feat: Support basic expression

This commit is contained in:
Lucàs
2024-07-02 15:33:58 +02:00
parent c91951308f
commit e563bce4f5
12 changed files with 231 additions and 25 deletions
+28
View File
@@ -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) }