String generateFragment() { // Find the current position ... assert currentToken != null; int startIndex = currentToken.startIndex(); return generateFragment(inputString, startIndex, 20, " ===>> "); }
String generateFragment() { // Find the current position ... assert currentToken != null; int startIndex = currentToken.startIndex(); return generateFragment(inputString, startIndex, 20, " ===>> "); }
String generateFragment() { // Find the current position ... assert currentToken != null; int startIndex = currentToken.startIndex(); return generateFragment(inputString, startIndex, 20, " ===>> "); }
/** * Attempt to consume this current token as long as it matches the expected character, or throw an exception if the token does * not match. * * @param expected the expected character of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( char expected ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingCharacter.text(expected); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (!currentToken().matches(expected)) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedCharacter.text(expected, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected character, or throw an exception if the token does * not match. * * @param expected the expected character of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( char expected ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingCharacter.text(expected); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (!currentToken().matches(expected)) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedCharacter.text(expected, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected character, or throw an exception if the token does * not match. * * @param expected the expected character of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( char expected ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingCharacter.text(expected); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (!currentToken().matches(expected)) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedCharacter.text(expected, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected character, or throw an exception if the token does * not match. * <p> * The {@link #ANY_TYPE ANY_TYPE} constant can be used in the expected values as a wildcard. * </p> * * @param expectedType the expected token type of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( int expectedType ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingTokenType.text(expectedType); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (expectedType != ANY_TYPE && currentToken().type() != expectedType) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedTokenType.text(expectedType, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected value, or throw an exception if the token does not * match. * <p> * The {@link #ANY_VALUE ANY_VALUE} constant can be used in the expected values as a wildcard. * </p> * * @param expected the expected value of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( String expected ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingToken.text(expected); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (expected != ANY_VALUE && !currentToken().matches(expected)) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedToken.text(expected, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected character, or throw an exception if the token does * not match. * <p> * The {@link #ANY_TYPE ANY_TYPE} constant can be used in the expected values as a wildcard. * </p> * * @param expectedType the expected token type of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( int expectedType ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingTokenType.text(expectedType); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (expectedType != ANY_TYPE && currentToken().type() != expectedType) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedTokenType.text(expectedType, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected value, or throw an exception if the token does not * match. * <p> * The {@link #ANY_VALUE ANY_VALUE} constant can be used in the expected values as a wildcard. * </p> * * @param expected the expected value of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( String expected ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingToken.text(expected); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (expected != ANY_VALUE && !currentToken().matches(expected)) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedToken.text(expected, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected value, or throw an exception if the token does not * match. * <p> * The {@link #ANY_VALUE ANY_VALUE} constant can be used in the expected values as a wildcard. * </p> * * @param expected the expected value of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( String expected ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingToken.text(expected); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (expected != ANY_VALUE && !currentToken().matches(expected)) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedToken.text(expected, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }
/** * Attempt to consume this current token as long as it matches the expected character, or throw an exception if the token does * not match. * <p> * The {@link #ANY_TYPE ANY_TYPE} constant can be used in the expected values as a wildcard. * </p> * * @param expectedType the expected token type of the current token * @throws ParsingException if the current token doesn't match the supplied value * @throws IllegalStateException if this method was called before the stream was {@link #start() started} */ public void consume( int expectedType ) throws ParsingException, IllegalStateException { if (completed) { String msg = CommonI18n.noMoreContentButWasExpectingTokenType.text(expectedType); throw new ParsingException(tokens.get(tokens.size() - 1).position(), msg); } // Get the value from the current token ... if (expectedType != ANY_TYPE && currentToken().type() != expectedType) { String found = currentToken().value(); Position pos = currentToken().position(); String fragment = generateFragment(); String msg = CommonI18n.unexpectedTokenType.text(expectedType, found, pos.getLine(), pos.getColumn(), fragment); throw new ParsingException(pos, msg); } moveToNextToken(); }