return; nfa = new NFA(this); factory = new NFAFactory(nfa);
return; nfa = new NFA(this); factory = new NFAFactory(nfa);
/** Define all the rule begin/end NFAStates to solve forward reference * issues. Critical for composite grammars too. * This is normally called on all root/delegates manually and then * buildNFA() is called afterwards because the NFA construction needs * to see rule start/stop states from potentially every grammar. Has * to be have these created a priori. Testing routines will often * just call buildNFA(), which forces a call to this method if not * done already. Works ONLY for single noncomposite grammars. */ public void createRuleStartAndStopNFAStates() { //System.out.println("### createRuleStartAndStopNFAStates "+getGrammarTypeString()+" grammar "+name+" NFAs"); if ( nfa!=null ) { return; } nfa = new NFA(this); factory = new NFAFactory(nfa); Collection<Rule> rules = getRules(); for (Rule r : rules) { String ruleName = r.name; NFAState ruleBeginState = factory.newState(); ruleBeginState.setDescription("rule "+ruleName+" start"); ruleBeginState.enclosingRule = r; r.startState = ruleBeginState; NFAState ruleEndState = factory.newState(); ruleEndState.setDescription("rule "+ruleName+" end"); ruleEndState.setAcceptState(true); ruleEndState.enclosingRule = r; r.stopState = ruleEndState; } }
/** Define all the rule begin/end NFAStates to solve forward reference * issues. Critical for composite grammars too. * This is normally called on all root/delegates manually and then * buildNFA() is called afterwards because the NFA construction needs * to see rule start/stop states from potentially every grammar. Has * to be have these created a priori. Testing routines will often * just call buildNFA(), which forces a call to this method if not * done already. Works ONLY for single noncomposite grammars. */ public void createRuleStartAndStopNFAStates() { //System.out.println("### createRuleStartAndStopNFAStates "+getGrammarTypeString()+" grammar "+name+" NFAs"); if ( nfa!=null ) { return; } nfa = new NFA(this); factory = new NFAFactory(nfa); Collection<Rule> rules = getRules(); for (Rule r : rules) { String ruleName = r.name; NFAState ruleBeginState = factory.newState(); ruleBeginState.setDescription("rule "+ruleName+" start"); ruleBeginState.enclosingRule = r; r.startState = ruleBeginState; NFAState ruleEndState = factory.newState(); ruleEndState.setDescription("rule "+ruleName+" end"); ruleEndState.setAcceptState(true); ruleEndState.enclosingRule = r; r.stopState = ruleEndState; } }