| 1 | open Printf |
| 2 | |
| 3 | module T = Tiger_parser |
| 4 | |
| 5 | type t = T.token |
| 6 | |
| 7 | let to_string = function |
| 8 | | T.TYPE -> "TYPE" |
| 9 | | T.VAR -> "VAR" |
| 10 | | T.FUNCTION -> "FUNCTION" |
| 11 | | T.BREAK -> "BREAK" |
| 12 | | T.OF -> "OF" |
| 13 | | T.END -> "END" |
| 14 | | T.IN -> "IN" |
| 15 | | T.NIL -> "NIL" |
| 16 | | T.LET -> "LET" |
| 17 | | T.DO -> "DO" |
| 18 | | T.TO -> "TO" |
| 19 | | T.FOR -> "FOR" |
| 20 | | T.WHILE -> "WHILE" |
| 21 | | T.ELSE -> "ELSE" |
| 22 | | T.THEN -> "THEN" |
| 23 | | T.IF -> "IF" |
| 24 | | T.ARRAY -> "ARRAY" |
| 25 | | T.ASSIGN -> "ASSIGN" |
| 26 | | T.OR -> "OR" |
| 27 | | T.AND -> "AND" |
| 28 | | T.GE -> "GE" |
| 29 | | T.GT -> "GT" |
| 30 | | T.LE -> "LE" |
| 31 | | T.LT -> "LT" |
| 32 | | T.NEQ -> "NEQ" |
| 33 | | T.EQ -> "EQ" |
| 34 | | T.DIVIDE -> "DIVIDE" |
| 35 | | T.TIMES -> "TIMES" |
| 36 | | T.MINUS -> "MINUS" |
| 37 | | T.PLUS -> "PLUS" |
| 38 | | T.DOT -> "DOT" |
| 39 | | T.RBRACE -> "RBRACE" |
| 40 | | T.LBRACE -> "LBRACE" |
| 41 | | T.RBRACK -> "RBRACK" |
| 42 | | T.LBRACK -> "LBRACK" |
| 43 | | T.RPAREN -> "RPAREN" |
| 44 | | T.LPAREN -> "LPAREN" |
| 45 | | T.SEMICOLON -> "SEMICOLON" |
| 46 | | T.COLON -> "COLON" |
| 47 | | T.COMMA -> "COMMA" |
| 48 | | T.STRING s -> sprintf "STRING (%S)" s |
| 49 | | T.INT i -> sprintf "INT (%d)" i |
| 50 | | T.ID id -> sprintf "ID (%s)" id |
| 51 | | T.EOF -> "EOF" |