//When a library is defined. public override object VisitStat_library([NotNull] algoParser.Stat_libraryContext context) { //Check if a library with this name already exists. if (Scopes.LibraryExists(context.IDENTIFIER().GetText())) { Error.Warning(context, "A library with the name '" + context.IDENTIFIER().GetText() + "' has already been loaded, so loading was ignored."); } //Switch the current scope out for a new "library" scope. AlgoScopeCollection oldScope = Scopes; Scopes = new AlgoScopeCollection(); //Evaluate the contents of the library. foreach (var statement in context.statement()) { VisitStatement(statement); } //Save the new scope, and switch back to the old one. AlgoScopeCollection libScope = Scopes; Scopes = oldScope; //Add the library scope to the library list. Scopes.AddLibrary(context.IDENTIFIER().GetText(), libScope); return(null); }
/// <summary> /// Visit a parse tree produced by <see cref="algoParser.stat_library"/>. /// <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_library([NotNull] algoParser.Stat_libraryContext context) { return(VisitChildren(context)); }
/// <summary> /// Exit a parse tree produced by <see cref="algoParser.stat_library"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitStat_library([NotNull] algoParser.Stat_libraryContext context) { }