Example #1
0
        public IGrammar ToGrammar()
        {
            if (StartSymbolExists())
            {
                if (ProductionsAreEmpty())
                {
                    PopulateMissingProductionsFromStart(Start);
                }
                AssertStartProductionExistsForStartSymbol(_reachibilityMatrix);
            }
            else
            {
                Start = _reachibilityMatrix.GetStartProduction();
            }

            var productions = GetProductionsFromProductionsModel();
            var ignoreRules = GetIgnoreRulesFromIgnoreRulesModel();

            return(new Grammar(Start.LeftHandSide.NonTerminal, productions, ignoreRules));
        }
Example #2
0
 private void SetStartProduction()
 {
     if (StartSymbolExists())
     {
         if (ProductionsAreEmpty())
         {
             PopulateMissingProductionsFromStart(Start);
         }
         AssertStartProductionExistsForStartSymbol(_reachibilityMatrix);
     }
     else if (StartSettingExists())
     {
         if (ProductionsAreEmpty())
         {
             throw new InvalidOperationException("Unable to determine start symbol. No productions exist and a start symbol was not specified.");
         }
         AssertStartProductionexistsForStartSetting(_reachibilityMatrix);
         Start = FindProduction(StartSetting.Value);
     }
     else
     {
         Start = _reachibilityMatrix.GetStartProduction();
     }
 }