[03 - JFlex Scanner] Get TestASScanner1 to work

This commit is contained in:
2020-04-29 10:17:50 +02:00
parent 89ee1e1beb
commit 4cd6257831
20 changed files with 951 additions and 80 deletions

View File

@@ -28,11 +28,12 @@ public final class JFlexASScanner {
/** lexical states */
public static final int YYINITIAL = 0;
public static final int NUM = 2;
public static final int FRAC = 4;
public static final int EXP = 6;
public static final int STR = 8;
public static final int NULL = 10;
public static final int FRAC = 2;
public static final int EXP = 4;
public static final int STR = 6;
public static final int NULL = 8;
public static final int ID = 10;
public static final int NUM = 12;
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
@@ -41,7 +42,7 @@ public final class JFlexASScanner {
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3
};
/**
@@ -63,11 +64,11 @@ public final class JFlexASScanner {
private static final int [] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
"\2\0\1\1\1\2\1\3\1\4\1\3\1\5\1\6"+
"\1\7\2\3\1\10";
"\4\0\1\1\1\2\1\3\1\4\1\3\1\5\1\6"+
"\1\7\1\10\1\11\1\12\1\13\1\14\2\0\1\15";
private static int [] zzUnpackAction() {
int [] result = new int[13];
int [] result = new int[20];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -92,11 +93,12 @@ public final class JFlexASScanner {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\12\0\12\0\24\0\36\0\50\0\62\0\12"+
"\0\12\0\12\0\74\0\106\0\36";
"\0\0\0\12\0\24\0\36\0\12\0\50\0\12\0\12"+
"\0\62\0\12\0\12\0\12\0\12\0\12\0\12\0\12"+
"\0\12\0\74\0\106\0\12";
private static int [] zzUnpackRowMap() {
int [] result = new int[13];
int [] result = new int[20];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -119,10 +121,10 @@ public final class JFlexASScanner {
private static final int [] ZZ_TRANS = zzUnpackTrans();
private static final String ZZ_TRANS_PACKED_0 =
"\1\3\1\4\1\5\1\6\1\7\2\5\1\10\1\11"+
"\1\12\13\0\1\4\12\0\5\5\5\0\1\5\1\6"+
"\3\5\5\0\3\5\1\13\1\5\5\0\4\5\1\14"+
"\5\0\4\5\1\15\3\0";
"\1\5\1\6\1\7\1\10\1\11\2\7\1\12\1\13"+
"\1\14\12\0\2\15\5\16\3\15\2\17\1\20\1\21"+
"\3\20\3\17\1\0\1\6\15\0\1\22\12\0\1\23"+
"\11\0\1\24\3\0";
private static int [] zzUnpackTrans() {
int [] result = new int[80];
@@ -163,10 +165,11 @@ public final class JFlexASScanner {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\1\0\1\10\1\11\4\1\3\11\3\1";
"\1\0\1\10\2\0\1\11\1\1\2\11\1\1\10\11"+
"\2\0\1\11";
private static int [] zzUnpackAttribute() {
int [] result = new int[13];
int [] result = new int[20];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -242,6 +245,8 @@ public final class JFlexASScanner {
private int zzFinalHighSurrogate = 0;
/* user code: */
String idValue = "";
int intValue = 0;
/**
@@ -616,37 +621,64 @@ public final class JFlexASScanner {
else {
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 1:
{ throw new Error("Illegal character <" + yytext() + ">");
{ System.out.println("Illegal character <" + yytext() + ">");
return new Token(Token.INVALID, yytext(), yyline+1, yycolumn+1);
}
case 9: break;
case 14: break;
case 2:
{ /* Ignore */
}
case 10: break;
case 15: break;
case 3:
{ return new Token(Token.ID, yytext(), yyline+1, yycolumn+1);
{ yybegin(ID); System.out.println("BEGIN ID <"+yytext()+">");
idValue = yytext();
}
case 11: break;
case 16: break;
case 4:
{ return new Token(Token.NUM, yytext(), yyline+1, yycolumn+1);
{ yybegin(NUM);
intValue = yycharat(0)-'0'; System.out.println("BEGIN INT <"+intValue+">");
}
case 12: break;
case 17: break;
case 5:
{ return new Token(Token.LSBR, yytext(), yyline+1, yycolumn+1);
}
case 13: break;
case 18: break;
case 6:
{ return new Token(Token.RSBR, yytext(), yyline+1, yycolumn+1);
}
case 14: break;
case 19: break;
case 7:
{ return new Token(Token.COMMA, yytext(), yyline+1, yycolumn+1);
}
case 15: break;
case 20: break;
case 8:
{ yybegin(YYINITIAL);
yypushback(1);
return new Token(Token.ID, idValue, yyline+1, yycolumn+1-idValue.length());
}
case 21: break;
case 9:
{ idValue += yytext();
}
case 22: break;
case 10:
{ yybegin(YYINITIAL);
yypushback(1);
return new Token(Token.NUM, String.valueOf(intValue), yyline+1, yycolumn+1-String.valueOf(intValue).length());
}
case 23: break;
case 11:
{ yybegin(ID); idValue = String.valueOf(intValue); yypushback(1);
}
case 24: break;
case 12:
{ intValue = intValue * 10 + yycharat(0) - '0';
}
case 25: break;
case 13:
{ return new Token(Token.NULL, yytext(), yyline+1, yycolumn+1);
}
case 16: break;
case 26: break;
default:
zzScanError(ZZ_NO_MATCH);
}