mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
implemented break
This commit is contained in:
parent
3bc871d434
commit
e288a626fd
6 changed files with 84 additions and 72 deletions
|
|
@ -22,6 +22,7 @@ type token_type =
|
|||
| String of string
|
||||
| Number of float
|
||||
| And
|
||||
| Break
|
||||
| Class
|
||||
| Else
|
||||
| False
|
||||
|
|
@ -50,36 +51,4 @@ val show_token : token -> string
|
|||
|
||||
type lexer_result = (token list, Error.lexer_error list) result
|
||||
|
||||
(* type state = {
|
||||
source : string;
|
||||
start_pos : int;
|
||||
cur_pos : int;
|
||||
tokens_rev : token list;
|
||||
errors_rev : Error.lexer_error list;
|
||||
line : int;
|
||||
col : int;
|
||||
}
|
||||
module State : sig
|
||||
type t = state
|
||||
|
||||
val is_digit : char -> bool
|
||||
val is_alpha : char -> bool
|
||||
val is_alphanum : char -> bool
|
||||
val is_identifier : char -> bool
|
||||
val is_at_end : state -> bool
|
||||
val get_lexeme : state -> int -> int -> string
|
||||
val advance : state -> char * state
|
||||
val peek : state -> char option
|
||||
val advance_if : char -> state -> bool * state
|
||||
val advance_until : char -> state -> bool * state
|
||||
val advance_while : (char -> bool) -> state -> state
|
||||
val last_char : state -> char
|
||||
val append_token : Error.code_pos -> token_type -> state -> state
|
||||
val append_error : Error.code_pos -> string -> state -> state
|
||||
val parse_number : state -> state
|
||||
val parse_keyword_or_identifier : state -> state
|
||||
val parse_block_commend : state -> state
|
||||
val tokenize_rec : state -> state
|
||||
end *)
|
||||
|
||||
val tokenize : string -> lexer_result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue