//When a variable is first defined. public override object VisitStat_define([NotNull] algoParser.Stat_defineContext context) { //Get the name of the identifier/objtext. string name = Particles.StitchVariableName(context, context.IDENTIFIER().GetText(), context.particle()); //Evaluate the expression on the right side of the define. AlgoValue value = (AlgoValue)VisitExpr(context.expr()); //Create the variable at the current scope. Scopes.AddVariable(name, value); return(null); }
/// <summary> /// Visit a parse tree produced by <see cref="algoParser.stat_define"/>. /// <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 VisitStat_define([NotNull] algoParser.Stat_defineContext context) { return(VisitChildren(context)); }
/// <summary> /// Enter a parse tree produced by <see cref="algoParser.stat_define"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void EnterStat_define([NotNull] algoParser.Stat_defineContext context) { }