Пример #1
0
 internal void MarkAccept(NState acpt, RuleDesc rule)
 {
     acpt.accept = rule;
     acceptStates.Add(acpt.ord);
 }
Пример #2
0
 //
 // For version 1.0.1 recognize any line-end character if /unicode
 //
 static void AddAnchorContext(NfsaInstance nInst, NState endS, RuleDesc rule)
 {
     NState nEnd = nInst.MkState();
     Leaf temp = new Leaf(RegOp.charClass);
     temp.rangeLit = RangeLiteral.RightAnchors;
     nInst.MakePath(temp, endS, nEnd);
     nInst.MarkAccept(nEnd, rule);
     nEnd.rhCntx = 1;
 }
Пример #3
0
 internal void AddRule( RuleDesc rule ) {
     rules.Add( rule );
 }
Пример #4
0
 internal void AddRuleToList( RuleDesc rule ) {
     //
     // Versions before 0.4.2.* had incorrect semantics
     // for the handling of inclusive start states.
     // Correct semantics for inclusive start states:
     // If a rule has no explicit start state(s) then it
     // should be added to *every* inclusive start state.
     //
     // For version 0.5.1+ the semantics follow those of
     // FLEX, which distinguishes between rules that are
     // *explicitly* attached to INITIAL, and those which
     // have an empty start state list.  Only those without
     // a start state list are added to inclusive states.
     //
     if (rule.list == null || rule.list.Count == 0) {
         StartState.initState.AddRule( rule );       // Add to initial state
         foreach (StartState inclS in inclStates)  // Add to inclusive states
             inclS.AddRule( rule );
     }
     else if (rule.list[0].IsAll)
         AddToAllStates( rule );
     else
         foreach (StartState state in rule.list)
             state.AddRule( rule );
 }
Пример #5
0
 internal void AddToAllStates( RuleDesc rule ) {
     foreach (KeyValuePair<string, StartState> p in startStates) {
         StartState s = p.Value;
         if (!s.IsAll && !s.IsDummy)
             s.AddRule( rule );
     }
 }
Пример #6
0
 internal static RuleDesc MkDummyRuleDesc( LexCategory cat, AAST aast ) {
     RuleDesc result = new RuleDesc();
     result.pSpan = null;
     result.aSpan = aast.AtStart;
     result.isBarAction = false;
     result.isPredDummyRule = true;
     result.pattern = String.Format( CultureInfo.InvariantCulture, "{{{0}}}", cat.Name );
     result.list = new List<StartState>();
     result.ParseRE( aast );
     result.list.Add( aast.StartStateValue( cat.PredDummyName ) );
     return result;
 }