Created
April 18, 2019 23:20
-
-
Save travisdowns/62aa1999a4058e159e01af53b863f601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Output created by jacc on Sun Apr 07 22:44:19 COT 2019 | |
package travisdowns.github.io; | |
class RegexParser extends ParserBase implements RegexTokens { | |
private int yyss = 100; | |
private int yytok; | |
private int yysp = 0; | |
private int[] yyst; | |
protected int yyerrno = (-1); | |
private Object[] yysv; | |
private Object yyrv; | |
public boolean parse() { | |
int yyn = 0; | |
yysp = 0; | |
yyst = new int[yyss]; | |
yysv = new Object[yyss]; | |
yytok = (lexer.getToken() | |
); | |
loop: | |
for (;;) { | |
switch (yyn) { | |
case 0: | |
yyst[yysp] = 0; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 26: | |
switch (yytok) { | |
case CHAR: | |
yyn = 6; | |
continue; | |
case '(': | |
yyn = 7; | |
continue; | |
case '.': | |
yyn = 8; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 1: | |
yyst[yysp] = 1; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 27: | |
switch (yytok) { | |
case ENDINPUT: | |
yyn = 52; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 2: | |
yyst[yysp] = 2; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 28: | |
yyn = yys2(); | |
continue; | |
case 3: | |
yyst[yysp] = 3; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 29: | |
switch (yytok) { | |
case EOL: | |
yyn = 10; | |
continue; | |
case '|': | |
yyn = 11; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 4: | |
yyst[yysp] = 4; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 30: | |
yyn = yys4(); | |
continue; | |
case 5: | |
yyst[yysp] = 5; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 31: | |
yyn = yys5(); | |
continue; | |
case 6: | |
yyst[yysp] = 6; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 32: | |
switch (yytok) { | |
case error: | |
case ENDINPUT: | |
case ':': | |
yyn = 55; | |
continue; | |
} | |
yyn = yyr16(); | |
continue; | |
case 7: | |
yyst[yysp] = 7; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 33: | |
switch (yytok) { | |
case '?': | |
yyn = 16; | |
continue; | |
case '.': | |
case '(': | |
case CHAR: | |
yyn = yyr13(); | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 8: | |
yyst[yysp] = 8; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 34: | |
switch (yytok) { | |
case error: | |
case ENDINPUT: | |
case ':': | |
yyn = 55; | |
continue; | |
} | |
yyn = yyr17(); | |
continue; | |
case 9: | |
yyst[yysp] = 9; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 35: | |
yyn = yys9(); | |
continue; | |
case 10: | |
yyst[yysp] = 10; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 36: | |
switch (yytok) { | |
case ENDINPUT: | |
yyn = yyr1(); | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 11: | |
yyst[yysp] = 11; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 37: | |
switch (yytok) { | |
case CHAR: | |
yyn = 6; | |
continue; | |
case '(': | |
yyn = 7; | |
continue; | |
case '.': | |
yyn = 8; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 12: | |
yyst[yysp] = 12; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 38: | |
yyn = yys12(); | |
continue; | |
case 13: | |
yyst[yysp] = 13; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 39: | |
yyn = yys13(); | |
continue; | |
case 14: | |
yyst[yysp] = 14; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 40: | |
yyn = yys14(); | |
continue; | |
case 15: | |
yyst[yysp] = 15; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 41: | |
switch (yytok) { | |
case CHAR: | |
yyn = 6; | |
continue; | |
case '(': | |
yyn = 7; | |
continue; | |
case '.': | |
yyn = 8; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 16: | |
yyst[yysp] = 16; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 42: | |
switch (yytok) { | |
case ':': | |
yyn = 22; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 17: | |
yyst[yysp] = 17; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 43: | |
yyn = yys17(); | |
continue; | |
case 18: | |
yyst[yysp] = 18; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 44: | |
yyn = yys18(); | |
continue; | |
case 19: | |
yyst[yysp] = 19; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 45: | |
yyn = yys19(); | |
continue; | |
case 20: | |
yyst[yysp] = 20; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 46: | |
yyn = yys20(); | |
continue; | |
case 21: | |
yyst[yysp] = 21; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 47: | |
switch (yytok) { | |
case '|': | |
yyn = 11; | |
continue; | |
case ')': | |
yyn = 23; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 22: | |
yyst[yysp] = 22; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 48: | |
switch (yytok) { | |
case CHAR: | |
yyn = 6; | |
continue; | |
case '(': | |
yyn = 7; | |
continue; | |
case '.': | |
yyn = 8; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 23: | |
yyst[yysp] = 23; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 49: | |
switch (yytok) { | |
case error: | |
case ENDINPUT: | |
case ':': | |
yyn = 55; | |
continue; | |
} | |
yyn = yyr14(); | |
continue; | |
case 24: | |
yyst[yysp] = 24; | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 50: | |
switch (yytok) { | |
case '|': | |
yyn = 11; | |
continue; | |
case ')': | |
yyn = 25; | |
continue; | |
} | |
yyn = 55; | |
continue; | |
case 25: | |
yyst[yysp] = 25; | |
yysv[yysp] = (lexer.getSemantic() | |
); | |
yytok = (lexer.nextToken() | |
); | |
if (++yysp>=yyst.length) { | |
yyexpand(); | |
} | |
case 51: | |
switch (yytok) { | |
case error: | |
case ENDINPUT: | |
case ':': | |
yyn = 55; | |
continue; | |
} | |
yyn = yyr15(); | |
continue; | |
case 52: | |
return true; | |
case 53: | |
yyerror("stack overflow"); | |
case 54: | |
return false; | |
case 55: | |
yyerror("syntax error"); | |
return false; | |
} | |
} | |
} | |
protected void yyexpand() { | |
int[] newyyst = new int[2*yyst.length]; | |
Object[] newyysv = new Object[2*yyst.length]; | |
for (int i=0; i<yyst.length; i++) { | |
newyyst[i] = yyst[i]; | |
newyysv[i] = yysv[i]; | |
} | |
yyst = newyyst; | |
yysv = newyysv; | |
} | |
private int yys2() { | |
switch (yytok) { | |
case CHAR: | |
return 6; | |
case '(': | |
return 7; | |
case '.': | |
return 8; | |
case '|': | |
case ')': | |
case EOL: | |
return yyr2(); | |
} | |
return 55; | |
} | |
private int yys4() { | |
switch (yytok) { | |
case ')': | |
case '.': | |
case '(': | |
case '|': | |
case EOL: | |
case CHAR: | |
return yyr4(); | |
} | |
return 55; | |
} | |
private int yys5() { | |
switch (yytok) { | |
case error: | |
case ':': | |
case ENDINPUT: | |
return 55; | |
case '*': | |
return 12; | |
case '+': | |
return 13; | |
case '?': | |
return 14; | |
} | |
return yyr6(); | |
} | |
private int yys9() { | |
switch (yytok) { | |
case ')': | |
case '.': | |
case '(': | |
case '|': | |
case EOL: | |
case CHAR: | |
return yyr5(); | |
} | |
return 55; | |
} | |
private int yys12() { | |
switch (yytok) { | |
case '+': | |
case error: | |
case ENDINPUT: | |
case ':': | |
case '*': | |
return 55; | |
case '?': | |
return 18; | |
} | |
return yyr7(); | |
} | |
private int yys13() { | |
switch (yytok) { | |
case '+': | |
case error: | |
case ENDINPUT: | |
case ':': | |
case '*': | |
return 55; | |
case '?': | |
return 19; | |
} | |
return yyr9(); | |
} | |
private int yys14() { | |
switch (yytok) { | |
case '+': | |
case error: | |
case ENDINPUT: | |
case ':': | |
case '*': | |
return 55; | |
case '?': | |
return 20; | |
} | |
return yyr11(); | |
} | |
private int yys17() { | |
switch (yytok) { | |
case CHAR: | |
return 6; | |
case '(': | |
return 7; | |
case '.': | |
return 8; | |
case '|': | |
case ')': | |
case EOL: | |
return yyr3(); | |
} | |
return 55; | |
} | |
private int yys18() { | |
switch (yytok) { | |
case ')': | |
case '.': | |
case '(': | |
case '|': | |
case EOL: | |
case CHAR: | |
return yyr8(); | |
} | |
return 55; | |
} | |
private int yys19() { | |
switch (yytok) { | |
case ')': | |
case '.': | |
case '(': | |
case '|': | |
case EOL: | |
case CHAR: | |
return yyr10(); | |
} | |
return 55; | |
} | |
private int yys20() { | |
switch (yytok) { | |
case ')': | |
case '.': | |
case '(': | |
case '|': | |
case EOL: | |
case CHAR: | |
return yyr12(); | |
} | |
return 55; | |
} | |
private int yyr1() { // line : alt EOL | |
{ | |
State *s; | |
((Frag)yysv[yysp-2]) = paren(((Frag)yysv[yysp-2]), 0); | |
s = state(Match, 0, NULL, NULL); | |
patch(((Frag)yysv[yysp-2]).out, s); | |
start = ((Frag)yysv[yysp-2]).start; | |
return 0; | |
} | |
yysv[yysp-=2] = yyrv; | |
return 1; | |
} | |
private int yyr4() { // concat : repeat | |
yysp -= 1; | |
return yypconcat(); | |
} | |
private int yyr5() { // concat : concat repeat | |
{ | |
patch(((Frag)yysv[yysp-2]).out, ((Frag)yysv[yysp-1]).start); | |
yyrv = frag(((Frag)yysv[yysp-2]).start, ((Frag)yysv[yysp-1]).out); | |
} | |
yysv[yysp-=2] = yyrv; | |
return yypconcat(); | |
} | |
private int yypconcat() { | |
switch (yyst[yysp-1]) { | |
case 11: return 17; | |
default: return 2; | |
} | |
} | |
private int yyr13() { // count : /* empty */ | |
{ yyrv = ++nparen; } | |
yysv[yysp-=0] = yyrv; | |
return 15; | |
} | |
private int yyr2() { // alt : concat | |
yysp -= 1; | |
return yypalt(); | |
} | |
private int yyr3() { // alt : alt '|' concat | |
{ | |
State *s = state(Split, 0, ((Frag)yysv[yysp-3]).start, ((Frag)yysv[yysp-1]).start); | |
yyrv = frag(s, append(((Frag)yysv[yysp-3]).out, ((Frag)yysv[yysp-1]).out)); | |
} | |
yysv[yysp-=3] = yyrv; | |
return yypalt(); | |
} | |
private int yypalt() { | |
switch (yyst[yysp-1]) { | |
case 15: return 21; | |
case 0: return 3; | |
default: return 24; | |
} | |
} | |
private int yyr6() { // repeat : single | |
yysp -= 1; | |
return yyprepeat(); | |
} | |
private int yyr7() { // repeat : single '*' | |
{ | |
State *s = state(Split, 0, ((Frag)yysv[yysp-2]).start, NULL); | |
patch(((Frag)yysv[yysp-2]).out, s); | |
yyrv = frag(s, list1(&s->out1)); | |
} | |
yysv[yysp-=2] = yyrv; | |
return yyprepeat(); | |
} | |
private int yyr8() { // repeat : single '*' '?' | |
{ | |
State *s = state(Split, 0, NULL, ((Frag)yysv[yysp-3]).start); | |
patch(((Frag)yysv[yysp-3]).out, s); | |
yyrv = frag(s, list1(&s->out)); | |
} | |
yysv[yysp-=3] = yyrv; | |
return yyprepeat(); | |
} | |
private int yyr9() { // repeat : single '+' | |
{ | |
State *s = state(Split, 0, ((Frag)yysv[yysp-2]).start, NULL); | |
patch(((Frag)yysv[yysp-2]).out, s); | |
yyrv = frag(((Frag)yysv[yysp-2]).start, list1(&s->out1)); | |
} | |
yysv[yysp-=2] = yyrv; | |
return yyprepeat(); | |
} | |
private int yyr10() { // repeat : single '+' '?' | |
{ | |
State *s = state(Split, 0, NULL, ((Frag)yysv[yysp-3]).start); | |
patch(((Frag)yysv[yysp-3]).out, s); | |
yyrv = frag(((Frag)yysv[yysp-3]).start, list1(&s->out)); | |
} | |
yysv[yysp-=3] = yyrv; | |
return yyprepeat(); | |
} | |
private int yyr11() { // repeat : single '?' | |
{ | |
State *s = state(Split, 0, ((Frag)yysv[yysp-2]).start, NULL); | |
yyrv = frag(s, append(((Frag)yysv[yysp-2]).out, list1(&s->out1))); | |
} | |
yysv[yysp-=2] = yyrv; | |
return yyprepeat(); | |
} | |
private int yyr12() { // repeat : single '?' '?' | |
{ | |
State *s = state(Split, 0, NULL, ((Frag)yysv[yysp-3]).start); | |
yyrv = frag(s, append(((Frag)yysv[yysp-3]).out, list1(&s->out))); | |
} | |
yysv[yysp-=3] = yyrv; | |
return yyprepeat(); | |
} | |
private int yyprepeat() { | |
switch (yyst[yysp-1]) { | |
case 17: return 9; | |
case 2: return 9; | |
default: return 4; | |
} | |
} | |
private int yyr14() { // single : '(' count alt ')' | |
{ | |
yyrv = paren(((Frag)yysv[yysp-2]), ((Integer)yysv[yysp-3])); | |
} | |
yysv[yysp-=4] = yyrv; | |
return 5; | |
} | |
private int yyr15() { // single : '(' '?' ':' alt ')' | |
{ | |
yyrv = ((Frag)yysv[yysp-2]); | |
} | |
yysv[yysp-=5] = yyrv; | |
return 5; | |
} | |
private int yyr16() { // single : CHAR | |
{ | |
State *s = state(Char, ((Character)yysv[yysp-1]), NULL, NULL); | |
yyrv = frag(s, list1(&s->out)); | |
} | |
yysv[yysp-=1] = yyrv; | |
return 5; | |
} | |
private int yyr17() { // single : '.' | |
{ | |
State *s = state(Any, 0, NULL, NULL); | |
yyrv = frag(s, list1(&s->out)); | |
} | |
yysv[yysp-=1] = yyrv; | |
return 5; | |
} | |
protected String[] yyerrmsgs = { | |
}; | |
RegexParser(String input) { super(input); } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment