Exemplo n.º 1
0
            public override void EnterCat([NotNull] lbnfParser.CatContext context)
            {
                if (context.Identifier() == null)
                {
                    return;
                }
                var id = context.Identifier().GetText();

                if (context.Parent is lbnfParser.DefContext ||
                    context.Parent is lbnfParser.CatContext)
                {
                    var     frontier = TreeEdits.Frontier(context);
                    var     list     = frontier.Select(t => t.Symbol).ToList();
                    ISymbol sym      = new NonterminalSymbol(id, list);
                    _pd.RootScope.define(ref sym);
                    CombinedScopeSymbol s = (CombinedScopeSymbol)sym;
                    _pd.Attributes[context] = new List <CombinedScopeSymbol>()
                    {
                        s
                    };
                    foreach (var tr in frontier)
                    {
                        _pd.Attributes[tr] = new List <CombinedScopeSymbol>()
                        {
                            s
                        }
                    }
                    ;
                }
            }
        }
Exemplo n.º 2
0
            public override void EnterCat([NotNull] lbnfParser.CatContext context)
            {
                if (context.Identifier() == null)
                {
                    return;
                }
                var id = context.Identifier().GetText();

                if (!(context.Parent is lbnfParser.ItemContext))
                {
                    return;
                }

                var            frontier = TreeEdits.Frontier(context);
                List <ISymbol> prior    = _pd.RootScope.LookupType(id).ToList();

                if (!prior.Any())
                {
                    var     listp = frontier.Select(t => t.Symbol).ToList();
                    ISymbol symp  = new NonterminalSymbol(id, listp);
                    _pd.RootScope.define(ref symp);
                    prior = _pd.RootScope.LookupType(id).ToList();
                }
                var list = frontier.Select(t => t.Symbol).ToList();
                List <CombinedScopeSymbol> new_attrs = new List <CombinedScopeSymbol>();
                CombinedScopeSymbol        s         = new RefSymbol(list, prior);

                new_attrs.Add(s);
                _pd.Attributes[context] = new_attrs;
                _pd.Attributes[context] = new List <CombinedScopeSymbol>()
                {
                    s
                };
                foreach (var tr in frontier)
                {
                    _pd.Attributes[tr] = new List <CombinedScopeSymbol>()
                    {
                        s
                    }
                }
                ;
            }
        }