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)); }
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]))); }
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); }
protected override object OnRule(INonterminalToken token) { return(NonterminalRule.From(token.Terminal(0).Value, false, Visit <IExpression>(token[1]))); }
protected override object OnOption(INonterminalToken token) { return(new Option(token.Terminal(0).Value, token.Terminal(1).Value)); }