@Override protected Token fetchSymbol() { Token result = Token.create(Token.TokenType.SYMBOL, input.current()); result.addToTrigger(input.consume()); while (isSymbolCharacter(input.current()) && !input.current().is(',')) { result.addToTrigger(input.consume()); } return result; } }
/** * Reads and returns a special id. * * @return the parsed special id as Token */ protected Token fetchSpecialId() { Token result = Token.create(Token.TokenType.SPECIAL_ID, input.current()); result.addToTrigger(input.consume()); while (isIdentifierChar(input.current())) { result.addToContent(input.consume()); } return handleKeywords(result); }
/** * Reads and returns a special id. * * @return the parsed special id as Token */ protected Token fetchSpecialId() { Token result = Token.create(Token.TokenType.SPECIAL_ID, input.current()); result.addToTrigger(input.consume()); while (isIdentifierChar(input.current())) { result.addToContent(input.consume()); } return handleKeywords(result); }
/** * Reads and returns a symbol. * <p> * A symbol are one or two characters, which don't match any other token type. In most cases, this will be * operators like + or *. * * @return the parsed symbol as Token */ @SuppressWarnings("squid:S1067") protected Token fetchSymbol() { Token result = Token.create(Token.TokenType.SYMBOL, input.current()); result.addToTrigger(input.consume()); if (result.isSymbol("*") && input.current().is('*') || result.isSymbol("&") && input.current().is('&') || result.isSymbol("|") && input.current().is('|') || result.isSymbol() && input.current().is('=')) { result.addToTrigger(input.consume()); } return result; }
/** * Reads and returns a symbol. * <p> * A symbol are one or two characters, which don't match any other token type. In most cases, this will be * operators like + or *. * * @return the parsed symbol as Token */ @SuppressWarnings("squid:S1067") protected Token fetchSymbol() { Token result = Token.create(Token.TokenType.SYMBOL, input.current()); result.addToTrigger(input.consume()); if (result.isSymbol("*") && input.current().is('*') || result.isSymbol("&") && input.current().is('&') || result.isSymbol("|") && input.current().is('|') || result.isSymbol() && input.current().is('=')) { result.addToTrigger(input.consume()); } return result; }
/** * Reads and returns a string constant. * * @return the parsed string constant a Token */ protected Token fetchString() { char separator = input.current().getValue(); char escapeChar = stringDelimiters.get(input.current().getValue()); Token result = Token.create(Token.TokenType.STRING, input.current()); result.addToTrigger(input.consume()); while (!input.current().isNewLine() && !input.current().is(separator) && !input.current().isEndOfInput()) { if (escapeChar != '\0' && input.current().is(escapeChar)) { result.addToSource(input.consume()); if (!handleStringEscape(separator, escapeChar, result)) { problemCollector.add(ParseError.error(input.next(), String.format("Cannot use '%s' as escaped character", input.next().getStringValue()))); } } else { result.addToContent(input.consume()); } } if (input.current().is(separator)) { result.addToSource(input.consume()); } else { problemCollector.add(ParseError.error(input.current(), "Premature end of string constant")); } return result; }
/** * Reads and returns a string constant. * * @return the parsed string constant a Token */ protected Token fetchString() { char separator = input.current().getValue(); char escapeChar = stringDelimiters.get(input.current().getValue()); Token result = Token.create(Token.TokenType.STRING, input.current()); result.addToTrigger(input.consume()); while (!input.current().isNewLine() && !input.current().is(separator) && !input.current().isEndOfInput()) { if (escapeChar != '\0' && input.current().is(escapeChar)) { result.addToSource(input.consume()); if (!handleStringEscape(separator, escapeChar, result)) { problemCollector.add(ParseError.error(input.next(), String.format("Cannot use '%s' as escaped character", input.next().getStringValue()))); } } else { result.addToContent(input.consume()); } } if (input.current().is(separator)) { result.addToSource(input.consume()); } else { problemCollector.add(ParseError.error(input.current(), "Premature end of string constant")); } return result; }