protected String retrieveLookAheadText(int lookAheadPosition) throws TokenStreamException { Token token = LT(lookAheadPosition); return token == null ? null : token.getText(); }
public final int token() throws RecognitionException, TokenStreamException { int value=0; Token t = null; t = LT(1); match(TOKEN); if ( inputState.guessing==0 ) { value = Integer.parseInt(t.getText()); } return value; }
protected void out(Token token) { out( token.getText() ); }
@Override public void initialize(Token tok) { super.initialize(tok); filename = tok.getFilename(); line = tok.getLine(); column = tok.getColumn(); String text = tok.getText(); textLength = StringHelper.isEmpty(text) ? 0 : text.length(); }
protected Token makeToken(int t) { Token tok = super.makeToken(t); if (tok.getType() == EOF) tok.setText("EOF"); if (tok.getText() == null) { tok.setText("(no text)"); } return tok; } public OQLLexer(InputStream in) {
@Override protected void startQualifiedAttribute(Token attributeNameToken, Token qualifierToken) { final String attributeName = attributeNameToken.getText(); final String qualifierName = qualifierToken.getText(); if ( PARSING_LOGGER.isDebugEnabled() ) { PARSING_LOGGER.debugf( "%s Start qualified attribute : %s.%s", StringHelper.repeat( ">>", attributeNodeStack.depth() + 1 ), attributeName, qualifierName ); } final AttributeNodeImplementor<?> attributeNode = resolveAttributeNode( attributeName ); attributeNodeStack.push( attributeNode ); final PathQualifierType pathQualifierType = resolvePathQualifier( qualifierName ); graphSourceStack.push( pathQualifierType.getSubGraphCreator() ); }
@Override protected void startAttribute(Token attributeNameToken) { final String attributeName = attributeNameToken.getText(); if ( PARSING_LOGGER.isDebugEnabled() ) { PARSING_LOGGER.debugf( "%s Start attribute : %s", StringHelper.repeat( ">>", attributeNodeStack.depth() + 1 ), attributeName ); } final AttributeNodeImplementor attributeNode = resolveAttributeNode( attributeName ); attributeNodeStack.push( attributeNode ); graphSourceStack.push( PathQualifierType.VALUE.getSubGraphCreator() ); }
@Override protected void startSubGraph(Token subTypeToken) { final String subTypeName = subTypeToken == null ? null : subTypeToken.getText(); if ( PARSING_LOGGER.isDebugEnabled() ) { PARSING_LOGGER.debugf( "%s Starting graph : %s", StringHelper.repeat( ">>", attributeNodeStack.depth() + 2 ), subTypeName ); } final AttributeNodeImplementor<?> attributeNode = attributeNodeStack.getCurrent(); graphStack.push( graphSourceStack.getCurrent() .createSubGraph( attributeNode, subTypeName, sessionFactory ) ); }
public final void mSINGLE_LINE_COMMENT(boolean _createToken) throws RecognitionException, CharStreamException, TokenStreamException { int _ttype; Token _token=null; int _begin=text.length(); _ttype = SINGLE_LINE_COMMENT; int _saveIndex; Token content=null; match("//"); if ( inputState.guessing==0 ) { mCommentListener.reportSingleLineComment("//", getLine(), getColumn() - 3); } mSINGLE_LINE_COMMENT_CONTENT(true); content=_returnToken; if ( inputState.guessing==0 ) { text.setLength(_begin); text.append(content.getText()); } if ( _createToken && _token==null && _ttype!=Token.SKIP ) { _token = makeToken(_ttype); _token.setText(new String(text.getBuffer(), _begin, text.length()-_begin)); } _returnToken = _token; }
/** * Create block comment from token. * @param token * Token object. * @return DetailAST with BLOCK_COMMENT type. */ public static DetailAST createBlockCommentNode(Token token) { final DetailAST blockComment = new DetailAST(); blockComment.initialize(TokenTypes.BLOCK_COMMENT_BEGIN, BLOCK_MULTIPLE_COMMENT_BEGIN); // column counting begins from 0 blockComment.setColumnNo(token.getColumn() - 1); blockComment.setLineNo(token.getLine()); final DetailAST blockCommentContent = new DetailAST(); blockCommentContent.setType(TokenTypes.COMMENT_CONTENT); // column counting begins from 0 // plus length of '/*' blockCommentContent.setColumnNo(token.getColumn() - 1 + 2); blockCommentContent.setLineNo(token.getLine()); blockCommentContent.setText(token.getText()); final DetailAST blockCommentClose = new DetailAST(); blockCommentClose.initialize(TokenTypes.BLOCK_COMMENT_END, BLOCK_MULTIPLE_COMMENT_END); final Map.Entry<Integer, Integer> linesColumns = countLinesColumns( token.getText(), token.getLine(), token.getColumn()); blockCommentClose.setLineNo(linesColumns.getKey()); blockCommentClose.setColumnNo(linesColumns.getValue()); blockComment.addChild(blockCommentContent); blockComment.addChild(blockCommentClose); return blockComment; }
public final void hintIdentifier() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST hintIdentifier_AST = null; Token n = null; AST n_AST = null; n = LT(1); n_AST = astFactory.create(n); astFactory.addASTChild(currentAST, n_AST); match(StringLiteral); if ( inputState.guessing==0 ) { hintIdentifier_AST = (AST)currentAST.root; hintIdentifier_AST =(AST)astFactory.create(HINT,n.getText(),"org.apache.geode.cache.query.internal.parse.ASTHintIdentifier") ; currentAST.root = hintIdentifier_AST; currentAST.child = hintIdentifier_AST!=null &&hintIdentifier_AST.getFirstChild()!=null ? hintIdentifier_AST.getFirstChild() : hintIdentifier_AST; currentAST.advanceChildToEnd(); } hintIdentifier_AST = (AST)currentAST.root; returnAST = hintIdentifier_AST; }
text.setLength(_begin); text.append(content.getText());
a_AST = (AST)returnAST; match(CLOSE); if (!( i.getText().equalsIgnoreCase("treat") )) throw new SemanticException(" i.getText().equalsIgnoreCase(\"treat\") ");
+ token.getText() + "' is being interpreted as an identifier due to: " + mte.getMessage() );
a_AST = (AST)returnAST; match(CLOSE); if (!(i.getText().equalsIgnoreCase("treat") )) throw new SemanticException("i.getText().equalsIgnoreCase(\"treat\") ");
/** * Create single-line comment from token. * @param token to create the AST * @return DetailAST with SINGLE_LINE_COMMENT type */ private static DetailAST createSlCommentNode(Token token) { final DetailAST slComment = new DetailAST(); slComment.setType(TokenTypes.SINGLE_LINE_COMMENT); slComment.setText("//"); // column counting begins from 0 slComment.setColumnNo(token.getColumn() - 1); slComment.setLineNo(token.getLine()); final DetailAST slCommentContent = new DetailAST(); slCommentContent.setType(TokenTypes.COMMENT_CONTENT); // column counting begins from 0 // plus length of '//' slCommentContent.setColumnNo(token.getColumn() - 1 + 2); slCommentContent.setLineNo(token.getLine()); slCommentContent.setText(token.getText()); slComment.addChild(slCommentContent); return slComment; }
astFactory.addASTChild(currentAST, returnAST); else if (((LA(1)==AT) && (LA(2)==IDENT))&&(LA(1)==AT && !LT(2).getText().equals("interface"))) { annotation(); astFactory.addASTChild(currentAST, returnAST);
i_AST.setType( METHOD_CALL ); i_AST.setText( i_AST.getText() + " (" + functionName + ")" ); jpaFunctionSyntax_AST = (AST)astFactory.make( (new ASTArray(3)).add(i_AST).add(astFactory.create(IDENT,unquote(n.getText()))).add(a_AST));