Beispiel #1
0
        //Should it be Func_expr or Func_stmt?
        public override void EnterFunc_expr([NotNull] GrammarParser.Func_exprContext context)
        {
            ScopeNode LocalScope = new ScopeNode();

            Scopes.Add(LocalScope);
            LocalScope.Parent = currentScope;
            currentScope      = LocalScope;
            base.EnterFunc_expr(context);
        }
Beispiel #2
0
        public override void EnterIter_stmt([NotNull] GrammarParser.Iter_stmtContext context)
        {
            ScopeNode LocalScope = new ScopeNode();

            Scopes.Add(LocalScope);
            LocalScope.Parent = currentScope;
            currentScope      = LocalScope;

            base.EnterIter_stmt(context);
        }
Beispiel #3
0
        public override void EnterProgram([NotNull] GrammarParser.ProgramContext context)
        {
            ScopeNode GlobalScope = new ScopeNode();

            Scopes.Add(currentScope);
            Scopes.Add(GlobalScope);
            currentScope = GlobalScope;

            base.EnterProgram(context);
        }
Beispiel #4
0
        private bool LookUpScope(string expression)
        {
            ScopeNode Scope = currentScope;

            while (Scope != null)
            {
                if (Scope.SymbolTable.ContainsKey(expression))
                {
                    return(true);
                }
                else
                {
                    Scope = Scope.Parent;
                }
            }

            return(false);
        }
Beispiel #5
0
 public override void ExitFunc_expr([NotNull] GrammarParser.Func_exprContext context)
 {
     currentScope = currentScope.Parent;
     base.ExitFunc_expr(context);
 }
Beispiel #6
0
 public override void ExitCond_stmt([NotNull] GrammarParser.Cond_stmtContext context)
 {
     currentScope = currentScope.Parent;
     base.ExitCond_stmt(context);
 }