1: #include "itran.h" 2: #include "lex.h" 3: #include "token.h" 4: 5: /* 6: * Token table - contains an entry for each token type 7: * with printable name of token, token type, and flags 8: * for semicolon insertion. 9: */ 10: 11: struct toktab toktab[] = { 12: /* token token type flags */ 13: 14: /* primitives */ 15: "identifier", IDENT, BEGINNER+ENDER, /* 0 */ 16: "integer-literal", INTLIT, BEGINNER+ENDER, /* 1 */ 17: "real-literal", REALLIT, BEGINNER+ENDER, /* 2 */ 18: "string-literal", STRINGLIT, BEGINNER+ENDER, /* 3 */ 19: "cset-literal", CSETLIT, BEGINNER+ENDER, /* 4 */ 20: "end-of-file", EOFX, 0, /* 5 */ 21: 22: /* reserved words */ 23: "break", BREAK, BEGINNER+ENDER, /* 6 */ 24: "by", BY, 0, /* 7 */ 25: "case", CASE, BEGINNER, /* 8 */ 26: "create", CREATE, BEGINNER, /* 9 */ 27: "default", DEFAULT, BEGINNER, /* 10 */ 28: "do", DO, 0, /* 11 */ 29: "dynamic", DYNAMIC, BEGINNER, /* 12 */ 30: "else", ELSE, 0, /* 13 */ 31: "end", END, BEGINNER, /* 14 */ 32: "every", EVERY, BEGINNER, /* 15 */ 33: "fail", FAIL, BEGINNER+ENDER, /* 16 */ 34: "global", GLOBAL, 0, /* 17 */ 35: "if", IF, BEGINNER, /* 18 */ 36: "initial", INITIAL, BEGINNER, /* 19 */ 37: "link", LINK, 0, /* 20 */ 38: "local", LOCAL, BEGINNER, /* 21 */ 39: "next", NEXT, BEGINNER+ENDER, /* 22 */ 40: "not", NOT, BEGINNER, /* 23 */ 41: "of", OF, 0, /* 24 */ 42: "procedure", PROCEDURE, 0, /* 25 */ 43: "record", RECORD, 0, /* 26 */ 44: "repeat", REPEAT, BEGINNER, /* 27 */ 45: "return", RETURN, BEGINNER+ENDER, /* 28 */ 46: "static", STATIC, BEGINNER, /* 29 */ 47: "suspend", SUSPEND, BEGINNER+ENDER, /* 30 */ 48: "then", THEN, 0, /* 31 */ 49: "to", TO, 0, /* 32 */ 50: "until", UNTIL, BEGINNER, /* 33 */ 51: "while", WHILE, BEGINNER, /* 34 */ 52: 53: /* operators */ 54: ":=", ASSIGN, 0, /* 35 */ 55: "@", AT, BEGINNER, /* 36 */ 56: "@:=", AUGACT, 0, /* 37 */ 57: "&:=", AUGAND, 0, /* 38 */ 58: "=:=", AUGEQ, 0, /* 39 */ 59: "===:=", AUGEQV, 0, /* 40 */ 60: ">=:=", AUGGE, 0, /* 41 */ 61: ">:=", AUGGT, 0, /* 42 */ 62: "<=:=", AUGLE, 0, /* 43 */ 63: "<:=", AUGLT, 0, /* 44 */ 64: "~=:=", AUGNE, 0, /* 45 */ 65: "~===:=", AUGNEQV, 0, /* 46 */ 66: "==:=", AUGSEQ, 0, /* 47 */ 67: ">>=:=", AUGSGE, 0, /* 48 */ 68: ">>:=", AUGSGT, 0, /* 49 */ 69: "<<=:=", AUGSLE, 0, /* 50 */ 70: "<<:=", AUGSLT, 0, /* 51 */ 71: "~==:=", AUGSNE, 0, /* 52 */ 72: "\\", BACKSLASH, BEGINNER, /* 53 */ 73: "!", BANG, BEGINNER, /* 54 */ 74: "|", BAR, BEGINNER, /* 55 */ 75: "^", CARET, BEGINNER, /* 56 */ 76: "^:=", CARETASGN, 0, /* 57 */ 77: ":", COLON, 0, /* 58 */ 78: ",", COMMA, 0, /* 59 */ 79: "||", CONCAT, BEGINNER, /* 60 */ 80: "||:=", CONCATASGN, 0, /* 61 */ 81: "&", CONJUNC, BEGINNER, /* 62 */ 82: ".", DOT, BEGINNER, /* 63 */ 83: "--", DIFF, BEGINNER, /* 64 */ 84: "--:=", DIFFASGN, 0, /* 65 */ 85: "===", EQUIV, BEGINNER, /* 66 */ 86: "**", INTER, BEGINNER, /* 67 */ 87: "**:=", INTERASGN, 0, /* 68 */ 88: "{", LBRACE, BEGINNER, /* 69 */ 89: "[", LBRACK, BEGINNER, /* 70 */ 90: "|||", LCONCAT, BEGINNER, /* 71 */ 91: "|||:=", LCONCATASGN, BEGINNER, /* 72 */ 92: "==", LEXEQ, BEGINNER, /* 73 */ 93: ">>=", LEXGE, 0, /* 74 */ 94: ">>", LEXGT, 0, /* 75 */ 95: "<<=", LEXLE, 0, /* 76 */ 96: "<<", LEXLT, 0, /* 77 */ 97: "~==", LEXNE, BEGINNER, /* 78 */ 98: "(", LPAREN, BEGINNER, /* 79 */ 99: "-:", MCOLON, 0, /* 80 */ 100: "-", MINUS, BEGINNER, /* 81 */ 101: "-:=", MINUSASGN, 0, /* 82 */ 102: "%", MOD, 0, /* 83 */ 103: "%:=", MODASGN, 0, /* 84 */ 104: "~===", NOTEQUIV, BEGINNER, /* 85 */ 105: "=", NUMEQ, BEGINNER, /* 86 */ 106: ">=", NUMGE, 0, /* 87 */ 107: ">", NUMGT, 0, /* 88 */ 108: "<=", NUMLE, 0, /* 89 */ 109: "<", NUMLT, 0, /* 90 */ 110: "~=", NUMNE, BEGINNER, /* 91 */ 111: "+:", PCOLON, 0, /* 92 */ 112: "+", PLUS, BEGINNER, /* 93 */ 113: "+:=", PLUSASGN, 0, /* 94 */ 114: "?", QMARK, BEGINNER, /* 95 */ 115: "<-", REVASSIGN, 0, /* 96 */ 116: "<->", REVSWAP, 0, /* 97 */ 117: "}", RBRACE, ENDER, /* 98 */ 118: "]", RBRACK, ENDER, /* 99 */ 119: ")", RPAREN, ENDER, /* 100 */ 120: ";", SEMICOL, 0, /* 101 */ 121: "?:=", SCANASGN, 0, /* 102 */ 122: "/", SLASH, BEGINNER, /* 103 */ 123: "/:=", SLASHASGN, 0, /* 104 */ 124: "*", STAR, BEGINNER, /* 105 */ 125: "*:=", STARASGN, 0, /* 106 */ 126: ":=:", SWAP, 0, /* 107 */ 127: "~", TILDE, BEGINNER, /* 108 */ 128: "++", UNION, BEGINNER, /* 109 */ 129: "++:=", UNIONASGN, 0, /* 110 */ 130: "end-of-file", 0, 0, 131: }; 132: 133: /* 134: * restab[c] points to the first keyword in toktab which 135: * begins with the letter c. 136: */ 137: 138: struct toktab *restab[] = { 139: NULL , NULL , /* _` */ 140: NULL, &toktab[ 6], &toktab[ 8], &toktab[10], /* abcd */ 141: &toktab[13], &toktab[16], &toktab[17], NULL, /* efgh */ 142: &toktab[18], NULL, NULL, &toktab[20], /* ijkl */ 143: NULL, &toktab[22], &toktab[24], &toktab[25], /* mnop */ 144: NULL, &toktab[26], &toktab[29], &toktab[31], /* qrst */ 145: &toktab[33], NULL, &toktab[34], NULL, /* uvwx */ 146: NULL, NULL, /* yz */ 147: };