public LookaheadSet FOLLOW(Rule r) { //System.out.println("> FOLLOW("+r.name+") in rule "+r.startState.enclosingRule); LookaheadSet f = FOLLOWCache.get(r); if ( f!=null ) { return f; } f = _FIRST(r.stopState, true); FOLLOWCache.put(r, f); //System.out.println("< FOLLOW("+r+") in rule "+r.startState.enclosingRule+"="+f.toString(this.grammar)); return f; }
public LookaheadSet FOLLOW(Rule r) { //System.out.println("> FOLLOW("+r.name+") in rule "+r.startState.enclosingRule); LookaheadSet f = FOLLOWCache.get(r); if ( f!=null ) { return f; } f = _FIRST(r.stopState, true); FOLLOWCache.put(r, f); //System.out.println("< FOLLOW("+r+") in rule "+r.startState.enclosingRule+"="+f.toString(this.grammar)); return f; }
public LookaheadSet FOLLOW(Rule r) { //System.out.println("> FOLLOW("+r.name+") in rule "+r.startState.enclosingRule); LookaheadSet f = FOLLOWCache.get(r); if ( f!=null ) { return f; } f = _FIRST(r.stopState, true); FOLLOWCache.put(r, f); //System.out.println("< FOLLOW("+r+") in rule "+r.startState.enclosingRule+"="+f.toString(this.grammar)); return f; }
public LookaheadSet FOLLOW(Rule r) { //System.out.println("> FOLLOW("+r.name+") in rule "+r.startState.enclosingRule); LookaheadSet f = FOLLOWCache.get(r); if ( f!=null ) { return f; } f = _FIRST(r.stopState, true); FOLLOWCache.put(r, f); //System.out.println("< FOLLOW("+r+") in rule "+r.startState.enclosingRule+"="+f.toString(this.grammar)); return f; }
/** From an NFA state, s, find the set of all labels reachable from s. * Used to compute follow sets for error recovery. Never computes * a FOLLOW operation. FIRST stops at end of rules, returning EOR, unless * invoked from another rule. I.e., routine properly handles * * a : b A ; * * where b is nullable. * * We record with EOR_TOKEN_TYPE if we hit the end of a rule so we can * know at runtime (when these sets are used) to start walking up the * follow chain to compute the real, correct follow set (as opposed to * the FOLLOW, which is a superset). * * This routine will only be used on parser and tree parser grammars. */ public LookaheadSet FIRST(NFAState s) { //System.out.println("> FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule); lookBusy.clear(); LookaheadSet look = _FIRST(s, false); //System.out.println("< FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule+"="+look.toString(this.grammar)); return look; }
/** From an NFA state, s, find the set of all labels reachable from s. * Used to compute follow sets for error recovery. Never computes * a FOLLOW operation. FIRST stops at end of rules, returning EOR, unless * invoked from another rule. I.e., routine properly handles * * a : b A ; * * where b is nullable. * * We record with EOR_TOKEN_TYPE if we hit the end of a rule so we can * know at runtime (when these sets are used) to start walking up the * follow chain to compute the real, correct follow set (as opposed to * the FOLLOW, which is a superset). * * This routine will only be used on parser and tree parser grammars. */ public LookaheadSet FIRST(NFAState s) { //System.out.println("> FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule); lookBusy.clear(); LookaheadSet look = _FIRST(s, false); //System.out.println("< FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule+"="+look.toString(this.grammar)); return look; }
/** From an NFA state, s, find the set of all labels reachable from s. * Used to compute follow sets for error recovery. Never computes * a FOLLOW operation. FIRST stops at end of rules, returning EOR, unless * invoked from another rule. I.e., routine properly handles * * a : b A ; * * where b is nullable. * * We record with EOR_TOKEN_TYPE if we hit the end of a rule so we can * know at runtime (when these sets are used) to start walking up the * follow chain to compute the real, correct follow set (as opposed to * the FOLLOW, which is a superset). * * This routine will only be used on parser and tree parser grammars. */ public LookaheadSet FIRST(NFAState s) { //System.out.println("> FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule); lookBusy.clear(); LookaheadSet look = _FIRST(s, false); //System.out.println("< FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule+"="+look.toString(this.grammar)); return look; }
/** From an NFA state, s, find the set of all labels reachable from s. * Used to compute follow sets for error recovery. Never computes * a FOLLOW operation. FIRST stops at end of rules, returning EOR, unless * invoked from another rule. I.e., routine properly handles * * a : b A ; * * where b is nullable. * * We record with EOR_TOKEN_TYPE if we hit the end of a rule so we can * know at runtime (when these sets are used) to start walking up the * follow chain to compute the real, correct follow set (as opposed to * the FOLLOW, which is a superset). * * This routine will only be used on parser and tree parser grammars. */ public LookaheadSet FIRST(NFAState s) { //System.out.println("> FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule); lookBusy.clear(); LookaheadSet look = _FIRST(s, false); //System.out.println("< FIRST("+s.enclosingRule.name+") in rule "+s.enclosingRule+"="+look.toString(this.grammar)); return look; }
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; }
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; }
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; }
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; }