/** For reference to rule r, build * * o-e->(r) o * * where (r) is the start of rule r and the trailing o is not linked * to from rule ref state directly (it's done thru the transition(0) * RuleClosureTransition. * * If the rule r is just a list of tokens, it's block will be just * a set on an edge o->o->o-set->o->o->o, could inline it rather than doing * the rule reference, but i'm not doing this yet as I'm not sure * it would help much in the NFA→DFA construction. * * TODO add to codegen: collapse alt blks that are sets into single matchSet */ public StateCluster build_RuleRef(Rule refDef, NFAState ruleStart) { //System.out.println("building ref to rule "+nfa.grammar.name+"."+refDef.name); NFAState left = newState(); // left.setDescription("ref to "+ruleStart.getDescription()); NFAState right = newState(); // right.setDescription("NFAState following ref to "+ruleStart.getDescription()); Transition e = new RuleClosureTransition(refDef,ruleStart,right); left.addTransition(e); StateCluster g = new StateCluster(left, right); return g; }
/** For reference to rule r, build * * o-e->(r) o * * where (r) is the start of rule r and the trailing o is not linked * to from rule ref state directly (it's done thru the transition(0) * RuleClosureTransition. * * If the rule r is just a list of tokens, it's block will be just * a set on an edge o->o->o-set->o->o->o, could inline it rather than doing * the rule reference, but i'm not doing this yet as I'm not sure * it would help much in the NFA->DFA construction. * * TODO add to codegen: collapse alt blks that are sets into single matchSet */ public StateCluster build_RuleRef(Rule refDef, NFAState ruleStart) { //System.out.println("building ref to rule "+nfa.grammar.name+"."+refDef.name); NFAState left = newState(); // left.setDescription("ref to "+ruleStart.getDescription()); NFAState right = newState(); // right.setDescription("NFAState following ref to "+ruleStart.getDescription()); Transition e = new RuleClosureTransition(refDef,ruleStart,right); left.addTransition(e); StateCluster g = new StateCluster(left, right); return g; }
/** For reference to rule r, build * * o-e->(r) o * * where (r) is the start of rule r and the trailing o is not linked * to from rule ref state directly (it's done thru the transition(0) * RuleClosureTransition. * * If the rule r is just a list of tokens, it's block will be just * a set on an edge o->o->o-set->o->o->o, could inline it rather than doing * the rule reference, but i'm not doing this yet as I'm not sure * it would help much in the NFA→DFA construction. * * TODO add to codegen: collapse alt blks that are sets into single matchSet */ public StateCluster build_RuleRef(Rule refDef, NFAState ruleStart) { //System.out.println("building ref to rule "+nfa.grammar.name+"."+refDef.name); NFAState left = newState(); // left.setDescription("ref to "+ruleStart.getDescription()); NFAState right = newState(); // right.setDescription("NFAState following ref to "+ruleStart.getDescription()); Transition e = new RuleClosureTransition(refDef,ruleStart,right); left.addTransition(e); StateCluster g = new StateCluster(left, right); return g; }
/** For reference to rule r, build * * o-e->(r) o * * where (r) is the start of rule r and the trailing o is not linked * to from rule ref state directly (it's done thru the transition(0) * RuleClosureTransition. * * If the rule r is just a list of tokens, it's block will be just * a set on an edge o->o->o-set->o->o->o, could inline it rather than doing * the rule reference, but i'm not doing this yet as I'm not sure * it would help much in the NFA->DFA construction. * * TODO add to codegen: collapse alt blks that are sets into single matchSet */ public StateCluster build_RuleRef(Rule refDef, NFAState ruleStart) { //System.out.println("building ref to rule "+nfa.grammar.name+"."+refDef.name); NFAState left = newState(); // left.setDescription("ref to "+ruleStart.getDescription()); NFAState right = newState(); // right.setDescription("NFAState following ref to "+ruleStart.getDescription()); Transition e = new RuleClosureTransition(refDef,ruleStart,right); left.addTransition(e); StateCluster g = new StateCluster(left, right); return g; }