示例#1
0
 public LookaheadSet LOOK(NFAState s) {
   if (NFAToDFAConverter.debug) {
     System.out.println("> LOOK(" + s + ")");
   }
   lookBusy.clear();
   LookaheadSet look = _FIRST(s, true);
   // FOLLOW makes no sense (at the moment!) for lexical rules.
   if (grammar.type != Grammar.LEXER && look.member(Label.EOR_TOKEN_TYPE)) {
     // avoid altering FIRST reset as it is cached
     LookaheadSet f = FOLLOW(s.enclosingRule);
     f.orInPlace(look);
     f.remove(Label.EOR_TOKEN_TYPE);
     look = f;
     // look.orInPlace(FOLLOW(s.enclosingRule));
   } else if (grammar.type == Grammar.LEXER && look.member(Label.EOT)) {
     // if this has EOT, lookahead is all char (all char can follow rule)
     // look = new LookaheadSet(Label.EOT);
     look = new LookaheadSet(IntervalSet.COMPLETE_SET);
   }
   if (NFAToDFAConverter.debug) {
     System.out.println("< LOOK(" + s + ")=" + look.toString(grammar));
   }
   return look;
 }