1
GALS generates the code in Java. I want to put it in the eclipse to make a screen and such. I was told that in the method nextState
class lexico
, have to put a switch
with some numbers. But where do these numbers come from?
private int nextState(char c, int state)
{
switch (state)
{
case 0:
switch (c)
{
case 9: return 1;
case 10: return 1;
case 13: return 1;
case 32: return 1;
case 33: return 2;
case 34: return 3;
case 40: return 4;
case 41: return 5;
case 42: return 6;
case 43: return 7;
case 44: return 8;
case 45: return 9;
case 47: return 10;
case 48: return 11;
case 49: return 11;
case 50: return 11;
case 51: return 11;
case 52: return 11;
case 53: return 11;
case 54: return 11;
case 55: return 11;
case 56: return 11;
case 57: return 11;
case 59: return 12;
case 60: return 13;
case 61: return 14;
case 62: return 15;
case 65: return 16;
case 66: return 16;
case 67: return 16;
case 68: return 16;
case 69: return 16;
case 70: return 16;
case 71: return 16;
case 72: return 16;
case 73: return 16;
case 74: return 16;
case 75: return 16;
case 76: return 16;
case 77: return 16;
case 78: return 16;
case 79: return 16;
case 80: return 16;
case 81: return 16;
case 82: return 16;
case 83: return 16;
case 84: return 16;
case 85: return 16;
case 86: return 16;
case 87: return 16;
case 88: return 16;
case 89: return 16;
case 90: return 16;
case 97: return 16;
case 98: return 16;
case 99: return 16;
case 100: return 16;
case 101: return 16;
case 102: return 16;
case 103: return 16;
case 104: return 16;
case 105: return 16;
case 106: return 16;
case 107: return 16;
case 108: return 16;
case 109: return 16;
case 110: return 16;
case 111: return 16;
case 112: return 16;
case 113: return 16;
case 114: return 16;
case 115: return 16;
case 116: return 16;
case 117: return 16;
case 118: return 16;
case 119: return 16;
case 120: return 16;
case 121: return 16;
case 122: return 16;
case 123: return 17;
case 125: return 18;
default: return -1;
}
case 1:
switch (c)
{
case 9: return 1;
case 10: return 1;
case 13: return 1;
case 32: return 1;
default: return -1;
}
case 3:
switch (c)
{
case 9: return 3;
case 10: return 3;
case 13: return 3;
case 32: return 3;
case 33: return 3;
case 34: return 19;
case 35: return 3;
case 36: return 3;
case 37: return 3;
case 38: return 3;
case 39: return 3;
case 40: return 3;
case 41: return 3;
case 42: return 3;
case 43: return 3;
case 44: return 3;
case 45: return 3;
case 46: return 3;
case 47: return 3;
case 48: return 3;
case 49: return 3;
case 50: return 3;
case 51: return 3;
case 52: return 3;
case 53: return 3;
case 54: return 3;
case 55: return 3;
case 56: return 3;
case 57: return 3;
case 58: return 3;
case 59: return 3;
case 60: return 3;
case 61: return 3;
case 62: return 3;
case 63: return 3;
case 64: return 3;
case 65: return 3;
case 66: return 3;
case 67: return 3;
case 68: return 3;
case 69: return 3;
case 70: return 3;
case 71: return 3;
case 72: return 3;
case 73: return 3;
case 74: return 3;
case 75: return 3;
case 76: return 3;
case 77: return 3;
case 78: return 3;
case 79: return 3;
case 80: return 3;
case 81: return 3;
case 82: return 3;
case 83: return 3;
case 84: return 3;
case 85: return 3;
case 86: return 3;
case 87: return 3;
case 88: return 3;
case 89: return 3;
case 90: return 3;
case 91: return 3;
case 92: return 3;
case 93: return 3;
case 94: return 3;
case 95: return 3;
case 96: return 3;
case 97: return 3;
case 98: return 3;
case 99: return 3;
case 100: return 3;
case 101: return 3;
case 102: return 3;
case 103: return 3;
case 104: return 3;
case 105: return 3;
case 106: return 3;
case 107: return 3;
case 108: return 3;
case 109: return 3;
case 110: return 3;
case 111: return 3;
case 112: return 3;
case 113: return 3;
case 114: return 3;
case 115: return 3;
case 116: return 3;
case 117: return 3;
case 118: return 3;
case 119: return 3;
case 120: return 3;
case 121: return 3;
case 122: return 3;
case 123: return 3;
case 124: return 3;
case 125: return 3;
case 126: return 3;
case 161: return 3;
case 162: return 3;
case 163: return 3;
case 164: return 3;
case 165: return 3;
case 166: return 3;
case 167: return 3;
case 168: return 3;
case 169: return 3;
case 170: return 3;
case 171: return 3;
case 172: return 3;
case 173: return 3;
case 174: return 3;
case 175: return 3;
case 176: return 3;
case 177: return 3;
case 178: return 3;
case 179: return 3;
case 180: return 3;
case 181: return 3;
case 182: return 3;
case 183: return 3;
case 184: return 3;
case 185: return 3;
case 186: return 3;
case 187: return 3;
case 188: return 3;
case 189: return 3;
case 190: return 3;
case 191: return 3;
case 192: return 3;
case 193: return 3;
case 194: return 3;
case 195: return 3;
case 196: return 3;
case 197: return 3;
case 198: return 3;
case 199: return 3;
case 200: return 3;
case 201: return 3;
case 202: return 3;
case 203: return 3;
case 204: return 3;
case 205: return 3;
case 206: return 3;
case 207: return 3;
case 208: return 3;
case 209: return 3;
case 210: return 3;
case 211: return 3;
case 212: return 3;
case 213: return 3;
case 214: return 3;
case 215: return 3;
case 216: return 3;
case 217: return 3;
case 218: return 3;
case 219: return 3;
case 220: return 3;
case 221: return 3;
case 222: return 3;
case 223: return 3;
case 224: return 3;
case 225: return 3;
case 226: return 3;
case 227: return 3;
case 228: return 3;
case 229: return 3;
case 230: return 3;
case 231: return 3;
case 232: return 3;
case 233: return 3;
case 234: return 3;
case 235: return 3;
case 236: return 3;
case 237: return 3;
case 238: return 3;
case 239: return 3;
case 240: return 3;
case 241: return 3;
case 242: return 3;
case 243: return 3;
case 244: return 3;
case 245: return 3;
case 246: return 3;
case 247: return 3;
case 248: return 3;
case 249: return 3;
case 250: return 3;
case 251: return 3;
case 252: return 3;
case 253: return 3;
case 254: return 3;
case 255: return 3;
default: return -1;
}
case 10:
switch (c)
{
case 42: return 20;
default: return -1;
}
case 11:
switch (c)
{
case 46: return 21;
case 48: return 11;
case 49: return 11;
case 50: return 11;
case 51: return 11;
case 52: return 11;
case 53: return 11;
case 54: return 11;
case 55: return 11;
case 56: return 11;
case 57: return 11;
default: return -1;
}
case 13:
switch (c)
{
case 61: return 22;
case 62: return 23;
default: return -1;
}
case 14:
switch (c)
{
case 61: return 24;
default: return -1;
}
case 15:
switch (c)
{
case 61: return 25;
default: return -1;
}
case 16:
switch (c)
{
case 48: return 26;
case 49: return 26;
case 50: return 26;
case 51: return 26;
case 52: return 26;
case 53: return 26;
case 54: return 26;
case 55: return 26;
case 56: return 26;
case 57: return 26;
case 65: return 16;
case 66: return 16;
case 67: return 16;
case 68: return 16;
case 69: return 16;
case 70: return 16;
case 71: return 16;
case 72: return 16;
case 73: return 16;
case 74: return 16;
case 75: return 16;
case 76: return 16;
case 77: return 16;
case 78: return 16;
case 79: return 16;
case 80: return 16;
case 81: return 16;
case 82: return 16;
case 83: return 16;
case 84: return 16;
case 85: return 16;
case 86: return 16;
case 87: return 16;
case 88: return 16;
case 89: return 16;
case 90: return 16;
case 95: return 16;
case 97: return 16;
case 98: return 16;
case 99: return 16;
case 100: return 16;
case 101: return 16;
case 102: return 16;
case 103: return 16;
case 104: return 16;
case 105: return 16;
case 106: return 16;
case 107: return 16;
case 108: return 16;
case 109: return 16;
case 110: return 16;
case 111: return 16;
case 112: return 16;
case 113: return 16;
case 114: return 16;
case 115: return 16;
case 116: return 16;
case 117: return 16;
case 118: return 16;
case 119: return 16;
case 120: return 16;
case 121: return 16;
case 122: return 16;
default: return -1;
}
default: return -1;
}
}
Gabriella, are you studying for some compiler book? I have the good new dragon book here, I can catch an explanation from there because it might be better than mine, but if I can talk about where you’re contextualized, I can try an answer within the context
– Jefferson Quesado
So... This work was the teacher who passed... after doing in GALS, you have to generate the java code to create a small screen, and then the interface will show if there was a lexical or syntactic error. From the previous works I saw of the teacher, you had to put these numbers in the nextState method, but I don’t know where this number comes from. You know?
– Gabriella
if I tell you that comes from the deterministic stack automaton that is interpreting the input, will I be speaking Greek or Aramaic? Or was this concept good enough for what you know? I would like to give a deep answer to that, I love formal languages, but I’m not available right now
– Jefferson Quesado
boy and how do I get these numbers from the deterministic stack automaton?
– Gabriella