Exemplo n.º 1
0
        }//method

        private void CreateProductions()
        {
            _lastItemId = 0;
            //CheckWrapTailHints() method may add non-terminals on the fly, so we have to use for loop here (not foreach)
            for (int i = 0; i < _grammarData.NonTerminals.Count; i++)
            {
                var nt = _grammarData.NonTerminals[i];
                nt.Productions.Clear();
                //Get data (sequences) from both Rule and ErrorRule
                BnfExpressionData allData = new BnfExpressionData();
                allData.AddRange(nt.Rule.Data);
                if (nt.ErrorRule != null)
                {
                    allData.AddRange(nt.ErrorRule.Data);
                }
                //actually create productions for each sequence
                foreach (BnfTermList prodOperands in allData)
                {
                    Production prod = CreateProduction(nt, prodOperands);
                    nt.Productions.Add(prod);
                } //foreach prodOperands
                // insert pending custom hints in all productions
                nt.InsertCustomHints();
            }
        }
        }//method

        #endregion

        #region Creating Productions
        private void CreateProductions()
        {
            Data.Productions.Clear();
            //each LR0Item gets its unique ID, last assigned (max) Id is kept in static field
            LR0Item._maxID = 0;
            foreach (NonTerminal nt in Data.NonTerminals)
            {
                nt.Productions.Clear();
                //Get data (sequences) from both Rule and ErrorRule
                BnfExpressionData allData = new BnfExpressionData();
                allData.AddRange(nt.Rule.Data);
                if (nt.ErrorRule != null)
                {
                    allData.AddRange(nt.ErrorRule.Data);
                }
                //actually create productions for each sequence
                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);
                }//foreach prodOperands
            }
        }
 private void CreateProductions()
 {
     Data.Productions.Clear();
     //each LR0Item gets its unique ID, last assigned (max) Id is kept in static field
     LR0Item._maxID = 0;
     foreach (NonTerminal nt in Data.NonTerminals)
     {
         NtData ntInfo = NtData.GetOrCreate(nt);
         ntInfo.Productions.Clear();
         //Get data (sequences) from both Rule and ErrorRule
         BnfExpressionData allData = new BnfExpressionData();
         allData.AddRange(nt.Rule.Data);
         if (nt.ErrorRule != null)
         {
             allData.AddRange(nt.ErrorRule.Data);
         }
         //actually create productions for each sequence
         foreach (BnfTermList prodOperands in allData)
         {
             Production prod = CreateProduction(nt, prodOperands);
             //Add the production to non-terminal's list and to global list
             ntInfo.Productions.Add(prod);
             Data.Productions.Add(prod);
         }//foreach prodOperands
     }
 }
Exemplo 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);
                }
            }
        }
Exemplo n.º 5
0
 private void CreateProductions()
 {
     _lastItemId = 0;
       //CheckWrapTailHints() method may add non-terminals on the fly, so we have to use for loop here (not foreach)
       for (int i = 0; i < _grammarData.NonTerminals.Count; i++) {
     var nt = _grammarData.NonTerminals[i];
     nt.Productions.Clear();
     //Get data (sequences) from both Rule and ErrorRule
     BnfExpressionData allData = new BnfExpressionData();
     allData.AddRange(nt.Rule.Data);
     if (nt.ErrorRule != null)
       allData.AddRange(nt.ErrorRule.Data);
     //actually create productions for each sequence
     foreach (BnfTermList prodOperands in allData) {
       Production prod = CreateProduction(nt, prodOperands);
       nt.Productions.Add(prod);
     } //foreach prodOperands
     // insert pending custom hints in all productions
     nt.InsertCustomHints();
       }
 }
Exemplo n.º 6
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);
        }
      }
    }
        } //method

        private void CreateProductions()
        {
            _lastItemId = 0;
            //CheckWrapTailHints() method may add non-terminals on the fly, so we have to use for loop here (not foreach)
            foreach (var nt in _grammarData.NonTerminals)
            {
                nt.Productions.Clear();
                //Get data (sequences) from both Rule and ErrorRule
                var allData = new BnfExpressionData();
                allData.AddRange(nt.Rule.Data);
                if (nt.ErrorRule != null)
                    allData.AddRange(nt.ErrorRule.Data);
                //actually create productions for each sequence
                foreach (var prodOperands in allData)
                {
                    var prod = CreateProduction(nt, prodOperands);
                    nt.Productions.Add(prod);
                } //foreach prodOperands
            }
        }