mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Add all missing parser error messages
... that's one less thing to do Two notes: - Updated the syntax errors in examples/NSW_community_gaming/tests/test_nsw_social_housie.catala_en ; those probably aren't expected though, but fixing them is outside my purpose here - There is consensus on keeping the error messages in English; however, here, the error messages include hints on the syntax to use, which are only valid for users of the English syntax. * A possible solution would be to apply cppo on parser.messages, using the macros already defined in lexer_LANG.cppo.ml. However, we would then need to tweak (or duplicate!) the parser to use the messages for the correct language. Furthermore, updating and merging the file on parser updates would need special care. * Another, maybe easier solution would be manual processing, using a custom escape in the parser messages and rewriting that at runtime when printing the message. We would need to extract a runtime version of the macro definitions though.
This commit is contained in:
parent
3f487a16ed
commit
98ebc36343
@ -601,14 +601,16 @@ let rec lex_code (lexbuf : lexbuf) : token =
|
|||||||
Buffer.add_string cents (String.make (2 - Buffer.length cents) '0');
|
Buffer.add_string cents (String.make (2 - Buffer.length cents) '0');
|
||||||
L.update_acc lexbuf;
|
L.update_acc lexbuf;
|
||||||
MONEY_AMOUNT (Buffer.contents units, Buffer.contents cents)
|
MONEY_AMOUNT (Buffer.contents units, Buffer.contents cents)
|
||||||
| Rep (digit, 4), '-', Rep (digit, 2), '-', Rep (digit, 2) ->
|
| '|', Rep (digit, 4), '-', Rep (digit, 2), '-', Rep (digit, 2), '|' ->
|
||||||
let rex =
|
let rex =
|
||||||
Re.(compile @@ whole_string @@ seq [
|
Re.(compile @@ whole_string @@ seq [
|
||||||
|
char '|';
|
||||||
group (repn digit 4 None);
|
group (repn digit 4 None);
|
||||||
char '-';
|
char '-';
|
||||||
group (repn digit 2 None);
|
group (repn digit 2 None);
|
||||||
char '-';
|
char '-';
|
||||||
group (repn digit 2 None);
|
group (repn digit 2 None);
|
||||||
|
char '|';
|
||||||
])
|
])
|
||||||
in
|
in
|
||||||
let date_parts = R.get_substring (R.exec ~rex (Utf8.lexeme lexbuf)) in
|
let date_parts = R.get_substring (R.exec ~rex (Utf8.lexeme lexbuf)) in
|
||||||
@ -687,9 +689,6 @@ let rec lex_code (lexbuf : lexbuf) : token =
|
|||||||
| ']' ->
|
| ']' ->
|
||||||
L.update_acc lexbuf;
|
L.update_acc lexbuf;
|
||||||
RBRACKET
|
RBRACKET
|
||||||
| '|' ->
|
|
||||||
L.update_acc lexbuf;
|
|
||||||
BAR
|
|
||||||
| ':' ->
|
| ':' ->
|
||||||
L.update_acc lexbuf;
|
L.update_acc lexbuf;
|
||||||
COLON
|
COLON
|
||||||
|
@ -84,7 +84,6 @@ let token_list_language_agnostic : (string * token) list =
|
|||||||
"-", MINUS KPoly;
|
"-", MINUS KPoly;
|
||||||
"*", MULT KPoly;
|
"*", MULT KPoly;
|
||||||
"/", DIV KPoly;
|
"/", DIV KPoly;
|
||||||
"|", BAR;
|
|
||||||
":", COLON;
|
":", COLON;
|
||||||
";", SEMICOLON;
|
";", SEMICOLON;
|
||||||
"--", ALT;
|
"--", ALT;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -303,7 +303,7 @@ let literal :=
|
|||||||
money_amount_cents = cents;
|
money_amount_cents = cents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| BAR ; d = DATE_LITERAL ; BAR ; {
|
| d = DATE_LITERAL ; {
|
||||||
let (y,m,d) = d in
|
let (y,m,d) = d in
|
||||||
LDate {
|
LDate {
|
||||||
literal_date_year = y;
|
literal_date_year = y;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
%token<string * string> DECIMAL_LITERAL
|
%token<string * string> DECIMAL_LITERAL
|
||||||
%token<string * string> MONEY_AMOUNT
|
%token<string * string> MONEY_AMOUNT
|
||||||
%token BEGIN_CODE TEXT
|
%token BEGIN_CODE TEXT
|
||||||
%token COLON ALT DATA BAR
|
%token COLON ALT DATA
|
||||||
%token OF INTEGER COLLECTION CONTAINS AMONG
|
%token OF INTEGER COLLECTION CONTAINS AMONG
|
||||||
%token RULE CONDITION DEFINED_AS
|
%token RULE CONDITION DEFINED_AS
|
||||||
%token<Ast.op_kind> LESSER GREATER LESSER_EQUAL GREATER_EQUAL
|
%token<Ast.op_kind> LESSER GREATER LESSER_EQUAL GREATER_EQUAL
|
||||||
|
@ -389,7 +389,7 @@
|
|||||||
\\
|
\\
|
||||||
Direct scope call & \begin{catala}
|
Direct scope call & \begin{catala}
|
||||||
```catala
|
```catala
|
||||||
outut of Scope1
|
output of Scope1
|
||||||
with { -- fld1: 9 -- fld2: true }
|
with { -- fld1: 9 -- fld2: true }
|
||||||
```
|
```
|
||||||
\end{catala}
|
\end{catala}
|
||||||
|
@ -29,7 +29,7 @@ scope Test1:
|
|||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret -s Test1
|
$ catala Interpret -s Test1
|
||||||
[ERROR] Syntax error at token "scope"
|
[ERROR] Syntax error at token "scope"
|
||||||
Message: unexpected token
|
Message: expected either 'condition', or 'content' followed by the expected variable type
|
||||||
Autosuggestion: did you mean "content", or maybe "condition"?
|
Autosuggestion: did you mean "content", or maybe "condition"?
|
||||||
|
|
||||||
Error token:
|
Error token:
|
||||||
@ -73,7 +73,7 @@ scope Test2:
|
|||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret -s Test2
|
$ catala Interpret -s Test2
|
||||||
[ERROR] Syntax error at token "scope"
|
[ERROR] Syntax error at token "scope"
|
||||||
Message: unexpected token
|
Message: expected either 'condition', or 'content' followed by the expected variable type
|
||||||
Autosuggestion: did you mean "content", or maybe "condition"?
|
Autosuggestion: did you mean "content", or maybe "condition"?
|
||||||
|
|
||||||
Error token:
|
Error token:
|
||||||
@ -117,7 +117,7 @@ scope Test3:
|
|||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret -s Test3
|
$ catala Interpret -s Test3
|
||||||
[ERROR] Syntax error at token "scope"
|
[ERROR] Syntax error at token "scope"
|
||||||
Message: unexpected token
|
Message: expected either 'condition', or 'content' followed by the expected variable type
|
||||||
Autosuggestion: did you mean "content", or maybe "condition"?
|
Autosuggestion: did you mean "content", or maybe "condition"?
|
||||||
|
|
||||||
Error token:
|
Error token:
|
||||||
@ -163,7 +163,7 @@ scope Test4:
|
|||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret -s Test4
|
$ catala Interpret -s Test4
|
||||||
[ERROR] Syntax error at token "scope"
|
[ERROR] Syntax error at token "scope"
|
||||||
Message: unexpected token
|
Message: expected either 'condition', or 'content' followed by the expected variable type
|
||||||
Autosuggestion: did you mean "content", or maybe "condition"?
|
Autosuggestion: did you mean "content", or maybe "condition"?
|
||||||
|
|
||||||
Error token:
|
Error token:
|
||||||
|
Loading…
Reference in New Issue
Block a user