Ejemplo n.º 1
0
 public LR0Item(Production production, int position)
 {
   Production = production;
   Position = position;
   ID = instance_counter++;
 }
Ejemplo n.º 2
0
 private LRItem FindItem(ParserState state, Production production, int position)
 {
   foreach (LRItem item in state.Items)
     if (item.Core.Production == production && item.Core.Position == position)
       return item;
   string msg = string.Format("Failed to find an LRItem in state {0} by production [{1}] and position {2}. ",
     state, production.ToString(), position.ToString());
   throw new CompilerException(msg);
 }
Ejemplo n.º 3
0
    public ProductionList ReduceProductions = new ProductionList(); //may be more than one, in case of conflict

    internal ActionRecord(string key, ParserActionType type, ParserState newState, Production reduceProduction)
    {
      Key = key;
      ActionType = type;
      NewState = newState;
      if (reduceProduction != null)
        ReduceProductions.Add(reduceProduction);
    }
Ejemplo n.º 4
0
    private void CreateProductions()
    {
      _data.Productions.Clear();

      LR0Item.instance_counter = 0;
      foreach (NonTerminal nt in _data.NonTerminals)
      {
        nt.Productions.Clear();
        BnfExpressionData allData = new BnfExpressionData();
        allData.AddRange(nt.Rule.Data);

        foreach (BnfTermList prodOperands in allData)
        {
          bool isInitial = (nt == _data.AugmentedRoot);
          Production prod = new Production(isInitial, nt, prodOperands);
          nt.Productions.Add(prod);
          _data.Productions.Add(prod);
        }
      }
    }