static Productions() { Expr = NonTerminals.Expr; ExprTail = NonTerminals.ExprTail; Term = NonTerminals.Term; TermTail = NonTerminals.TermTail; Factor = NonTerminals.Factor; Expr.Add(NonTerminals.Term + NonTerminals.ExprTail); ExprTail.Add(("+" + NonTerminals.Term + NonTerminals.ExprTail) | ("-" + NonTerminals.Term + NonTerminals.ExprTail) | (Terminal.Epsilon) ); Term.Add(NonTerminals.Factor + NonTerminals.TermTail); TermTail.Add(("*" + NonTerminals.Factor + NonTerminals.TermTail) | ("/" + NonTerminals.Factor + NonTerminals.TermTail) | (Terminal.Epsilon) ); Factor.Add("(" + NonTerminals.Expr + ")") .Add(Terminals.Number); }
static Productions() { S = NonTerminals.S; E = NonTerminals.E; A = NonTerminals.A; B = NonTerminals.B; S.Add(NonTerminals.E); E.Add("+" + NonTerminals.A + "*" + NonTerminals.B + "("); A.Add(NonTerminals.A + "-").Add("-"); B.Add("/"); }
static Productions() { S = NonTerminals.S; E = NonTerminals.E; T = NonTerminals.T; F = NonTerminals.F; S.Add(NonTerminals.E); E.Add(NonTerminals.E + "+" + NonTerminals.T) .Add(NonTerminals.E + "-" + NonTerminals.T) .Add(NonTerminals.T); T.Add(NonTerminals.T + "*" + NonTerminals.F) .Add(NonTerminals.T + "/" + NonTerminals.F) .Add(NonTerminals.F); F.Add("(" + NonTerminals.E + ")") .Add(Terminals.Number); }