public VarAstNode(int ttype, VarDescr varDescr) : base(new CommonToken(AstNodeType.VAR)) { VarDescr = varDescr; }
// $ANTLR start "ident" // antlr_temp_dir\\MathExpr.g:54:1: ident : id= IDENT -> VAR[varDescr] ; public MathExprParser.ident_return ident() // throws RecognitionException [1] { MathExprParser.ident_return retval = new MathExprParser.ident_return(); retval.Start = input.LT(1); object root_0 = null; IToken id = null; object id_tree=null; RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor,"token IDENT"); try { // antlr_temp_dir\\MathExpr.g:54:6: (id= IDENT -> VAR[varDescr] ) // antlr_temp_dir\\MathExpr.g:55:3: id= IDENT { id=(IToken)Match(input,IDENT,FOLLOW_IDENT_in_ident345); stream_IDENT.Add(id); string identifier=((id != null) ? id.Text : null); // работа с таблицей идентификаторов VarDescr varDescr = null; if (identTable.ContainsKey(identifier)) { IdentDescr identDescr = identTable[identifier]; if (identDescr is VarDescr) varDescr = (VarDescr)identDescr; else throw new ParserBaseException(string.Format("Идентификатор {0} не является переменной (pos={1},{2})", identifier, id.Line, id.CharPositionInLine)); } else { varDescr = new VarDescr(identifier); identTable[identifier] = varDescr; } // AST REWRITE // elements: // token labels: // rule labels: retval // token list labels: // rule list labels: // wildcard labels: retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null); root_0 = (object)adaptor.GetNilNode(); // 71:5: -> VAR[varDescr] { adaptor.AddChild(root_0, new VarAstNode(VAR, varDescr)); } retval.Tree = root_0;retval.Tree = root_0; } retval.Stop = input.LT(-1); retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop); } catch (RecognitionException re) { ReportError(re); Recover(input,re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { } return retval; }