implemented break

This commit is contained in:
Moritz Gmeiner 2024-08-27 02:46:17 +02:00
commit e288a626fd
6 changed files with 84 additions and 72 deletions

View file

@ -14,7 +14,7 @@ open Error
| String of string
| Number of float
| And | Class | Else | False | Fun | For | If | Nil | Or | Print | Return | Super | This | True
| And | Break | Class | Else | False | Fun | For | If | Nil | Or | Print | Return | Super | This | True
| Var | While
| Comment of string
@ -29,10 +29,11 @@ let keywords =
Hashtbl.add keywords s tt;
keywords
in
keywords |> insert "and" And |> insert "class" Class |> insert "else" Else |> insert "false" False
|> insert "for" For |> insert "fun" Fun |> insert "if" If |> insert "nil" Nil |> insert "or" Or
|> insert "print" Print |> insert "return" Return |> insert "super" Super |> insert "this" This
|> insert "true" True |> insert "var" Var |> insert "while" While
keywords |> insert "and" And |> insert "break" Break |> insert "class" Class |> insert "else" Else
|> insert "false" False |> insert "for" For |> insert "fun" Fun |> insert "if" If
|> insert "nil" Nil |> insert "or" Or |> insert "print" Print |> insert "return" Return
|> insert "super" Super |> insert "this" This |> insert "true" True |> insert "var" Var
|> insert "while" While
type token = { token_type : token_type; pos : code_pos }