Esempio n. 1
0
        public override void ExitResource([NotNull] Java9Parser.ResourceContext context)
        {
            int i;

            for (i = 0; i < context.ChildCount; ++i)
            {
                if (context.GetChild(i) as Java9Parser.VariableDeclaratorIdContext != null)
                {
                    break;
                }
            }
            var     vdi  = context.GetChild(i) as Java9Parser.VariableDeclaratorIdContext;
            var     id   = vdi.GetChild(0);
            var     term = id.GetChild(0) as TerminalNodeImpl;
            var     name = term.GetText();
            ISymbol f    = new Symtab.LocalSymbol(name, term.Symbol);

            _pd.Attributes[vdi] = new List <CombinedScopeSymbol>()
            {
                (CombinedScopeSymbol)f
            };
            var scope = GetScope(NearestScope(context));

            scope.define(ref f);
            _pd.Attributes[context.GetChild(0)] = new List <CombinedScopeSymbol>()
            {
                (CombinedScopeSymbol)f
            };
            _pd.Attributes[context] = new List <CombinedScopeSymbol>()
            {
                (CombinedScopeSymbol)f
            };
        }
Esempio n. 2
0
        public override void EnterLocalVariableDeclaration(Java9Parser.LocalVariableDeclarationContext context)
        {
            int i;

            for (i = 0; i < context.ChildCount; ++i)
            {
                if (context.GetChild(i) as Java9Parser.VariableDeclaratorListContext != null)
                {
                    break;
                }
            }
            var vdl = context.GetChild(i) as Java9Parser.VariableDeclaratorListContext;

            for (int j = 0; j < vdl.ChildCount; j += 2)
            {
                var     vd    = vdl.GetChild(j) as Java9Parser.VariableDeclaratorContext;
                var     vdid  = vd.GetChild(0);
                var     id    = vdid.GetChild(0);
                var     term  = id.GetChild(0) as TerminalNodeImpl;
                var     name  = term.GetText();
                ISymbol f     = new Symtab.LocalSymbol(name, term.Symbol);
                var     scope = GetScope(NearestScope(context));
                scope.define(ref f);
                _pd.Attributes[term] = new List <CombinedScopeSymbol>()
                {
                    (CombinedScopeSymbol)f
                };
                _pd.Attributes[id] = new List <CombinedScopeSymbol>()
                {
                    (CombinedScopeSymbol)f
                };
            }
        }