mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
55 lines
858 B
OCaml
55 lines
858 B
OCaml
type token_type =
|
|
| LeftParen
|
|
| RightParen
|
|
| LeftBrace
|
|
| RightBrace
|
|
| Plus
|
|
| Minus
|
|
| Star
|
|
| Slash
|
|
| Bang
|
|
| Dot
|
|
| Comma
|
|
| Semicolon
|
|
| Equal
|
|
| EqualEqual
|
|
| BangEqual
|
|
| Greater
|
|
| Less
|
|
| GreaterEqual
|
|
| LessEqual
|
|
| Identifier of string
|
|
| String of string
|
|
| Number of float
|
|
| And
|
|
| Break
|
|
| Class
|
|
| Continue
|
|
| Else
|
|
| False
|
|
| Fun
|
|
| For
|
|
| If
|
|
| Nil
|
|
| Or
|
|
| Print
|
|
| Return
|
|
| Super
|
|
| This
|
|
| True
|
|
| Var
|
|
| While
|
|
| Comment of string
|
|
| Eof
|
|
|
|
val pp_token_type : Format.formatter -> token_type -> unit
|
|
val show_token_type : token_type -> string
|
|
val keywords : (string, token_type) Hashtbl.t
|
|
|
|
type token = { token_type : token_type; pos : Error.code_pos }
|
|
|
|
val show_token : token -> string
|
|
|
|
type lexer_result = (token list, Error.lexer_error list) result
|
|
|
|
val tokenize : string -> lexer_result
|