/** * Creates a <code>Reduction</code> from this token, adding the supplied * nodes as the second and third element, respectively. */ public Reduction asReduction( CSTNode second, CSTNode third ) { Reduction created = asReduction( second ); created.add( third ); return created; }
/** * Returns the starting column of the node. Returns -1 * if not known. */ public int getStartColumn() { return getRoot(true).getStartColumn(); }
/** * Creates a token that represents a symbol, using a library for the type. */ public static Token newSymbol( String type, int startLine, int startColumn ) { return new Token( Types.lookupSymbol(type), type, startLine, startColumn ); }
/** * Returns true if the node's meaning matches the specified type. */ public boolean isA( int type ) { return Types.ofType( getMeaning(), type ); }
/** * Creates a token that represents a keyword. Returns null if the * specified text isn't a keyword. */ public static Token newKeyword( String text, int startLine, int startColumn ) { int type = Types.lookupKeyword( text ); if( type != Types.UNKNOWN ) { return new Token( type, text, startLine, startColumn ); } return null; }
/** * Returns the starting line of the node. Returns -1 * if not known. */ public int getStartLine() { return getRoot(true).getStartLine(); }
/** * Returns true if the node can be coerced to the specified type. */ public boolean canMean( int type ) { return Types.canMean( getMeaning(), type ); }
/** * Returns the meaning of this node. If the node isEmpty(), returns * the type of Token.NULL. */ public int getMeaning() { return getRoot( true ).getMeaning(); }
/** * Sets the meaning for this node (and it's root Token). Not * valid if the node isEmpty(). Returns the node, for convenience. */ public CSTNode setMeaning( int meaning ) { getRoot().setMeaning( meaning ); return this; }
/** * Returns a description of the node. */ public String getDescription() { return Types.getDescription( getMeaning() ); }
/** * Creates a token that represents an identifier. */ public static Token newIdentifier( String text, int startLine, int startColumn ) { return new Token( Types.IDENTIFIER, text, startLine, startColumn ); }
/** * Returns true if the node is a complete expression. */ public boolean isAnExpression() { if( isA(Types.COMPLEX_EXPRESSION) ) { return true; } return marked; }
/** * Creates a <code>Reduction</code> from this token, adding the supplied * node as the second element. */ public Reduction asReduction( CSTNode second ) { Reduction created = asReduction(); created.add( second ); return created; }
/** * Creates a <code>Reduction</code> from this token, adding the supplied * nodes as the second, third, and fourth element, respectively. */ public Reduction asReduction( CSTNode second, CSTNode third, CSTNode fourth ) { Reduction created = asReduction( second, third ); created.add( fourth ); return created; }