public void Register(IGrammarBuilder <INode> grammar) { grammar.Choice("terminal", grammar.Ref("terminalType"), grammar.Ref("terminalLiteral"), grammar.Ref("terminalAny") ); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.Choice("atom", grammar.Ref("ruleRef"), grammar.Ref("terminal"), grammar.Sequence(null, grammar.TerminalValue("("), grammar.Ref("choice").Lift(), grammar.TerminalValue(")")) ); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.Sequence("choice", grammar.Ref("sequence"), grammar.ZeroOrMore(null, grammar.Sequence(null, grammar.TerminalValue("|"), grammar.Ref("sequence").Lift() )) ).ReduceWith(Reduce); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.Sequence("atomExpression", grammar.Optional(null, grammar.Choice(null, grammar.TerminalValue("&"), grammar.TerminalValue("!") ) ).As("prefix"), grammar.Ref("atom"), grammar.Optional(null, grammar.Ref("range")).As("suffix") ).ReduceWith(Reduce); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.Sequence("definition", grammar.Terminal(TokenType.Identifier).As("name"), grammar.TerminalValue(":="), grammar.Ref("choice").As("rule") ).ReduceWith(Reduce); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.Choice("range", grammar.TerminalValue("*"), grammar.TerminalValue("+"), grammar.TerminalValue("?"), grammar.Ref("minmax") ).ReduceWith(Reduce); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.Sequence("namedAtom", grammar.Ref("atomExpression").As("atom"), grammar.Optional(null, grammar.Choice(null, grammar.TerminalValue("#!"), grammar.Sequence(null, grammar.TerminalValue("#"), grammar.Terminal(TokenType.Identifier) )) ).As("name") ).ReduceWith(Reduce); }
public void Register(IGrammarBuilder <INode> grammar) { grammar.OneOrMore("sequence", grammar.Ref("namedAtom") ).ReduceWith(Reduce); }
public IRuleRef <TNode> Create <TNode>(IGrammarBuilder <TNode> grammar) { _grammarBuilderAdapter = new GrammarBuilderAdapter(rule => grammar.DefineRule(rule.Name, rule), name => grammar.Ref(name)); ArgAssert.NotNull(nameof(Factory), Factory); var rule = Factory(this); var ruleRef = grammar.DefineRule(rule.Name, rule); _grammarBuilderAdapter = null; if (RefName != null) { ruleRef.As(RefName); } return(ruleRef); }