ajout nouveauté lexer

This commit is contained in:
Nicolas PENELOUX 2023-10-09 17:40:42 +02:00
parent 115e4426bd
commit 35ecae440b
2 changed files with 24 additions and 1 deletions

View file

@ -28,6 +28,10 @@ let integers = '-'? (digit+
| octa+) | octa+)
let ident = ['a'-'z']['A'-'Z' 'a'-'z' '0'-'9' '_']* 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 rule token = parse
(** Layout *) (** Layout *)
@ -39,10 +43,29 @@ rule token = parse
(** Keywords *) (** Keywords *)
| "let" { LET } | "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 *) (** Operators *)
| '=' { EQUAL } | '=' { EQUAL }
(** Values *) (** Values *)
| integers as i { INT (Mint.of_string i) } | integers as i { INT (Mint.of_string i) }
| ident as s { ID s } | ident as s { ID s }

View file

@ -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<Mint.t> INT
%token<string> ID %token<string> ID