示例#1
0
        protected override object OnOption(INonterminalToken token)
        {
            if (token == null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            return(new Option(token.Terminal(0).Value, token.Terminal(1).Value));
        }
示例#2
0
        protected override object OnRule(INonterminalToken token)
        {
            if (token == null)
            {
                throw new ArgumentNullException(nameof(token));
            }

            return(NonterminalRule.From(token.Terminal(0).Value, false, Visit <IExpression>(token[1])));
        }
示例#3
0
        protected override object OnGrammar(INonterminalToken token)
        {
            Debug.Assert(token[0].Symbol.Id == LinguId.Identifier);
            var grammar = new RawGrammar(token.Terminal(0).Value);

            foreach (var section in token.Nonterminal(1).Children)
            {
                var children = Visit <IReadOnlyList <Symbol> >(section);

                grammar.Options.AddRange(children.OfType <Option>());
                grammar.Terminals.AddRange(children.OfType <TerminalRule>());
                grammar.Nonterminals.AddRange(children.OfType <NonterminalRule>());
            }
            return(grammar);
        }
示例#4
0
 protected override object OnRule(INonterminalToken token)
 {
     return(NonterminalRule.From(token.Terminal(0).Value, false, Visit <IExpression>(token[1])));
 }
示例#5
0
 protected override object OnOption(INonterminalToken token)
 {
     return(new Option(token.Terminal(0).Value, token.Terminal(1).Value));
 }