public override AST_Node VisitCaseof([NotNull] CoolParser.CaseofContext context) { var exp = (AST_Expresion)Visit(context.expr()); List <AST_ClassProperty> props = new List <AST_ClassProperty>(); foreach (var item in context.branch()) { var s = new AST_FormalDec(item.formal(), new AST_Id(item.formal().ID(), item.formal().ID().GetText()), new AST_Type_Node(item.formal().TYPE(), item.formal().TYPE().GetText())); AST_ClassProperty x = new AST_ClassProperty(item, s, (AST_Expresion)Visit(item.expr())); props.Add(x); } return(new AST_CaseOf(context, new AST_ListProp(context, props), exp)); }
/// <summary> /// Visit a parse tree produced by the <c>caseof</c> /// labeled alternative in <see cref="CoolParser.expr"/>. /// <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 VisitCaseof([NotNull] CoolParser.CaseofContext context) { return(VisitChildren(context)); }