mirror of
https://github.com/LucasVbr/croissant.git
synced 2026-12-05 15:20:50 +00:00
feat: Support basic expression
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
(* lib/lexer.mll *)
|
||||
{
|
||||
open Parser
|
||||
exception Error of char
|
||||
}
|
||||
|
||||
let line_comment = "//" [^ '\n']*
|
||||
|
||||
let digit = ['0'-'9']
|
||||
let integer = digit+
|
||||
|
||||
rule token = parse
|
||||
| [' ' '\t'] | line_comment { token lexbuf }
|
||||
| ['\n'] { Lexing.new_line lexbuf; token lexbuf }
|
||||
|
||||
| '+' { PLUS }
|
||||
| '-' { MINUS }
|
||||
| '*' { TIMES }
|
||||
| '/' { DIVIDE }
|
||||
| ';' { SEMICOLON }
|
||||
|
||||
| integer as lxm { INT(int_of_string lxm) }
|
||||
|
||||
| '(' { LPAREN }
|
||||
| ')' { RPAREN }
|
||||
|
||||
| eof { EOF }
|
||||
| _ as c { raise (Error c) }
|
||||
Reference in New Issue
Block a user