/** * Creates a new token with the given type, using the Char a initial trigger and content. * * @param type the type if this token. The supplied Char will be used as initial part of the trigger to further * specify the token * @param ch first character of the content and trigger of this token. Also specifies the position of the token. * @return a new token which is initialized with the given Char */ public static Token createAndFill(TokenType type, Char ch) { Token result = new Token(); result.type = type; result.line = ch.getLine(); result.pos = ch.getPos(); result.contents = ch.getStringValue(); result.trigger = ch.getStringValue(); result.source = ch.toString(); return result; }
/** * Creates a new token with the given type, using the Char a initial trigger and content. * * @param type the type if this token. The supplied Char will be used as initial part of the trigger to further * specify the token * @param ch first character of the content and trigger of this token. Also specifies the position of the token. * @return a new token which is initialized with the given Char */ public static Token createAndFill(TokenType type, Char ch) { Token result = new Token(); result.type = type; result.line = ch.getLine(); result.pos = ch.getPos(); result.contents = ch.getStringValue(); result.trigger = ch.getStringValue(); result.source = ch.toString(); return result; }
private String readOp() { if (isNotEqual()) { reader.consume(2); return "<>"; } if (reader.current().is('<') && reader.next().is('=')) { reader.consume(2); return "<="; } if (reader.current().is('>') && reader.next().is('=')) { reader.consume(2); return ">="; } if (reader.current().is('=') || reader.current().is(':')) { reader.consume(); return "="; } if (reader.current().is('>')) { reader.consume(); return ">"; } if (reader.current().is('<')) { reader.consume(); return "<"; } else { throw new IllegalStateException(reader.current().toString()); } }