public override IAstNode VisitRecDecl(MicroCParser.RecDeclContext context) { var label = ++_label; _symbolTable.AddScope(); IList <Identifier> fields = context.fieldDeclaration().Select(x => Visit(x) as Identifier).ToList(); var children = _symbolTable.RemoveScope(); string name = context.name.Text; var id = _symbolTable.InsertSymbol(name, children); var recDecl = new RecordDecl(name, fields); recDecl.Label = label; recDecl.Id = id; _recordDecls.Add(recDecl); return(recDecl); }
/// <summary> /// Exit a parse tree produced by the <c>recDecl</c> /// labeled alternative in <see cref="MicroCParser.declaration"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitRecDecl([NotNull] MicroCParser.RecDeclContext context) { }
/// <summary> /// Visit a parse tree produced by the <c>recDecl</c> /// labeled alternative in <see cref="MicroCParser.declaration"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitRecDecl([NotNull] MicroCParser.RecDeclContext context) { return(VisitChildren(context)); }