/** From A B build A-e->B (that is, build an epsilon arc from right * of A to left of B). * * As a convenience, return B if A is null or return A if B is null. */ public StateCluster build_AB(StateCluster A, StateCluster B) { if ( A==null ) { return B; } if ( B==null ) { return A; } transitionBetweenStates(A.right, B.left, Label.EPSILON); StateCluster g = new StateCluster(A.left, B.right); return g; }
/** From A B build A-e->B (that is, build an epsilon arc from right * of A to left of B). * * As a convenience, return B if A is null or return A if B is null. */ public StateCluster build_AB(StateCluster A, StateCluster B) { if ( A==null ) { return B; } if ( B==null ) { return A; } transitionBetweenStates(A.right, B.left, Label.EPSILON); StateCluster g = new StateCluster(A.left, B.right); return g; }
/** From A B build A-e->B (that is, build an epsilon arc from right * of A to left of B). * * As a convenience, return B if A is null or return A if B is null. */ public StateCluster build_AB(StateCluster A, StateCluster B) { if ( A==null ) { return B; } if ( B==null ) { return A; } transitionBetweenStates(A.right, B.left, Label.EPSILON); StateCluster g = new StateCluster(A.left, B.right); return g; }
/** From A B build A-e->B (that is, build an epsilon arc from right * of A to left of B). * * As a convenience, return B if A is null or return A if B is null. */ public StateCluster build_AB(StateCluster A, StateCluster B) { if ( A==null ) { return B; } if ( B==null ) { return A; } transitionBetweenStates(A.right, B.left, Label.EPSILON); StateCluster g = new StateCluster(A.left, B.right); return g; }
/** From a set ('a'|'b') build * * o->o-'a'..'b'->o->o (last NFAState is blockEndNFAState pointed to by all alts) */ public StateCluster build_AlternativeBlockFromSet(StateCluster set) { if ( set==null ) { return null; } // single alt, no decision, just return only alt state cluster NFAState startOfAlt = newState(); // must have this no matter what transitionBetweenStates(startOfAlt, set.left, Label.EPSILON); return new StateCluster(startOfAlt,set.right); }
/** From a set ('a'|'b') build * * o->o-'a'..'b'->o->o (last NFAState is blockEndNFAState pointed to by all alts) */ public StateCluster build_AlternativeBlockFromSet(StateCluster set) { if ( set==null ) { return null; } // single alt, no decision, just return only alt state cluster NFAState startOfAlt = newState(); // must have this no matter what transitionBetweenStates(startOfAlt, set.left, Label.EPSILON); return new StateCluster(startOfAlt,set.right); }
/** From a set ('a'|'b') build * * o->o-'a'..'b'->o->o (last NFAState is blockEndNFAState pointed to by all alts) */ public StateCluster build_AlternativeBlockFromSet(StateCluster set) { if ( set==null ) { return null; } // single alt, no decision, just return only alt state cluster NFAState startOfAlt = newState(); // must have this no matter what transitionBetweenStates(startOfAlt, set.left, Label.EPSILON); return new StateCluster(startOfAlt,set.right); }
/** From a set ('a'|'b') build * * o->o-'a'..'b'->o->o (last NFAState is blockEndNFAState pointed to by all alts) */ public StateCluster build_AlternativeBlockFromSet(StateCluster set) { if ( set==null ) { return null; } // single alt, no decision, just return only alt state cluster NFAState startOfAlt = newState(); // must have this no matter what transitionBetweenStates(startOfAlt, set.left, Label.EPSILON); return new StateCluster(startOfAlt,set.right); }
/** From label A build Graph o-A->o */ public StateCluster build_Atom(int label, GrammarAST associatedAST) { NFAState left = newState(); NFAState right = newState(); left.associatedASTNode = associatedAST; right.associatedASTNode = associatedAST; transitionBetweenStates(left, right, label); StateCluster g = new StateCluster(left, right); return g; }
/** From label A build Graph o-A->o */ public StateCluster build_Atom(int label, GrammarAST associatedAST) { NFAState left = newState(); NFAState right = newState(); left.associatedASTNode = associatedAST; right.associatedASTNode = associatedAST; transitionBetweenStates(left, right, label); StateCluster g = new StateCluster(left, right); return g; }
/** From label A build Graph o-A->o */ public StateCluster build_Atom(int label, GrammarAST associatedAST) { NFAState left = newState(); NFAState right = newState(); left.associatedASTNode = associatedAST; right.associatedASTNode = associatedAST; transitionBetweenStates(left, right, label); StateCluster g = new StateCluster(left, right); return g; }
/** From an empty alternative build StateCluster o-e->o */ public StateCluster build_Epsilon() { NFAState left = newState(); NFAState right = newState(); transitionBetweenStates(left, right, Label.EPSILON); StateCluster g = new StateCluster(left, right); return g; }
/** From an empty alternative build StateCluster o-e->o */ public StateCluster build_Epsilon() { NFAState left = newState(); NFAState right = newState(); transitionBetweenStates(left, right, Label.EPSILON); StateCluster g = new StateCluster(left, right); return g; }
/** From an empty alternative build StateCluster o-e->o */ public StateCluster build_Epsilon() { NFAState left = newState(); NFAState right = newState(); transitionBetweenStates(left, right, Label.EPSILON); StateCluster g = new StateCluster(left, right); return g; }
/** From an empty alternative build StateCluster o-e->o */ public StateCluster build_Epsilon() { NFAState left = newState(); NFAState right = newState(); transitionBetweenStates(left, right, Label.EPSILON); StateCluster g = new StateCluster(left, right); return g; }
/** From label A build Graph o-A->o */ public StateCluster build_Atom(int label, GrammarAST associatedAST) { NFAState left = newState(); NFAState right = newState(); left.associatedASTNode = associatedAST; right.associatedASTNode = associatedAST; transitionBetweenStates(left, right, label); StateCluster g = new StateCluster(left, right); return g; }
/** For a non-lexer, just build a simple token reference atom. * For a lexer, a string is a sequence of char to match. That is, * "fog" is treated as 'f' 'o' 'g' not as a single transition in * the DFA. Machine== o-'f'->o-'o'->o-'g'->o and has n+1 states * for n characters. */ public StateCluster build_StringLiteralAtom(GrammarAST stringLiteralAST) { if ( nfa.grammar.type==Grammar.LEXER ) { StringBuffer chars = Grammar.getUnescapedStringFromGrammarStringLiteral(stringLiteralAST.getText()); NFAState first = newState(); NFAState last = null; NFAState prev = first; for (int i=0; i<chars.length(); i++) { int c = chars.charAt(i); NFAState next = newState(); transitionBetweenStates(prev, next, c); prev = last = next; } return new StateCluster(first, last); } // a simple token reference in non-Lexers int tokenType = nfa.grammar.getTokenType(stringLiteralAST.getText()); return build_Atom(tokenType, stringLiteralAST); }
/** For a non-lexer, just build a simple token reference atom. * For a lexer, a string is a sequence of char to match. That is, * "fog" is treated as 'f' 'o' 'g' not as a single transition in * the DFA. Machine== o-'f'->o-'o'->o-'g'->o and has n+1 states * for n characters. */ public StateCluster build_StringLiteralAtom(GrammarAST stringLiteralAST) { if ( nfa.grammar.type==Grammar.LEXER ) { StringBuffer chars = Grammar.getUnescapedStringFromGrammarStringLiteral(stringLiteralAST.getText()); NFAState first = newState(); NFAState last = null; NFAState prev = first; for (int i=0; i<chars.length(); i++) { int c = chars.charAt(i); NFAState next = newState(); transitionBetweenStates(prev, next, c); prev = last = next; } return new StateCluster(first, last); } // a simple token reference in non-Lexers int tokenType = nfa.grammar.getTokenType(stringLiteralAST.getText()); return build_Atom(tokenType, stringLiteralAST); }
/** For a non-lexer, just build a simple token reference atom. * For a lexer, a string is a sequence of char to match. That is, * "fog" is treated as 'f' 'o' 'g' not as a single transition in * the DFA. Machine== o-'f'->o-'o'->o-'g'->o and has n+1 states * for n characters. */ public StateCluster build_StringLiteralAtom(GrammarAST stringLiteralAST) { if ( nfa.grammar.type==Grammar.LEXER ) { StringBuffer chars = Grammar.getUnescapedStringFromGrammarStringLiteral(stringLiteralAST.getText()); NFAState first = newState(); NFAState last = null; NFAState prev = first; for (int i=0; i<chars.length(); i++) { int c = chars.charAt(i); NFAState next = newState(); transitionBetweenStates(prev, next, c); prev = last = next; } return new StateCluster(first, last); } // a simple token reference in non-Lexers int tokenType = nfa.grammar.getTokenType(stringLiteralAST.getText()); return build_Atom(tokenType, stringLiteralAST); }
/** For a non-lexer, just build a simple token reference atom. * For a lexer, a string is a sequence of char to match. That is, * "fog" is treated as 'f' 'o' 'g' not as a single transition in * the DFA. Machine== o-'f'->o-'o'->o-'g'->o and has n+1 states * for n characters. */ public StateCluster build_StringLiteralAtom(GrammarAST stringLiteralAST) { if ( nfa.grammar.type==Grammar.LEXER ) { StringBuffer chars = Grammar.getUnescapedStringFromGrammarStringLiteral(stringLiteralAST.getText()); NFAState first = newState(); NFAState last = null; NFAState prev = first; for (int i=0; i<chars.length(); i++) { int c = chars.charAt(i); NFAState next = newState(); transitionBetweenStates(prev, next, c); prev = last = next; } return new StateCluster(first, last); } // a simple token reference in non-Lexers int tokenType = nfa.grammar.getTokenType(stringLiteralAST.getText()); return build_Atom(tokenType, stringLiteralAST); }