From 35ecae440b5c9e2aa4f2756a353a4b16985fe213 Mon Sep 17 00:00:00 2001 From: Nicolas PENELOUX Date: Mon, 9 Oct 2023 17:40:42 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20nouveaut=C3=A9=20lexer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flap/src/hopix/hopixLexer.mll | 23 +++++++++++++++++++++++ flap/src/hopix/hopixParser.mly | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/flap/src/hopix/hopixLexer.mll b/flap/src/hopix/hopixLexer.mll index 106b918..6808086 100644 --- a/flap/src/hopix/hopixLexer.mll +++ b/flap/src/hopix/hopixLexer.mll @@ -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 } diff --git a/flap/src/hopix/hopixParser.mly b/flap/src/hopix/hopixParser.mly index 14a8a6e..50e9587 100644 --- a/flap/src/hopix/hopixParser.mly +++ b/flap/src/hopix/hopixParser.mly @@ -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 INT %token ID