/** * Returns a new Token object, by default. However, if you want, you * can create and return subclass objects based on the value of ofKind. * Simply add the cases to the switch for all those special cases. * For example, if you have a subclass of Token called IDToken that * you want to create if ofKind is ID, simlpy add something like : * * case MyParserConstants.ID : return new IDToken(); * * to the following switch statement. Then you can cast matchedToken * variable to the appropriate type and use it in your lexical actions. */ public static final Token newToken(int ofKind) { switch(ofKind) { default : return new Token(); } }
public boolean equals(Object obj) { if (!(obj instanceof SimpleNode)) { return false; } try { SimpleNode other = (SimpleNode) obj; boolean equals = _id == other._id && _firstToken.equals(other._firstToken);// && // _lastToken.equals(other._lastToken); return equals; } catch (Exception e) { return false; } }
/** * The concrete implementation for this method has be removed into Thoken.java. * By stephen * @param viewer where the node is displayed * @return */ public int getStartOffset(IDocument document) { Assert.isNotNull(document); int offset = 0; if(_firstToken != null) { offset = _firstToken.getStartOffset(document); } return offset; }
/** * * @param viewer where the node is displayed * @see getGreatestEndOffset */ public int getEndOffset(IDocument document) { Assert.isNotNull(document); int offset = 0; if (_lastToken != null) { offset = _lastToken.getEndOffset(document); } return offset; }
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) { this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason); _token = new Token(); _token.beginLine = errorLine; _token.beginColumn = errorColumn; _token.endLine = errorLine; _token.endColumn = errorColumn + 1; }