public void addWarning(String warning, String solution) { Token lt = null; try { lt = LT(1); } catch (TokenStreamException ee) { } if (lt == null) lt = Token.badToken; Map row = new HashMap(); row.put("warning", warning); row.put("solution", solution); row.put("filename", getFilename()); row.put("line", Integer.valueOf(lt.getLine())); row.put("column", Integer.valueOf(lt.getColumn())); // System.out.println(row); warningList.add(row); }
/** An IDENT token whose spelling is required to start with an uppercase letter. * In the case of a simple statement {UpperID name} the identifier is taken to be a type name, not a command name. */ public final void upperCaseIdent() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST upperCaseIdent_AST = null; if (!(isUpperCase(LT(1)))) throw new SemanticException("isUpperCase(LT(1))"); AST tmp64_AST = null; tmp64_AST = astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp64_AST); match(IDENT); upperCaseIdent_AST = (AST)currentAST.root; returnAST = upperCaseIdent_AST; }
public final void variableName() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST variableName_AST = null; AST tmp217_AST = null; tmp217_AST = astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp217_AST); match(IDENT); variableName_AST = (AST)currentAST.root; returnAST = variableName_AST; }
/** A block known to be a closure, but which omits its arguments, is given this placeholder. * A subsequent pass is responsible for deciding if there is an implicit 'it' parameter, * or if the parameter list should be empty. */ public final void implicitParameters() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST implicitParameters_AST = null; Token first = LT(1); if ( inputState.guessing==0 ) { implicitParameters_AST = (AST)currentAST.root; implicitParameters_AST = (AST)astFactory.make( (new ASTArray(1)).add(create(IMPLICIT_PARAMETERS,"IMPLICIT_PARAMETERS",first,LT(1)))); currentAST.root = implicitParameters_AST; currentAST.child = implicitParameters_AST!=null &&implicitParameters_AST.getFirstChild()!=null ? implicitParameters_AST.getFirstChild() : implicitParameters_AST; currentAST.advanceChildToEnd(); } implicitParameters_AST = (AST)currentAST.root; returnAST = implicitParameters_AST; }
/** Simple names, as in {x|...}, are completely equivalent to {(def x)|...}. Build the right AST. */ public final void closableBlockParam() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST closableBlockParam_AST = null; Token id = null; AST id_AST = null; Token first = LT(1); id = LT(1); id_AST = astFactory.create(id); match(IDENT); if ( inputState.guessing==0 ) { closableBlockParam_AST = (AST)currentAST.root; closableBlockParam_AST = (AST)astFactory.make( (new ASTArray(4)).add(create(PARAMETER_DEF,"PARAMETER_DEF",first,LT(1))).add((AST)astFactory.make( (new ASTArray(1)).add(create(MODIFIERS,"MODIFIERS",first,LT(1))))).add((AST)astFactory.make( (new ASTArray(1)).add(create(TYPE,"TYPE",first,LT(1))))).add(id_AST)); currentAST.root = closableBlockParam_AST; currentAST.child = closableBlockParam_AST!=null &&closableBlockParam_AST.getFirstChild()!=null ? closableBlockParam_AST.getFirstChild() : closableBlockParam_AST; currentAST.advanceChildToEnd(); } returnAST = closableBlockParam_AST; }
/** Lookahead to check whether a block begins with explicit closure arguments. */ public final void closableBlockParamsStart() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST closableBlockParamsStart_AST = null; nls(); parameterDeclarationList(); nls(); AST tmp225_AST = null; tmp225_AST = astFactory.create(LT(1)); match(CLOSABLE_BLOCK_OP); returnAST = closableBlockParamsStart_AST; }
/** A labeled statement, consisting of a vanilla identifier followed by a colon. */ public final void statementLabelPrefix() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST statementLabelPrefix_AST = null; Token c = null; AST c_AST = null; AST tmp230_AST = null; tmp230_AST = astFactory.create(LT(1)); astFactory.addASTChild(currentAST, tmp230_AST); match(IDENT); c = LT(1); c_AST = astFactory.create(c); astFactory.makeASTRoot(currentAST, c_AST); match(COLON); if ( inputState.guessing==0 ) { c_AST.setType(LABELED_STAT); } nls(); statementLabelPrefix_AST = (AST)currentAST.root; returnAST = statementLabelPrefix_AST; }
/** A list of one or more modifier, annotation, or "def". */ public final void modifiers() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST modifiers_AST = null; Token first = LT(1); modifiersInternal(); astFactory.addASTChild(currentAST, returnAST); if ( inputState.guessing==0 ) { modifiers_AST = (AST)currentAST.root; modifiers_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(MODIFIERS,"MODIFIERS",first,LT(1))).add(modifiers_AST)); currentAST.root = modifiers_AST; currentAST.child = modifiers_AST!=null &&modifiers_AST.getFirstChild()!=null ? modifiers_AST.getFirstChild() : modifiers_AST; currentAST.advanceChildToEnd(); } modifiers_AST = (AST)currentAST.root; returnAST = modifiers_AST; }
public final void assignmentLessExpression() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST assignmentLessExpression_AST = null; Token first = LT(1); { conditionalExpression(0); astFactory.addASTChild(currentAST, returnAST); } if ( inputState.guessing==0 ) { assignmentLessExpression_AST = (AST)currentAST.root; assignmentLessExpression_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(EXPR,"EXPR",first,LT(1))).add(assignmentLessExpression_AST)); currentAST.root = assignmentLessExpression_AST; currentAST.child = assignmentLessExpression_AST!=null &&assignmentLessExpression_AST.getFirstChild()!=null ? assignmentLessExpression_AST.getFirstChild() : assignmentLessExpression_AST; currentAST.advanceChildToEnd(); } assignmentLessExpression_AST = (AST)currentAST.root; returnAST = assignmentLessExpression_AST; }
public final void typeArgumentsDiamond() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST typeArgumentsDiamond_AST = null; Token first = LT(1); match(LT); match(GT); nls(); if ( inputState.guessing==0 ) { typeArgumentsDiamond_AST = (AST)currentAST.root; typeArgumentsDiamond_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(TYPE_ARGUMENTS,"TYPE_ARGUMENTS",first,LT(1))).add(typeArgumentsDiamond_AST)); currentAST.root = typeArgumentsDiamond_AST; currentAST.child = typeArgumentsDiamond_AST!=null &&typeArgumentsDiamond_AST.getFirstChild()!=null ? typeArgumentsDiamond_AST.getFirstChild() : typeArgumentsDiamond_AST; currentAST.advanceChildToEnd(); } typeArgumentsDiamond_AST = (AST)currentAST.root; returnAST = typeArgumentsDiamond_AST; }
/** Used in cases where a declaration cannot have commas, or ends with the "in" operator instead of '='. */ public final void singleVariable( AST mods, AST t ) throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST singleVariable_AST = null; AST id_AST = null; Token first = LT(1); variableName(); id_AST = (AST)returnAST; if ( inputState.guessing==0 ) { singleVariable_AST = (AST)currentAST.root; singleVariable_AST = (AST)astFactory.make( (new ASTArray(4)).add(create(VARIABLE_DEF,"VARIABLE_DEF",first,LT(1))).add(mods).add((AST)astFactory.make( (new ASTArray(2)).add(create(TYPE,"TYPE",first,LT(1))).add(t))).add(id_AST)); currentAST.root = singleVariable_AST; currentAST.child = singleVariable_AST!=null &&singleVariable_AST.getFirstChild()!=null ? singleVariable_AST.getFirstChild() : singleVariable_AST; currentAST.advanceChildToEnd(); } returnAST = singleVariable_AST; }
/** An assignment operator '=' followed by an expression. (Never empty.) */ public final void varInitializer() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST varInitializer_AST = null; AST tmp43_AST = null; tmp43_AST = astFactory.create(LT(1)); astFactory.makeASTRoot(currentAST, tmp43_AST); match(ASSIGN); nls(); expressionStatementNoCheck(); astFactory.addASTChild(currentAST, returnAST); varInitializer_AST = (AST)currentAST.root; returnAST = varInitializer_AST; }
public final void finallyClause() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST finallyClause_AST = null; AST finallyCs_AST = null; Token first = LT(1); match(LITERAL_finally); nlsWarn(); compoundStatement(); finallyCs_AST = (AST)returnAST; if ( inputState.guessing==0 ) { finallyClause_AST = (AST)currentAST.root; finallyClause_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(LITERAL_finally,"finally",first,LT(1))).add(finallyCs_AST)); currentAST.root = finallyClause_AST; currentAST.child = finallyClause_AST!=null &&finallyClause_AST.getFirstChild()!=null ? finallyClause_AST.getFirstChild() : finallyClause_AST; currentAST.advanceChildToEnd(); } finallyClause_AST = (AST)currentAST.root; returnAST = finallyClause_AST; }
/** An open block is not allowed to have closure arguments. */ public final void openBlock() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST openBlock_AST = null; AST bb_AST = null; Token first = LT(1); match(LCURLY); nls(); blockBody(EOF); bb_AST = (AST)returnAST; match(RCURLY); if ( inputState.guessing==0 ) { openBlock_AST = (AST)currentAST.root; openBlock_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(SLIST,"{",first,LT(1))).add(bb_AST)); currentAST.root = openBlock_AST; currentAST.child = openBlock_AST!=null &&openBlock_AST.getFirstChild()!=null ? openBlock_AST.getFirstChild() : openBlock_AST; currentAST.advanceChildToEnd(); } openBlock_AST = (AST)currentAST.root; returnAST = openBlock_AST; }
public final void packageDefinition() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST packageDefinition_AST = null; AST an_AST = null; AST id_AST = null; Token first = LT(1); annotationsOpt(); an_AST = (AST)returnAST; match(LITERAL_package); identifier(); id_AST = (AST)returnAST; if ( inputState.guessing==0 ) { packageDefinition_AST = (AST)currentAST.root; packageDefinition_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(PACKAGE_DEF,"package",first,LT(1))).add(an_AST).add(id_AST)); currentAST.root = packageDefinition_AST; currentAST.child = packageDefinition_AST!=null &&packageDefinition_AST.getFirstChild()!=null ? packageDefinition_AST.getFirstChild() : packageDefinition_AST; currentAST.advanceChildToEnd(); } packageDefinition_AST = (AST)currentAST.root; returnAST = packageDefinition_AST; }
public final void annotationMemberValuePair() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST annotationMemberValuePair_AST = null; AST i_AST = null; AST v_AST = null; Token first = LT(1); annotationIdent(); i_AST = (AST)returnAST; match(ASSIGN); nls(); annotationMemberValueInitializer(); v_AST = (AST)returnAST; if ( inputState.guessing==0 ) { annotationMemberValuePair_AST = (AST)currentAST.root; annotationMemberValuePair_AST = (AST)astFactory.make( (new ASTArray(3)).add(create(ANNOTATION_MEMBER_VALUE_PAIR,"ANNOTATION_MEMBER_VALUE_PAIR",first,LT(1))).add(i_AST).add(v_AST)); currentAST.root = annotationMemberValuePair_AST; currentAST.child = annotationMemberValuePair_AST!=null &&annotationMemberValuePair_AST.getFirstChild()!=null ? annotationMemberValuePair_AST.getFirstChild() : annotationMemberValuePair_AST; currentAST.advanceChildToEnd(); } returnAST = annotationMemberValuePair_AST; }
/** Used to look ahead for a constructor */ public final void constructorStart() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST constructorStart_AST = null; Token id = null; AST id_AST = null; modifiersOpt(); id = LT(1); id_AST = astFactory.create(id); match(IDENT); if (!(isConstructorIdent(id))) throw new SemanticException("isConstructorIdent(id)"); nls(); match(LPAREN); returnAST = constructorStart_AST; }
public void requireFailed(String problem, String solution) throws SemanticException { // TODO: Needs more work. Token lt = null; int lineNum = Token.badToken.getLine(), colNum = Token.badToken.getColumn(); try { lt = LT(1); if(lt != null) { lineNum = lt.getLine(); colNum = lt.getColumn(); } } catch (TokenStreamException ee) { if(ee instanceof TokenStreamRecognitionException) { lineNum = ((TokenStreamRecognitionException) ee).recog.getLine(); colNum = ((TokenStreamRecognitionException) ee).recog.getColumn(); } } throw new SemanticException(problem + ";\n solution: " + solution, getFilename(), lineNum, colNum); }
public void matchGenericTypeBracketsFailed(String problem, String solution) throws SemanticException { Token lt = null; int lineNum = Token.badToken.getLine(), colNum = Token.badToken.getColumn(); try { lt = LT(1); if(lt != null) { lineNum = lt.getLine(); colNum = lt.getColumn(); } } catch (TokenStreamException ee) { if(ee instanceof TokenStreamRecognitionException) { lineNum = ((TokenStreamRecognitionException) ee).recog.getLine(); colNum = ((TokenStreamRecognitionException) ee).recog.getColumn(); } } throw new SemanticException(problem + ";\n solution: " + solution, getFilename(), lineNum, colNum); }
/** Zero or more insignificant newlines, all gobbled up and thrown away. */ public final void nls() throws RecognitionException, TokenStreamException { returnAST = null; ASTPair currentAST = new ASTPair(); AST nls_AST = null; { if ((LA(1)==NLS) && (_tokenSet_2.member(LA(2)))) { match(NLS); } else if ((_tokenSet_2.member(LA(1))) && (_tokenSet_3.member(LA(2)))) { } else { throw new NoViableAltException(LT(1), getFilename()); } } returnAST = nls_AST; }