/// <summary> /// Creates a new rule. /// </summary> /// <param name="id">Id of this rule.</param> /// <param name="lhs">Left hand side. The other symbols can be reduced to /// this symbol.</param> /// <param name="rhs">The right hand side. The symbols that can be reduced.</param> public Rule(int id, SymbolNonterminal lhs, Symbol[] rhs) { this.id = id; this.lhs = lhs; this.rhs = rhs; }
public Action this[Symbol symbol] { get { return Get(symbol);} }
private RuleCollection CreateRules(CGTContent content) { RuleCollection rules = new RuleCollection(); foreach (RuleRecord ruleRecord in content.RuleTable) { SymbolNonterminal lhs = symbols[ruleRecord.Nonterminal] as SymbolNonterminal; //todo: exception handling? Symbol[] rhs = new Symbol[ruleRecord.Symbols.Count]; for (int i = 0; i< rhs.Length; i++) { rhs[i] = symbols[ruleRecord.Symbols[i]]; } Rule rule = new Rule(ruleRecord.Index,lhs,rhs); rules.Add(rule); } return rules; }
public Action Get(Symbol symbol) { return table[symbol] as Action; }
public void Add(Symbol symbol) { list.Add(symbol); }