ajout nouveauté lexer
This commit is contained in:
parent
115e4426bd
commit
35ecae440b
2 changed files with 24 additions and 1 deletions
|
@ -28,6 +28,10 @@ let integers = '-'? (digit+
|
|||
| octa+)
|
||||
|
||||
let ident = ['a'-'z']['A'-'Z' 'a'-'z' '0'-'9' '_']*
|
||||
let constr_id = ['A'-'Z']['A'-'Z' 'a'-'z' '0'-'9' '_']*
|
||||
let type_variable = '\''ident
|
||||
|
||||
let binop = '+' | '-' | '*' | '/' | "&&" | "||"| "=?"| "<=?" |">=?" |"<?" |">?"
|
||||
|
||||
rule token = parse
|
||||
(** Layout *)
|
||||
|
@ -39,10 +43,29 @@ rule token = parse
|
|||
|
||||
(** Keywords *)
|
||||
| "let" { LET }
|
||||
| "type" { TYPE }
|
||||
| "extern" { EXTERN }
|
||||
| "fun" { FUN }
|
||||
| "match" { MATCH }
|
||||
| "if" { IF }
|
||||
| "then" { THEN }
|
||||
| "else" { ELSE }
|
||||
| "ref" { REF }
|
||||
| "while" { WHILE }
|
||||
| "do" { DO }
|
||||
| "until" { UNTIL }
|
||||
| "for" { FOR }
|
||||
| "from" { FROM }
|
||||
| "to" { TO }
|
||||
(* Fini ? *)
|
||||
|
||||
(* binar operation : pas sûr pour celui là*)
|
||||
| binop as b { BINOP (* TODO *) }
|
||||
|
||||
(** Operators *)
|
||||
| '=' { EQUAL }
|
||||
|
||||
|
||||
(** Values *)
|
||||
| integers as i { INT (Mint.of_string i) }
|
||||
| ident as s { ID s }
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
%}
|
||||
|
||||
%token EOF LET EQUAL
|
||||
%token EOF LET TYPE EXTERN FUN MATCH IF THEN ELSE REF WHILE DO UNTIL FOR FROM TO BINOP EQUAL
|
||||
|
||||
%token<Mint.t> INT
|
||||
%token<string> ID
|
||||
|
|
Reference in a new issue