Пример #1
0
 /// <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;
 }
Пример #2
0
		public Action this[Symbol symbol]
		{
			get { return Get(symbol);}
		}
Пример #3
0
        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;
        }
Пример #4
0
		public Action Get(Symbol symbol)
		{
			return table[symbol] as Action;
		}
Пример #5
0
 public void Add(Symbol symbol)
 {
     list.Add(symbol);
 }