예제 #1
0
 private void Init(string id, CfgRule cfgRule, int iSerialize, GrammarOptions SemanticFormat, ref int cImportedRules)
 {
     _id                = id;
     _cfgRule           = cfgRule;
     _firstState        = null;
     _cfgRule.DirtyRule = true;
     _iSerialize        = iSerialize;
     _fHasExitPath      = false;
     _fHasDynamicRef    = false;
     _fIsEpsilonRule    = false;
     _fStaticRule       = false;
     if (_cfgRule.Import)
     {
         cImportedRules++;
     }
 }
예제 #2
0
 private CfgGrammar.CfgHeader BuildRulesFromBinaryGrammar(CfgGrammar.CfgHeader header, State[] apStateTable, SortedDictionary <int, Rule> ruleFirstArcs, int previousCfgLastRules)
 {
     for (int i = 0; i < header.rules.Length; i++)
     {
         CfgRule cfgRule       = header.rules[i];
         int     firstArcIndex = (int)cfgRule.FirstArcIndex;
         cfgRule._nameOffset = _symbols.OffsetFromId(_symbols.Find(header.pszSymbols.FromOffset(cfgRule._nameOffset)));
         Rule rule = new Rule(this, _symbols.FromOffset(cfgRule._nameOffset), cfgRule, i + previousCfgLastRules, _grammarOptions & GrammarOptions.TagFormat, ref _cImportedRules);
         rule._firstState = _states.CreateNewState(rule);
         _rules.Add(rule);
         if (firstArcIndex > 0)
         {
             ruleFirstArcs.Add((int)cfgRule.FirstArcIndex, rule);
         }
         rule._fStaticRule       = ((!cfgRule.Dynamic) ? true : false);
         rule._cfgRule.DirtyRule = false;
         rule._fHasExitPath      = (rule._fStaticRule ? true : false);
         if (firstArcIndex != 0)
         {
             rule._firstState.SerializeId = (int)cfgRule.FirstArcIndex;
             apStateTable[firstArcIndex]  = rule._firstState;
         }
         if (rule._cfgRule.HasResources)
         {
             throw new NotImplementedException();
         }
         if (header.ulRootRuleIndex == i)
         {
             _rootRule = rule;
         }
         if (rule._cfgRule._nameOffset != 0)
         {
             _nameOffsetRules.Add(rule._cfgRule._nameOffset, rule);
         }
     }
     return(header);
 }
예제 #3
0
 internal Rule(Backend backend, string name, CfgRule cfgRule, int iSerialize, GrammarOptions SemanticFormat, ref int cImportedRules)
     : base(backend, null)
 {
     _rule = this;
     Init(name, cfgRule, iSerialize, SemanticFormat, ref cImportedRules);
 }