correction reference et lexer

This commit is contained in:
Nicolas PENELOUX 2023-10-23 12:35:31 +02:00
parent 892d0bf8dc
commit 94fdab56fc
2 changed files with 11 additions and 2 deletions

View file

@ -53,6 +53,8 @@ let int = '-'? (digit+ | hexa+ | bina+ | octa+)
(* Littéraux caractères *)
let letter = (digit | ['A'-'Z'] | ['a'-'z'])
let ascii_trop_grand = '\\' ['3'-'9']['0'-'9'](['0'-'9'])+
rule token = parse
(** Layout *)
| newline { next_line_and token lexbuf }
@ -134,6 +136,8 @@ rule token = parse
in CHAR (Char.chr (code)) } *)
(** Lexing error *)
(* erreur qui advient pour le test 22-char-literal, le code renvoie bizarrement que "Error (during lexing) "*)
| "'" ascii_trop_grand "'" { error lexbuf None "" }
| _ as _c { error lexbuf None (* (Some _c) *) "unexpected character." }
(* TODO: Gérer les imbrications de commentaires *)

View file

@ -23,7 +23,6 @@
/* TODO: Résoudre tout les shift/reduce conflits */
%right WHILE REF DO
%left FUN MATCH IF FOR
%right ARROW
%right SEMICOLON
@ -327,10 +326,16 @@ expression:
}
/* Sequence - Séquencement *
* Pas sûr, voir s'il ne faut pas une troisième couche d'expression */
| e=located(simple_expression)
SEMICOLON e_list=separated_nonempty_list(SEMICOLON, located(simple_expression)) {
Sequence(e :: e_list)
}
/*
|e1=located(expression) SEMICOLON e2=located(expression){
Sequence([e1;e2])
}*/
/* Definition locale */
| vd=vdefinition SEMICOLON e=located(expression) {
Define(vd, e)
@ -389,7 +394,7 @@ expression:
}
/* Reference - Allocation
* ref expr */
| REF e=located(expression) {
| REF e=located(simple_expression) {
Ref(e)
}
/* Affectation