aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChimrod <>2023-10-01 19:07:17 +0200
committerChimrod <>2023-10-01 19:07:17 +0200
commit622bbf897af29ec6f7d533f915b0170d3a9c899f (patch)
treef985dc2f40c8ca9938e93b75fb266fe2b12330ae
parent2e41a214e4c2a2984ad3b2afa3d80178d227927f (diff)
Added some test for syntax errors
-rw-r--r--lib/analyzer.ml14
-rw-r--r--lib/expression_parser.messages1137
-rw-r--r--syntax/report.ml2
-rw-r--r--test/qsp_parser_test.ml832
-rw-r--r--test/syntax.ml832
-rw-r--r--test/syntax_error.ml85
6 files changed, 927 insertions, 1975 deletions
diff --git a/lib/analyzer.ml b/lib/analyzer.ml
index 7a64cab..da1adbf 100644
--- a/lib/analyzer.ml
+++ b/lib/analyzer.ml
@@ -23,13 +23,13 @@ let parse :
| Interpreter.InvalidSyntax -> "Invalid Syntax"
| Interpreter.UnrecoverableError -> "UnrecoverableError"
| Interpreter.MenhirCode c ->
- String.concat ""
- [
- String.trim @@ Parser_messages.message c;
- " (Error code ";
- string_of_int c;
- ")";
- ]
+ let message_content =
+ try Parser_messages.message c
+ with Not_found ->
+ String.concat "" [ "(Error code "; string_of_int c; ")" ]
+ in
+
+ String.concat "" [ String.trim @@ message_content ]
in
let report =
Qsp_syntax.Report.error (e.start_pos, e.end_pos) message
diff --git a/lib/expression_parser.messages b/lib/expression_parser.messages
index eaeec6c..2bdf477 100644
--- a/lib/expression_parser.messages
+++ b/lib/expression_parser.messages
@@ -311,880 +311,6 @@ main: EOL STAR
The context does not allow an instruction here.
-main: LOCATION_START EOL R_PAREN
-##
-## Ends in an error in state: 7.
-##
-## nonempty_list(EOL) -> EOL . [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## nonempty_list(EOL) -> EOL . nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## EOL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL STAR STAR
-##
-## Ends in an error in state: 10.
-##
-## keyword -> STAR . KEYWORD [ PLUS OBJ NO MINUS L_PAREN LITERAL INTEGER IDENT FUNCTION EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## STAR
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL SET STAR
-##
-## Ends in an error in state: 12.
-##
-## let_assignation -> SET . variable assignation_operator expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## SET
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT L_BRACKET STAR
-##
-## Ends in an error in state: 14.
-##
-## option(delimited(L_BRACKET,option(expression),R_BRACKET)) -> L_BRACKET . option(expression) R_BRACKET [ STAR R_PAREN R_BRACKET PLUS OR MULT_EQUAL MOD MINUS LT INCR GT EXCLAMATION EQUAL EOL ELSE DIV DECR COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## L_BRACKET
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL L_PAREN STAR
-##
-## Ends in an error in state: 19.
-##
-## expression -> L_PAREN . expression R_PAREN [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## L_PAREN
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL FUNCTION STAR
-##
-## Ends in an error in state: 22.
-##
-## expression -> FUNCTION . L_PAREN arguments(expression) R_PAREN [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> FUNCTION . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## FUNCTION
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL FUNCTION L_PAREN STAR
-##
-## Ends in an error in state: 23.
-##
-## expression -> L_PAREN . expression R_PAREN [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> FUNCTION L_PAREN . arguments(expression) R_PAREN [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## FUNCTION L_PAREN
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT STAR STAR
-##
-## Ends in an error in state: 27.
-##
-## expression -> expression STAR . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression STAR
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT LT STAR
-##
-## Ends in an error in state: 39.
-##
-## expression -> expression LT . GT expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> expression LT . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> expression LT . EQUAL expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression LT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT GT STAR
-##
-## Ends in an error in state: 46.
-##
-## expression -> expression GT . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> expression GT . EQUAL expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression GT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL INTEGER EQUAL STAR
-##
-## Ends in an error in state: 51.
-##
-## expression -> expression EQUAL . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> expression EQUAL . GT expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> expression EQUAL . LT expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression EQUAL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD L_PAREN INTEGER SET
-##
-## Ends in an error in state: 59.
-##
-## arguments(expression) -> expression . COMA separated_nonempty_list(COMA,expression) [ R_PAREN ]
-## expression -> L_PAREN expression . R_PAREN [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-## expression -> expression . EQUAL expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . LT GT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . EXCLAMATION expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . PLUS expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . MINUS expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . STAR expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . DIV expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . MOD expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . GT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . LT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . AND expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . GT EQUAL expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . LT EQUAL expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . EQUAL GT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . EQUAL LT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-## expression -> expression . OR expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COMA AND ]
-##
-## The known suffix of the stack is as follows:
-## L_PAREN expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD IDENT COMA INTEGER SET
-##
-## Ends in an error in state: 63.
-##
-## expression -> expression . EQUAL expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . LT GT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . EXCLAMATION expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . PLUS expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . MINUS expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . STAR expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . DIV expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . MOD expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . GT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . LT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . AND expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . GT EQUAL expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . LT EQUAL expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . EQUAL GT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . EQUAL LT expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . OR expression [ STAR R_PAREN PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## separated_nonempty_list(COMA,expression) -> expression . [ R_PAREN EOL ELSE AMPERSAND ]
-## separated_nonempty_list(COMA,expression) -> expression . COMA separated_nonempty_list(COMA,expression) [ R_PAREN EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD IDENT COMA IDENT COMA STAR
-##
-## Ends in an error in state: 64.
-##
-## separated_nonempty_list(COMA,expression) -> expression COMA . separated_nonempty_list(COMA,expression) [ R_PAREN EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression COMA
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL FUNCTION L_PAREN IDENT COMA IDENT EOL
-##
-## Ends in an error in state: 66.
-##
-## expression -> FUNCTION L_PAREN arguments(expression) . R_PAREN [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## FUNCTION L_PAREN arguments(expression)
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 13, spurious reduction of production option(delimited(L_BRACKET,option(expression),R_BRACKET)) ->
-## In state 73, spurious reduction of production variable -> IDENT option(delimited(L_BRACKET,option(expression),R_BRACKET))
-## In state 24, spurious reduction of production expression -> variable
-## In state 63, spurious reduction of production separated_nonempty_list(COMA,expression) -> expression
-## In state 62, spurious reduction of production arguments(expression) -> expression COMA separated_nonempty_list(COMA,expression)
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT L_BRACKET INTEGER SET
-##
-## Ends in an error in state: 72.
-##
-## expression -> expression . EQUAL expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . LT GT expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . EXCLAMATION expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . PLUS expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . MINUS expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . STAR expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . DIV expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . MOD expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . GT expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . LT expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . AND expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . GT EQUAL expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . LT EQUAL expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . EQUAL GT expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . EQUAL LT expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## expression -> expression . OR expression [ STAR R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV AND ]
-## option(expression) -> expression . [ R_BRACKET ]
-##
-## The known suffix of the stack is as follows:
-## expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL SET IDENT STAR
-##
-## Ends in an error in state: 74.
-##
-## let_assignation -> SET variable . assignation_operator expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## SET variable
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 13, spurious reduction of production option(delimited(L_BRACKET,option(expression),R_BRACKET)) ->
-## In state 73, spurious reduction of production variable -> IDENT option(delimited(L_BRACKET,option(expression),R_BRACKET))
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL SET IDENT DECR STAR
-##
-## Ends in an error in state: 79.
-##
-## let_assignation -> SET variable assignation_operator . expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## SET variable assignation_operator
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL SET IDENT DECR INTEGER SET
-##
-## Ends in an error in state: 80.
-##
-## expression -> expression . EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EXCLAMATION expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . PLUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . MINUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . STAR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . DIV expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . MOD expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . AND expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . GT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EQUAL GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EQUAL LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . OR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## let_assignation -> SET variable assignation_operator expression . [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## SET variable assignation_operator expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL LET STAR
-##
-## Ends in an error in state: 81.
-##
-## let_assignation -> LET . variable assignation_operator expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## LET
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL LET IDENT STAR
-##
-## Ends in an error in state: 82.
-##
-## let_assignation -> LET variable . assignation_operator expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## LET variable
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 13, spurious reduction of production option(delimited(L_BRACKET,option(expression),R_BRACKET)) ->
-## In state 73, spurious reduction of production variable -> IDENT option(delimited(L_BRACKET,option(expression),R_BRACKET))
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL LET IDENT DECR STAR
-##
-## Ends in an error in state: 83.
-##
-## let_assignation -> LET variable assignation_operator . expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## LET variable assignation_operator
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL LET IDENT DECR INTEGER SET
-##
-## Ends in an error in state: 84.
-##
-## expression -> expression . EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EXCLAMATION expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . PLUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . MINUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . STAR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . DIV expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . MOD expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . AND expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . GT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EQUAL GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EQUAL LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . OR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## let_assignation -> LET variable assignation_operator expression . [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## LET variable assignation_operator expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF STAR
-##
-## Ends in an error in state: 86.
-##
-## line_statement -> IF . expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END option(IF) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> IF . expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END option(IF) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## onliner(IF) -> IF . expression COLUMN final_inline_instruction [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## IF
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN R_PAREN
-##
-## Ends in an error in state: 88.
-##
-## line_statement -> IF expression COLUMN . nonempty_list(EOL) list(line_statement) elif_else_body END option(IF) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> IF expression COLUMN . nonempty_list(EOL) list(line_statement) elif_else_body END option(IF) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## onliner(IF) -> IF expression COLUMN . final_inline_instruction [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## IF expression COLUMN
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL LOCATION_END
-##
-## Ends in an error in state: 89.
-##
-## line_statement -> IF expression COLUMN nonempty_list(EOL) . list(line_statement) elif_else_body END option(IF) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> IF expression COLUMN nonempty_list(EOL) . list(line_statement) elif_else_body END option(IF) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## IF expression COLUMN nonempty_list(EOL)
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 7, spurious reduction of production nonempty_list(EOL) -> EOL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL COMMENT STAR
-##
-## Ends in an error in state: 90.
-##
-## line_statement -> COMMENT . nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## COMMENT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL COLUMN IDENT R_PAREN
-##
-## Ends in an error in state: 93.
-##
-## line_statement -> COLUMN IDENT . list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## COLUMN IDENT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT STAR
-##
-## Ends in an error in state: 97.
-##
-## line_statement -> ACT . expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END option(ACT) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> ACT . expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END option(ACT) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## onliner(ACT) -> ACT . expression COLUMN final_inline_instruction [ EOL AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## ACT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN R_PAREN
-##
-## Ends in an error in state: 99.
-##
-## line_statement -> ACT expression COLUMN . nonempty_list(EOL) list(line_statement) empty_body END option(ACT) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> ACT expression COLUMN . nonempty_list(EOL) list(line_statement) empty_body END option(ACT) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## onliner(ACT) -> ACT expression COLUMN . final_inline_instruction [ EOL AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## ACT expression COLUMN
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT DECR STAR
-##
-## Ends in an error in state: 102.
-##
-## let_assignation -> variable assignation_operator . expression [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## variable assignation_operator
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT DECR INTEGER SET
-##
-## Ends in an error in state: 103.
-##
-## expression -> expression . EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EXCLAMATION expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . PLUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . MINUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . STAR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . DIV expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . MOD expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . AND expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . GT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . LT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EQUAL GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . EQUAL LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## expression -> expression . OR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV AND AMPERSAND ]
-## let_assignation -> variable assignation_operator expression . [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## variable assignation_operator expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN COMMENT STAR
-##
-## Ends in an error in state: 105.
-##
-## inline_action -> onliner(IF) . option(preceded(ELSE,instruction)) [ EOL ELSE AMPERSAND ]
-## inline_action -> onliner(IF) . ELSE inline_action [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## onliner(IF)
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD STAR
-##
-## Ends in an error in state: 122.
-##
-## single_instruction -> keyword . qsp_instruction_argument(expression) [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## keyword
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD L_PAREN STAR
-##
-## Ends in an error in state: 123.
-##
-## expression -> L_PAREN . expression R_PAREN [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## optionnal_delimited(L_PAREN,arguments(expression),R_PAREN) -> L_PAREN . arguments(expression) R_PAREN [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## L_PAREN
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD L_PAREN IDENT COMA IDENT EOL
-##
-## Ends in an error in state: 124.
-##
-## optionnal_delimited(L_PAREN,arguments(expression),R_PAREN) -> L_PAREN arguments(expression) . R_PAREN [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## L_PAREN arguments(expression)
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 13, spurious reduction of production option(delimited(L_BRACKET,option(expression),R_BRACKET)) ->
-## In state 73, spurious reduction of production variable -> IDENT option(delimited(L_BRACKET,option(expression),R_BRACKET))
-## In state 24, spurious reduction of production expression -> variable
-## In state 63, spurious reduction of production separated_nonempty_list(COMA,expression) -> expression
-## In state 62, spurious reduction of production arguments(expression) -> expression COMA separated_nonempty_list(COMA,expression)
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD INTEGER SET
-##
-## Ends in an error in state: 128.
-##
-## arguments(expression) -> expression . COMA separated_nonempty_list(COMA,expression) [ EOL ELSE AMPERSAND ]
-## expression -> expression . EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . LT GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . EXCLAMATION expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . PLUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . MINUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . STAR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . DIV expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . MOD expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . AND expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . GT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . LT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . EQUAL GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . EQUAL LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## expression -> expression . OR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA AND AMPERSAND ]
-## qsp_instruction_argument(expression) -> expression . [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN EOL IDENT AMPERSAND LOCATION_END
-##
-## Ends in an error in state: 138.
-##
-## line_statement -> ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body . END option(ACT) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body . END option(ACT) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 117, spurious reduction of production nonempty_list(AMPERSAND) -> AMPERSAND
-## In state 149, spurious reduction of production list(EOL) ->
-## In state 150, spurious reduction of production line_statement -> instruction nonempty_list(AMPERSAND) list(EOL)
-## In state 145, spurious reduction of production list(line_statement) ->
-## In state 146, spurious reduction of production list(line_statement) -> line_statement list(line_statement)
-## In state 137, spurious reduction of production empty_body ->
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN EOL END STAR
-##
-## Ends in an error in state: 139.
-##
-## line_statement -> ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END . option(ACT) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END . option(ACT) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN EOL END ACT STAR
-##
-## Ends in an error in state: 141.
-##
-## line_statement -> ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END option(ACT) . nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END option(ACT) . nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## ACT expression COLUMN nonempty_list(EOL) list(line_statement) empty_body END option(ACT)
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT AMPERSAND R_PAREN
-##
-## Ends in an error in state: 117.
-##
-## nonempty_list(AMPERSAND) -> AMPERSAND . [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION EOL END ELSE ELIF COMMENT COLUMN AMPERSAND ACT ]
-## nonempty_list(AMPERSAND) -> AMPERSAND . nonempty_list(AMPERSAND) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION EOL END ELSE ELIF COMMENT COLUMN AMPERSAND ACT ]
-##
-## The known suffix of the stack is as follows:
-## AMPERSAND
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT AMPERSAND EOL EOF
-##
-## Ends in an error in state: 94.
-##
-## list(EOL) -> EOL . list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## EOL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT ELSE
-##
-## Ends in an error in state: 147.
-##
-## line_statement -> instruction . nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> instruction . nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## instruction
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 13, spurious reduction of production option(delimited(L_BRACKET,option(expression),R_BRACKET)) ->
-## In state 73, spurious reduction of production variable -> IDENT option(delimited(L_BRACKET,option(expression),R_BRACKET))
-## In state 101, spurious reduction of production expression -> variable
-## In state 132, spurious reduction of production single_instruction -> expression
-## In state 104, spurious reduction of production instruction -> single_instruction
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN COMMENT STAR
-##
-## Ends in an error in state: 151.
-##
-## line_statement -> inline_action . nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> inline_action . nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## inline_action
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN IDENT AMPERSAND LOCATION_END
-##
-## Ends in an error in state: 110.
-##
-## final_inline_instruction -> inline_instruction . instruction [ EOL ELSE AMPERSAND ]
-## final_inline_instruction -> inline_instruction . inline_action [ EOL ELSE AMPERSAND ]
-## final_inline_instruction -> inline_instruction . COMMENT [ EOL ELSE AMPERSAND ]
-## final_inline_instruction -> inline_instruction . [ EOL ELSE AMPERSAND ]
-## inline_instruction -> inline_instruction . single_instruction nonempty_list(AMPERSAND) [ STAR SET PLUS OBJ NO MINUS L_PAREN LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION EOL ELSE COMMENT AMPERSAND ACT ]
-##
-## The known suffix of the stack is as follows:
-## inline_instruction
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 117, spurious reduction of production nonempty_list(AMPERSAND) -> AMPERSAND
-## In state 119, spurious reduction of production inline_instruction -> inline_instruction single_instruction nonempty_list(AMPERSAND)
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN IF STAR
-##
-## Ends in an error in state: 107.
-##
-## onliner(IF) -> IF . expression COLUMN final_inline_instruction [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## IF
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN IF INTEGER SET
-##
-## Ends in an error in state: 108.
-##
-## expression -> expression . EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . LT GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . EXCLAMATION expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . PLUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . MINUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . STAR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . DIV expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . MOD expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . AND expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . GT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . LT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . EQUAL GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . EQUAL LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . OR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## onliner(IF) -> IF expression . COLUMN final_inline_instruction [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## IF expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN ACT STAR
-##
-## Ends in an error in state: 112.
-##
-## onliner(ACT) -> ACT . expression COLUMN final_inline_instruction [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## ACT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL ACT IDENT COLUMN ACT INTEGER SET
-##
-## Ends in an error in state: 113.
-##
-## expression -> expression . EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . LT GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . EXCLAMATION expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . PLUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . MINUS expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . STAR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . DIV expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . MOD expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . AND expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . GT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . LT EQUAL expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . EQUAL GT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . EQUAL LT expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## expression -> expression . OR expression [ STAR PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL DIV COLUMN AND ]
-## onliner(ACT) -> ACT expression . COLUMN final_inline_instruction [ EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## ACT expression
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF STAR
-##
-## Ends in an error in state: 156.
-##
-## elif -> ELIF . expression COLUMN nonempty_list(EOL) list(line_statement) [ END ELSE ELIF ]
-##
-## The known suffix of the stack is as follows:
-## ELIF
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF IDENT COLUMN STAR
-##
-## Ends in an error in state: 158.
-##
-## elif -> ELIF expression COLUMN . nonempty_list(EOL) list(line_statement) [ END ELSE ELIF ]
-##
-## The known suffix of the stack is as follows:
-## ELIF expression COLUMN
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL ELIF IDENT COLUMN EOL LOCATION_END
-##
-## Ends in an error in state: 159.
-##
-## elif -> ELIF expression COLUMN nonempty_list(EOL) . list(line_statement) [ END ELSE ELIF ]
-##
-## The known suffix of the stack is as follows:
-## ELIF expression COLUMN nonempty_list(EOL)
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 7, spurious reduction of production nonempty_list(EOL) -> EOL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
main: LOCATION_START EOL IF IDENT COLUMN EOL ELSE STAR
##
## Ends in an error in state: 162.
@@ -1195,265 +321,4 @@ main: LOCATION_START EOL IF IDENT COLUMN EOL ELSE STAR
## ELSE
##
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL ELSE EOL IDENT AMPERSAND LOCATION_END
-##
-## Ends in an error in state: 166.
-##
-## line_statement -> IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body . END option(IF) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body . END option(IF) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 117, spurious reduction of production nonempty_list(AMPERSAND) -> AMPERSAND
-## In state 149, spurious reduction of production list(EOL) ->
-## In state 150, spurious reduction of production line_statement -> instruction nonempty_list(AMPERSAND) list(EOL)
-## In state 145, spurious reduction of production list(line_statement) ->
-## In state 146, spurious reduction of production list(line_statement) -> line_statement list(line_statement)
-## In state 164, spurious reduction of production else_ -> ELSE nonempty_list(EOL) list(line_statement)
-## In state 165, spurious reduction of production elif_else_body -> list(elif) else_
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL END STAR
-##
-## Ends in an error in state: 167.
-##
-## line_statement -> IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END . option(IF) nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END . option(IF) nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IF IDENT COLUMN EOL END IF STAR
-##
-## Ends in an error in state: 169.
-##
-## line_statement -> IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END option(IF) . nonempty_list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-## line_statement -> IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END option(IF) . nonempty_list(AMPERSAND) list(EOL) [ STAR SET PLUS OBJ NO MINUS L_PAREN LOCATION_END LITERAL LET KEYWORD INTEGER IF IDENT FUNCTION END ELSE ELIF COMMENT COLUMN ACT ]
-##
-## The known suffix of the stack is as follows:
-## IF expression COLUMN nonempty_list(EOL) list(line_statement) elif_else_body END option(IF)
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START STAR
-##
-## Ends in an error in state: 6.
-##
-## main -> list(before_location) LOCATION_START . nonempty_list(EOL) list(line_statement) LOCATION_END [ # ]
-##
-## The known suffix of the stack is as follows:
-## list(before_location) LOCATION_START
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL END
-##
-## Ends in an error in state: 9.
-##
-## main -> list(before_location) LOCATION_START nonempty_list(EOL) . list(line_statement) LOCATION_END [ # ]
-##
-## The known suffix of the stack is as follows:
-## list(before_location) LOCATION_START nonempty_list(EOL)
-##
-## WARNING: This example involves spurious reductions.
-## This implies that, although the LR(1) items shown above provide an
-## accurate view of the past (what has been recognized so far), they
-## may provide an INCOMPLETE view of the future (what was expected next).
-## In state 7, spurious reduction of production nonempty_list(EOL) -> EOL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL MINUS STAR
-##
-## Ends in an error in state: 25.
-##
-## expression -> unary_operator . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## unary_operator
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL KEYWORD IDENT COMA STAR
-##
-## Ends in an error in state: 61.
-##
-## arguments(expression) -> expression COMA . separated_nonempty_list(COMA,expression) [ R_PAREN EOL ELSE AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression COMA
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: COMMENT STAR
-##
-## Ends in an error in state: 2.
-##
-## before_location -> COMMENT . EOL [ LOCATION_START EOL COMMENT ]
-##
-## The known suffix of the stack is as follows:
-## COMMENT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT MOD STAR
-##
-## Ends in an error in state: 29.
-##
-## expression -> expression MOD . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression MOD
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT PLUS STAR
-##
-## Ends in an error in state: 31.
-##
-## expression -> expression PLUS . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression PLUS
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT DIV STAR
-##
-## Ends in an error in state: 33.
-##
-## expression -> expression DIV . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression DIV
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT OR STAR
-##
-## Ends in an error in state: 35.
-##
-## expression -> expression OR . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression OR
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT MINUS STAR
-##
-## Ends in an error in state: 37.
-##
-## expression -> expression MINUS . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression MINUS
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT LT GT STAR
-##
-## Ends in an error in state: 40.
-##
-## expression -> expression LT GT . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression LT GT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT EXCLAMATION STAR
-##
-## Ends in an error in state: 42.
-##
-## expression -> expression EXCLAMATION . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression EXCLAMATION
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT LT EQUAL STAR
-##
-## Ends in an error in state: 44.
-##
-## expression -> expression LT EQUAL . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression LT EQUAL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT GT EQUAL STAR
-##
-## Ends in an error in state: 47.
-##
-## expression -> expression GT EQUAL . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression GT EQUAL
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL INTEGER EQUAL LT STAR
-##
-## Ends in an error in state: 52.
-##
-## expression -> expression EQUAL LT . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression EQUAL LT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL INTEGER EQUAL GT STAR
-##
-## Ends in an error in state: 54.
-##
-## expression -> expression EQUAL GT . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression EQUAL GT
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
-
-main: LOCATION_START EOL IDENT AND STAR
-##
-## Ends in an error in state: 57.
-##
-## expression -> expression AND . expression [ STAR R_PAREN R_BRACKET PLUS OR MOD MINUS LT GT EXCLAMATION EQUAL EOL ELSE DIV COMA COLUMN AND AMPERSAND ]
-##
-## The known suffix of the stack is as follows:
-## expression AND
-##
-
-<YOUR SYNTAX ERROR MESSAGE HERE>
+Unexpected operator after `ELSE`
diff --git a/syntax/report.ml b/syntax/report.ml
index 0c7d731..9ad24c3 100644
--- a/syntax/report.ml
+++ b/syntax/report.ml
@@ -1,7 +1,7 @@
(** Report built over the differents analysis in the file *)
type level = Error | Warn | Debug
-[@@deriving show { with_path = false }, enum]
+[@@deriving show { with_path = false }, enum, eq]
type pos = Lexing.position * Lexing.position
diff --git a/test/qsp_parser_test.ml b/test/qsp_parser_test.ml
index 652ef75..cbbe91e 100644
--- a/test/qsp_parser_test.ml
+++ b/test/qsp_parser_test.ml
@@ -1,831 +1 @@
-module Parser = Qparser.Parser.Make (Qsp_syntax.Tree)
-module Tree = Qsp_syntax.Tree
-module Ast = Qsp_syntax.Tree.Ast
-module T = Ast
-
-let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
-
-type 'a location = 'a * 'a Ast.statement list [@@deriving eq, show]
-
-(** Run the parser with the given expression and return the result *)
-let parse : string -> T.pos location =
- fun content ->
- let lexing =
- Sedlexing.Latin1.from_string content |> Qparser.Lexbuf.from_lexbuf
- in
- match Qparser.Analyzer.parse (module Qsp_syntax.Tree) lexing with
- | Ok e -> e
- | Error e ->
- let msg = Format.asprintf "%a" Qsp_syntax.Report.pp e in
- raise (Failure msg)
-
-let location : T.pos location Alcotest.testable =
- let equal = equal_location (fun _ _ -> true) in
- let pp =
- pp_location (fun formater _ -> Format.fprintf formater "_position")
- in
- Alcotest.testable pp equal
-
-let test_empty_location () =
- let expected = (_position, [])
- and actual = parse {|# Location
-------- |}
- and msg = "Empty location" in
-
- Alcotest.(check' location ~msg ~expected ~actual)
-
-let test_location_without_database () =
- let expected = (_position, [])
- and actual = parse {|# $Location
-------- |}
- and msg = "Location without database" in
-
- let () = Alcotest.(check' location ~msg ~expected ~actual) in
-
- let actual = parse {|# !Location
-------- |} in
- let () = Alcotest.(check' location ~msg ~expected ~actual) in
-
- let actual = parse {|# ^Location
-------- |} in
- Alcotest.(check' location ~msg ~expected ~actual)
-
-let _test_instruction : string -> Ast.pos Ast.statement list -> unit =
- fun literal expected ->
- let expected = (_position, expected)
- and _location = Printf.sprintf {|# Location
-%s
-------- |} literal in
- let actual = parse _location and msg = literal in
-
- Alcotest.(check' location ~msg ~expected ~actual)
-
-let test_numeric_expression () =
- _test_instruction "123" [ Expression (Integer (_position, "123")) ]
-
-let test_negative_numeric_expression () =
- _test_instruction "-123"
- [ Expression (Op (_position, Neg, Integer (_position, "123"))) ]
-
-let test_negative_numeric_expression2 () =
- let index = None in
- let var = { Ast.pos = _position; name = "CURTIMESUN"; index } in
- _test_instruction "-(780-CurTimeSun)"
- Ast.
- [
- Expression
- (Op
- ( _position,
- Neg,
- BinaryOp (_position, Minus, Integer (_position, "780"), Ident var)
- ));
- ]
-
-let test_str_variable () =
- let index = None in
- let var = { Ast.pos = _position; name = "$VALUE"; index } in
- _test_instruction "$value" [ Expression (Ident var) ]
-
-let test_variable () =
- let index = None in
- let var = { Ast.pos = _position; name = "VALUE"; index } in
- _test_instruction "value" [ Expression (Ident var) ]
-
-let test_indexed_variable () =
- let index = Some Ast.(Integer (_position, "1")) in
- let var = { Ast.pos = _position; name = "VALUE"; index } in
- _test_instruction "value[1]" [ Expression (Ident var) ]
-
-let test_let_literal () =
- let index = None in
- let var = { Ast.pos = _position; name = "VALUE"; index } in
- _test_instruction "let value = '123'"
- Ast.[ Declaration (_position, var, Eq', Literal (_position, "123")) ]
-
-let test_set_array_append () =
- let var = { Ast.pos = _position; name = "$VALUE"; index = None } in
- _test_instruction "set $value[] = ''"
- Ast.[ Declaration (_position, var, Eq', Literal (_position, "")) ]
-
-let test_direct_assignation () =
- let index = None in
- let var = { T.pos = _position; name = "VALUE"; index } in
- _test_instruction "value = '123'"
- Ast.[ Declaration (_position, var, Eq', Literal (_position, "123")) ]
-
-let test_command_assignation () =
- let index = None in
- let st_1 = { Ast.pos = _position; name = "ST_1"; index } in
- _test_instruction "st_1 = input 'Enter the amount'"
- Ast.
- [
- Declaration
- ( _position,
- st_1,
- Eq',
- Function
- (_position, Input, [ Literal (_position, "Enter the amount") ]) );
- ]
-
-let test_assignation2 () =
- let index = None in
- let var = { Ast.pos = _position; name = "VALUE"; index } in
- _test_instruction "set value += 123"
- Ast.[ Declaration (_position, var, Inc, Integer (_position, "123")) ]
-
-let test_multilie_literal () =
- let index = None in
- let var = { Ast.pos = _position; name = "VALUE"; index } in
- _test_instruction {|
- value = {
-$a = '123'
-}|}
- Ast.
- [
- Declaration (_position, var, Eq', Literal (_position, "\n$a = '123'\n"));
- ]
-
-let test_nested_literal () =
- _test_instruction
- {|
- value = {
-
- {
-
- }
-}|}
- [
- Ast.Declaration
- ( _position,
- { Ast.pos = _position; name = "VALUE"; index = None },
- Qsp_syntax.T.Eq',
- Ast.Literal (_position, "\n\n {\n\n }\n") );
- ]
-
-let test_concat_literal () =
- _test_instruction {|
- '123'
- +'456'
-|}
- [
- Ast.Expression (Ast.Literal (_position, "123"));
- Ast.Expression
- (Ast.Op (_position, Qsp_syntax.T.Add, Ast.Literal (_position, "456")));
- ]
-
-let test_literal () =
- _test_instruction "'123'" [ Expression (Literal (_position, "123")) ]
-
-let test_qutoted_literal () =
- _test_instruction "'12''3'" [ Expression (Literal (_position, "12'3")) ]
-
-let test_multiline1 () =
- let content = {|
-apples = 5
-pears = 10
-|} in
-
- let index = None in
- let apples = { Ast.pos = _position; name = "APPLES"; index }
- and pears = { Ast.pos = _position; name = "PEARS"; index }
- and value_5 = Ast.Integer (_position, "5")
- and value_10 = Ast.Integer (_position, "10") in
- _test_instruction content
- Ast.
- [
- Declaration (_position, apples, Eq', value_5);
- Declaration (_position, pears, Eq', value_10);
- ]
-
-let test_multiline2 () =
- let content = "apples = 5 & pears = 10" in
-
- let index = None in
- let apples = { Ast.pos = _position; name = "APPLES"; index }
- and pears = { Ast.pos = _position; name = "PEARS"; index }
- and value_5 = Ast.Integer (_position, "5")
- and value_10 = Ast.Integer (_position, "10") in
- _test_instruction content
- [
- Declaration (_position, apples, Eq', value_5);
- Declaration (_position, pears, Eq', value_10);
- ]
-
-let test_equality () =
- let content = "apples = 5 = pears" in
- let index = None in
- let apples = { Ast.pos = _position; name = "APPLES"; index }
- and pears = { Ast.pos = _position; name = "PEARS"; index }
- and value_5 = Ast.Integer (_position, "5") in
- _test_instruction content
- [
- Declaration
- (_position, apples, Eq', BinaryOp (_position, Eq, value_5, Ident pears));
- ]
-
-let test_plus () =
- let content = {|
-apples = 5 + pears
-|} in
- let index = None in
- let apples = { Ast.pos = _position; name = "APPLES"; index }
- and pears = { Ast.pos = _position; name = "PEARS"; index }
- and value_5 = Ast.Integer (_position, "5") in
- _test_instruction content
- [
- Declaration
- ( _position,
- apples,
- Eq',
- BinaryOp (_position, Plus, value_5, Ident pears) );
- ]
-
-let test_plus_litt () =
- let content = {|
-'five'+ pears
-|} in
- let index = None in
- let pears = { Ast.pos = _position; name = "PEARS"; index } in
- _test_instruction content
- [
- Ast.(
- Expression
- (BinaryOp (_position, Plus, Literal (_position, "five"), Ident pears)));
- ]
-
-let test_concat () =
- let content = {|
-$firstName + ' ' + $lastName
-|} in
- _test_instruction content
- [
- Tree.Ast.Expression
- (Tree.Ast.BinaryOp
- ( _position,
- Plus,
- Tree.Ast.BinaryOp
- ( _position,
- Plus,
- Tree.Ast.Ident
- {
- Tree.Ast.pos = _position;
- name = "$FIRSTNAME";
- index = None;
- },
- Tree.Ast.Literal (_position, " ") ),
- Tree.Ast.Ident
- { Tree.Ast.pos = _position; name = "$LASTNAME"; index = None } ));
- ]
-
-let test_comment () = _test_instruction "! Comment" [ Comment _position ]
-
-let test_comment2 () =
- let index = None in
- let a = { Ast.pos = _position; name = "A"; index }
- and value_0 = Ast.Integer (_position, "0") in
- _test_instruction "a = 0 &! Comment"
- Ast.[ Declaration (_position, a, Eq', value_0); Comment _position ]
-
-let test_comment3 () = _test_instruction {|!!1234
- |} [ Comment _position ]
-
-(** The exclamation mark here is an operation and not a comment *)
-let test_comment4 () =
- let index = None in
- let a = { Ast.pos = _position; name = "A"; index }
- and value_0 = Ast.Integer (_position, "0") in
- _test_instruction "a = rand(0, 1) ! 0"
- [
- Ast.(
- Declaration
- ( _position,
- a,
- Eq',
- BinaryOp
- ( _position,
- Neq,
- Function
- ( _position,
- Rand,
- [ Integer (_position, "0"); Integer (_position, "1") ] ),
- value_0 ) ));
- ]
-
-let test_comment5 () =
- _test_instruction "a = rand() &! Comment"
- [
- Ast.Declaration
- ( _position,
- { Ast.pos = _position; name = "A"; index = None },
- Qsp_syntax.T.Eq',
- Ast.Function (_position, Rand, []) );
- Ast.Comment _position;
- ]
-
-let test_comment6 () =
- _test_instruction
- "gs 'stat' &!! It should be here, because some of the strigs have to be \
- initialized"
- [
- Ast.Call (_position, "GOSUB", [ Ast.Literal (_position, "stat") ]);
- Ast.Comment _position;
- ]
-
-let test_long_comment () =
- _test_instruction
- {| !'this part of the comment is inside
-single quotes' but "this is still part
-of the same comment because sometimes
-life is unfair." Oh yeah, {curly brackets
-also count}. This is still the same comment. |}
- [ Comment _position ]
-
-(** This test ensure that the unary operator is applied to the whole expression
- *)
-let test_precedence () =
- let index = None in
- let x = Ast.Ident { Ast.pos = _position; name = "X"; index }
- and y = Ast.Ident { Ast.pos = _position; name = "Y"; index } in
- _test_instruction "no x = y"
- Ast.[ Expression (Op (_position, No, BinaryOp (_position, Eq, x, y))) ]
-
-(** This test ensure that a ! is not considered as a comment in an
- expression *)
-let test_precedence2 () =
- let index = None in
- let x = { Ast.pos = _position; name = "X"; index }
- and y = Ast.Ident { Ast.pos = _position; name = "Y"; index } in
- _test_instruction "x = y ! 0"
- Ast.
- [
- Declaration
- ( _position,
- x,
- Eq',
- BinaryOp (_position, Neq, y, Integer (_position, "0")) );
- ]
-
-let test_if () =
- let index = Some Ast.(Integer (_position, "0")) in
- let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
- and expr1 = Ast.(Literal (_position, "blockA"))
- and expr2 = Ast.(Expression (Literal (_position, "You are in block A"))) in
- _test_instruction {| if $ARGS[0] = 'blockA':
- 'You are in block A'
-end |}
- Ast.
- [
- If
- {
- loc = _position;
- then_ = (_position, BinaryOp (_position, Eq, args, expr1), [ expr2 ]);
- elifs = [];
- else_ = [];
- };
- ]
-
-let test_if2 () =
- let index = Some Ast.(Integer (_position, "0")) in
- let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
- and expr1 = Ast.(Literal (_position, "blockA"))
- and expr2 = Ast.(Expression (Literal (_position, "You are in block A"))) in
- _test_instruction {| if $ARGS[0] = 'blockA':
- 'You are in block A'
-end if|}
- Ast.
- [
- If
- {
- loc = _position;
- then_ = (_position, BinaryOp (_position, Eq, args, expr1), [ expr2 ]);
- elifs = [];
- else_ = [];
- };
- ]
-
-let test_if_chained () =
- let value_0 = Ast.Integer (_position, "0") in
- _test_instruction {| if 0:
- 0
-end &! -- |}
- Ast.
- [
- If
- {
- loc = _position;
- then_ = (_position, value_0, [ Expression value_0 ]);
- elifs = [];
- else_ = [];
- };
- Comment _position;
- ]
-
-let test_if_equality () =
- _test_instruction {|
-if 0 = 0:
-end &! --
-|}
- [
- Ast.If
- {
- loc = _position;
- then_ =
- ( _position,
- Ast.BinaryOp
- ( _position,
- Qsp_syntax.T.Eq,
- Ast.Integer (_position, "0"),
- Ast.Integer (_position, "0") ),
- [] );
- elifs = [];
- else_ = [];
- };
- Ast.Comment _position;
- ]
-
-let test_if_inline () =
- let value_0 = Ast.Integer (_position, "0") in
- _test_instruction "if 0: 0 else 0"
- Ast.
- [
- If
- {
- loc = _position;
- then_ = (_position, value_0, [ Expression value_0 ]);
- elifs = [];
- else_ = [ Expression value_0 ];
- };
- ]
-
-let test_if_inline_comment () =
- let value_0 = Ast.Integer (_position, "0") in
- _test_instruction "if 0: 0 else 0 &! comment "
- Ast.
- [
- If
- {
- loc = _position;
- then_ = (_position, value_0, [ Expression value_0 ]);
- elifs = [];
- else_ = [ Expression value_0 ];
- };
- Comment _position;
- ]
-
-let test_if_inline_comment2 () =
- _test_instruction "if 0: 1 & !! Comment"
- [
- Ast.If
- {
- loc = _position;
- then_ =
- ( _position,
- Ast.Integer (_position, "0"),
- [
- Ast.Expression (Ast.Integer (_position, "1"));
- Ast.Comment _position;
- ] );
- elifs = [];
- else_ = [];
- };
- ]
-
-let test_if_inline_act () =
- _test_instruction "if 1 and hour >= 8: minut += 1 & act 'go': gt 'go'"
- [
- Ast.If
- {
- loc = _position;
- then_ =
- ( _position,
- Ast.BinaryOp
- ( _position,
- Qsp_syntax.T.And,
- Ast.Integer (_position, "1"),
- Ast.BinaryOp
- ( _position,
- Qsp_syntax.T.Gte,
- Ast.Ident
- { Ast.pos = _position; name = "HOUR"; index = None },
- Ast.Integer (_position, "8") ) ),
- [
- Ast.Declaration
- ( _position,
- { Ast.pos = _position; name = "MINUT"; index = None },
- Qsp_syntax.T.Inc,
- Ast.Integer (_position, "1") );
- Ast.Act
- {
- loc = _position;
- label = Ast.Literal (_position, "go");
- statements =
- [
- Ast.Call
- (_position, "GOTO", [ Ast.Literal (_position, "go") ]);
- ];
- };
- ] );
- elifs = [];
- else_ = [];
- };
- ]
-
-let test_if_inline_act2 () =
- _test_instruction "if 1: act 'go': gt 'go' &! comment "
- [
- Ast.If
- {
- loc = _position;
- then_ =
- ( _position,
- Ast.Integer (_position, "1"),
- [
- Ast.Act
- {
- loc = _position;
- label = Ast.Literal (_position, "go");
- statements =
- [
- Ast.Call
- (_position, "GOTO", [ Ast.Literal (_position, "go") ]);
- Ast.Comment _position;
- ];
- };
- ] );
- elifs = [];
- else_ = [];
- };
- ]
-
-let test_precedence3 () =
- let index = Some Ast.(Integer (_position, "0")) in
- let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
- and expr1 = Ast.(Literal (_position, "blockA"))
- and expr2 = Ast.(Expression (Literal (_position, "You are in block A")))
- and expr3 = Ast.(Expression (Integer (_position, "0"))) in
- _test_instruction {| if $ARGS[0] = 'blockA': 'You are in block A' & 0|}
- Ast.
- [
- If
- {
- loc = _position;
- then_ =
- ( _position,
- BinaryOp (_position, Eq, args, expr1),
- [ expr2; expr3 ] );
- elifs = [];
- else_ = [];
- };
- ]
-
-let test_gs () =
- _test_instruction "gs '123'"
- [ Ast.(Call (_position, "GOSUB", [ Literal (_position, "123") ])) ]
-
-let test_gt () =
- _test_instruction "gt $curloc"
- [
- Ast.Call
- ( _position,
- "GOTO",
- [ Ast.Ident { Ast.pos = _position; name = "$CURLOC"; index = None } ]
- );
- ]
-
-let test_nl () =
- _test_instruction "*NL 'It'"
- [ Ast.Call (_position, "*NL", [ Ast.Literal (_position, "It") ]) ]
-
-let test_function () =
- _test_instruction "iif(123, 1, 0)"
- [
- Ast.(
- Expression
- (Function
- ( _position,
- Iif,
- [
- Integer (_position, "123");
- Integer (_position, "1");
- Integer (_position, "0");
- ] )));
- ]
-
-(** Include a space before the parameters *)
-let test_function2 () =
- _test_instruction "rand (0, 1)"
- [
- Ast.(
- Expression
- (Function
- ( _position,
- Rand,
- [ Integer (_position, "0"); Integer (_position, "1") ] )));
- ]
-
-let test_precedence4 () =
- _test_instruction "trim()" Ast.[ Expression (Function (_position, Trim, [])) ]
-
-(** This should not be a keyword without arguments, followed by an expression *)
-let test_precedence5 () =
- _test_instruction "clear()" Ast.[ Call (_position, "CLEAR", []) ]
-
-let test_precedence6 () =
- _test_instruction "(1 = 0 and 2 ! 3)"
- [
- Ast.Expression
- (Ast.BinaryOp
- ( _position,
- And,
- Ast.BinaryOp
- ( _position,
- Eq,
- Ast.Integer (_position, "1"),
- Ast.Integer (_position, "0") ),
- Ast.BinaryOp
- ( _position,
- Neq,
- Ast.Integer (_position, "2"),
- Ast.Integer (_position, "3") ) ));
- ]
-
-(** An identifier cannot start by a number *0 is a product and not an
- identifier *)
-let test_operator () =
- let index = None in
- let a = { Ast.pos = _position; name = "A"; index }
- and value_0 = Ast.Integer (_position, "0") in
- _test_instruction "a *0"
- Ast.[ Expression (BinaryOp (_position, Product, Ident a, value_0)) ]
-
-let test_operator2 () =
- let value_0 = Ast.Integer (_position, "0") in
- _test_instruction "0 *rand()"
- Ast.
- [
- Expression
- (BinaryOp (_position, Product, value_0, Function (_position, Rand, [])));
- ]
-
-let test_dyneval () =
- _test_instruction "dyneval ''"
- [
- Ast.Expression
- (Ast.Function (_position, Dyneval, [ Ast.Literal (_position, "") ]));
- ]
-
-(** The parens after input are considered as arguments for the function, not a
- following expression.
-
- This expression is a boolean.
-*)
-let test_input () =
- _test_instruction "( input('') = '' )"
- [
- Tree.Ast.Expression
- (Tree.Ast.BinaryOp
- ( _position,
- Eq,
- Tree.Ast.Function
- (_position, Input, [ Tree.Ast.Literal (_position, "") ]),
- Tree.Ast.Literal (_position, "") ));
- ]
-
-let test_mutiple_inline_ifs () =
- _test_instruction "if 1 > 0: 1 else if 1 < 0: 0"
- [
- Tree.Ast.If
- {
- loc = _position;
- then_ =
- ( _position,
- Tree.Ast.BinaryOp
- ( _position,
- Gt,
- Tree.Ast.Integer (_position, "1"),
- Tree.Ast.Integer (_position, "0") ),
- [ Tree.Ast.Expression (Tree.Ast.Integer (_position, "1")) ] );
- elifs = [];
- else_ =
- [
- Tree.Ast.If
- {
- loc = _position;
- then_ =
- ( _position,
- Tree.Ast.BinaryOp
- ( _position,
- Lt,
- Tree.Ast.Integer (_position, "1"),
- Tree.Ast.Integer (_position, "0") ),
- [
- Tree.Ast.Expression (Tree.Ast.Integer (_position, "0"));
- ] );
- elifs = [];
- else_ = [];
- };
- ];
- };
- ]
-
-let test_precedence7 () =
- _test_instruction "(1 + 1 = '')"
- [
- Tree.Ast.Expression
- (Tree.Ast.BinaryOp
- ( _position,
- Eq,
- Tree.Ast.BinaryOp
- ( _position,
- Plus,
- Tree.Ast.Integer (_position, "1"),
- Tree.Ast.Integer (_position, "1") ),
- Tree.Ast.Literal (_position, "") ));
- ]
-
-let test_precedence8 () =
- _test_instruction "(0 = 1 or 0 = 1)"
- [
- Tree.Ast.Expression
- (Tree.Ast.BinaryOp
- ( _position,
- Or,
- Tree.Ast.BinaryOp
- ( _position,
- Eq,
- Tree.Ast.Integer (_position, "0"),
- Tree.Ast.Integer (_position, "1") ),
- Tree.Ast.BinaryOp
- ( _position,
- Eq,
- Tree.Ast.Integer (_position, "0"),
- Tree.Ast.Integer (_position, "1") ) ));
- ]
-
-let syntax =
- ( "Syntax",
- [
- Alcotest.test_case "Location" `Quick test_empty_location;
- Alcotest.test_case "Location" `Quick test_location_without_database;
- Alcotest.test_case " Numeric expression" `Quick test_numeric_expression;
- Alcotest.test_case "-Numeric expression" `Quick
- test_negative_numeric_expression;
- Alcotest.test_case "-Numeric expression2" `Quick
- test_negative_numeric_expression2;
- Alcotest.test_case "$Variable expression" `Quick test_str_variable;
- Alcotest.test_case " Variable expression" `Quick test_variable;
- Alcotest.test_case "Indexed Variable expression" `Quick
- test_indexed_variable;
- Alcotest.test_case "Let instruction" `Quick test_let_literal;
- Alcotest.test_case "Set array_append" `Quick test_set_array_append;
- Alcotest.test_case "Variable_assignation" `Quick test_direct_assignation;
- Alcotest.test_case "Command assignation" `Quick test_command_assignation;
- Alcotest.test_case "Variable_assignation2" `Quick test_assignation2;
- Alcotest.test_case "Literal" `Quick test_literal;
- Alcotest.test_case "Literal2" `Quick test_qutoted_literal;
- Alcotest.test_case "Literal3" `Quick test_multilie_literal;
- Alcotest.test_case "Concat Literal" `Quick test_concat_literal;
- Alcotest.test_case "Nested Literal" `Quick test_nested_literal;
- Alcotest.test_case "Multiline1" `Quick test_multiline1;
- Alcotest.test_case "Multiline2" `Quick test_multiline2;
- Alcotest.test_case "Equality" `Quick test_equality;
- Alcotest.test_case "Plus" `Quick test_plus;
- Alcotest.test_case "Plus_litt" `Quick test_plus_litt;
- Alcotest.test_case "PlusChained" `Quick test_concat;
- Alcotest.test_case "Comment" `Quick test_comment;
- Alcotest.test_case "Comment2" `Quick test_comment2;
- Alcotest.test_case "Comment3" `Quick test_comment3;
- Alcotest.test_case "Comment4" `Quick test_comment4;
- Alcotest.test_case "Comment5" `Quick test_comment5;
- Alcotest.test_case "Comment6" `Quick test_comment6;
- Alcotest.test_case "Multiline Comment" `Quick test_long_comment;
- Alcotest.test_case "If" `Quick test_if;
- Alcotest.test_case "If - end if" `Quick test_if2;
- Alcotest.test_case "If_chained" `Quick test_if_chained;
- Alcotest.test_case "If_equality" `Quick test_if_equality;
- Alcotest.test_case "If inline" `Quick test_if_inline;
- Alcotest.test_case "If inline &!" `Quick test_if_inline_comment;
- Alcotest.test_case "If inline & !!" `Quick test_if_inline_comment2;
- Alcotest.test_case "If : act" `Quick test_if_inline_act;
- Alcotest.test_case "If : act: &!" `Quick test_if_inline_act2;
- Alcotest.test_case "Precedence1" `Quick test_precedence;
- Alcotest.test_case "Precedence2" `Quick test_precedence2;
- Alcotest.test_case "Precedence3" `Quick test_precedence3;
- Alcotest.test_case "Call gs" `Quick test_gs;
- Alcotest.test_case "Call gt" `Quick test_gt;
- Alcotest.test_case "Call nl" `Quick test_nl;
- Alcotest.test_case "Function iif" `Quick test_function;
- Alcotest.test_case "Function rand" `Quick test_function2;
- Alcotest.test_case "Precedence4" `Quick test_precedence4;
- Alcotest.test_case "Precedence5" `Quick test_precedence5;
- Alcotest.test_case "Precedence6" `Quick test_precedence6;
- Alcotest.test_case "Operator" `Quick test_operator;
- Alcotest.test_case "Operator2" `Quick test_operator2;
- Alcotest.test_case "Dyneval" `Quick test_dyneval;
- Alcotest.test_case "Input" `Quick test_input;
- Alcotest.test_case "inline if else if" `Quick test_mutiple_inline_ifs;
- Alcotest.test_case "Precedence7" `Quick test_precedence7;
- Alcotest.test_case "Precedence8" `Quick test_precedence8;
- ] )
-
-let () = Alcotest.run "qsp_parser" [ syntax ]
+let () = Alcotest.run "qsp_parser" [ Syntax.test; Syntax_error.test ]
diff --git a/test/syntax.ml b/test/syntax.ml
new file mode 100644
index 0000000..8c6334e
--- /dev/null
+++ b/test/syntax.ml
@@ -0,0 +1,832 @@
+module Parser = Qparser.Parser.Make (Qsp_syntax.Tree)
+module Tree = Qsp_syntax.Tree
+module Ast = Qsp_syntax.Tree.Ast
+module T = Ast
+
+let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
+
+type 'a location = 'a * 'a Ast.statement list [@@deriving eq, show]
+
+let get_location :
+ (T.pos location, Qsp_syntax.Report.t) result -> T.pos location = function
+ | Ok e -> e
+ | Error e ->
+ let msg = Format.asprintf "%a" Qsp_syntax.Report.pp e in
+ raise (Failure msg)
+
+(** Run the parser with the given expression and return the result *)
+let parse : string -> (T.pos location, Qsp_syntax.Report.t) result =
+ fun content ->
+ let lexing =
+ Sedlexing.Latin1.from_string content |> Qparser.Lexbuf.from_lexbuf
+ in
+ Qparser.Analyzer.parse (module Qsp_syntax.Tree) lexing
+
+let location : T.pos location Alcotest.testable =
+ let equal = equal_location (fun _ _ -> true) in
+ let pp =
+ pp_location (fun formater _ -> Format.fprintf formater "_position")
+ in
+ Alcotest.testable pp equal
+
+let test_empty_location () =
+ let expected = (_position, [])
+ and actual = get_location @@ parse {|# Location
+------- |}
+ and msg = "Empty location" in
+
+ Alcotest.(check' location ~msg ~expected ~actual)
+
+let test_location_without_database () =
+ let expected = (_position, [])
+ and actual = get_location @@ parse {|# $Location
+------- |}
+ and msg = "Location without database" in
+
+ let () = Alcotest.(check' location ~msg ~expected ~actual) in
+
+ let actual = get_location @@ parse {|# !Location
+------- |} in
+ let () = Alcotest.(check' location ~msg ~expected ~actual) in
+
+ let actual = get_location @@ parse {|# ^Location
+------- |} in
+ Alcotest.(check' location ~msg ~expected ~actual)
+
+let _test_instruction : string -> Ast.pos Ast.statement list -> unit =
+ fun literal expected ->
+ let expected = (_position, expected)
+ and _location = Printf.sprintf {|# Location
+%s
+------- |} literal in
+ let actual = get_location @@ parse _location and msg = literal in
+
+ Alcotest.(check' location ~msg ~expected ~actual)
+
+let test_numeric_expression () =
+ _test_instruction "123" [ Expression (Integer (_position, "123")) ]
+
+let test_negative_numeric_expression () =
+ _test_instruction "-123"
+ [ Expression (Op (_position, Neg, Integer (_position, "123"))) ]
+
+let test_negative_numeric_expression2 () =
+ let index = None in
+ let var = { Ast.pos = _position; name = "CURTIMESUN"; index } in
+ _test_instruction "-(780-CurTimeSun)"
+ Ast.
+ [
+ Expression
+ (Op
+ ( _position,
+ Neg,
+ BinaryOp (_position, Minus, Integer (_position, "780"), Ident var)
+ ));
+ ]
+
+let test_str_variable () =
+ let index = None in
+ let var = { Ast.pos = _position; name = "$VALUE"; index } in
+ _test_instruction "$value" [ Expression (Ident var) ]
+
+let test_variable () =
+ let index = None in
+ let var = { Ast.pos = _position; name = "VALUE"; index } in
+ _test_instruction "value" [ Expression (Ident var) ]
+
+let test_indexed_variable () =
+ let index = Some Ast.(Integer (_position, "1")) in
+ let var = { Ast.pos = _position; name = "VALUE"; index } in
+ _test_instruction "value[1]" [ Expression (Ident var) ]
+
+let test_let_literal () =
+ let index = None in
+ let var = { Ast.pos = _position; name = "VALUE"; index } in
+ _test_instruction "let value = '123'"
+ Ast.[ Declaration (_position, var, Eq', Literal (_position, "123")) ]
+
+let test_set_array_append () =
+ let var = { Ast.pos = _position; name = "$VALUE"; index = None } in
+ _test_instruction "set $value[] = ''"
+ Ast.[ Declaration (_position, var, Eq', Literal (_position, "")) ]
+
+let test_direct_assignation () =
+ let index = None in
+ let var = { T.pos = _position; name = "VALUE"; index } in
+ _test_instruction "value = '123'"
+ Ast.[ Declaration (_position, var, Eq', Literal (_position, "123")) ]
+
+let test_command_assignation () =
+ let index = None in
+ let st_1 = { Ast.pos = _position; name = "ST_1"; index } in
+ _test_instruction "st_1 = input 'Enter the amount'"
+ Ast.
+ [
+ Declaration
+ ( _position,
+ st_1,
+ Eq',
+ Function
+ (_position, Input, [ Literal (_position, "Enter the amount") ]) );
+ ]
+
+let test_assignation2 () =
+ let index = None in
+ let var = { Ast.pos = _position; name = "VALUE"; index } in
+ _test_instruction "set value += 123"
+ Ast.[ Declaration (_position, var, Inc, Integer (_position, "123")) ]
+
+let test_multilie_literal () =
+ let index = None in
+ let var = { Ast.pos = _position; name = "VALUE"; index } in
+ _test_instruction {|
+ value = {
+$a = '123'
+}|}
+ Ast.
+ [
+ Declaration (_position, var, Eq', Literal (_position, "\n$a = '123'\n"));
+ ]
+
+let test_nested_literal () =
+ _test_instruction
+ {|
+ value = {
+
+ {
+
+ }
+}|}
+ [
+ Ast.Declaration
+ ( _position,
+ { Ast.pos = _position; name = "VALUE"; index = None },
+ Qsp_syntax.T.Eq',
+ Ast.Literal (_position, "\n\n {\n\n }\n") );
+ ]
+
+let test_concat_literal () =
+ _test_instruction {|
+ '123'
+ +'456'
+|}
+ [
+ Ast.Expression (Ast.Literal (_position, "123"));
+ Ast.Expression
+ (Ast.Op (_position, Qsp_syntax.T.Add, Ast.Literal (_position, "456")));
+ ]
+
+let test_literal () =
+ _test_instruction "'123'" [ Expression (Literal (_position, "123")) ]
+
+let test_qutoted_literal () =
+ _test_instruction "'12''3'" [ Expression (Literal (_position, "12'3")) ]
+
+let test_multiline1 () =
+ let content = {|
+apples = 5
+pears = 10
+|} in
+
+ let index = None in
+ let apples = { Ast.pos = _position; name = "APPLES"; index }
+ and pears = { Ast.pos = _position; name = "PEARS"; index }
+ and value_5 = Ast.Integer (_position, "5")
+ and value_10 = Ast.Integer (_position, "10") in
+ _test_instruction content
+ Ast.
+ [
+ Declaration (_position, apples, Eq', value_5);
+ Declaration (_position, pears, Eq', value_10);
+ ]
+
+let test_multiline2 () =
+ let content = "apples = 5 & pears = 10" in
+
+ let index = None in
+ let apples = { Ast.pos = _position; name = "APPLES"; index }
+ and pears = { Ast.pos = _position; name = "PEARS"; index }
+ and value_5 = Ast.Integer (_position, "5")
+ and value_10 = Ast.Integer (_position, "10") in
+ _test_instruction content
+ [
+ Declaration (_position, apples, Eq', value_5);
+ Declaration (_position, pears, Eq', value_10);
+ ]
+
+let test_equality () =
+ let content = "apples = 5 = pears" in
+ let index = None in
+ let apples = { Ast.pos = _position; name = "APPLES"; index }
+ and pears = { Ast.pos = _position; name = "PEARS"; index }
+ and value_5 = Ast.Integer (_position, "5") in
+ _test_instruction content
+ [
+ Declaration
+ (_position, apples, Eq', BinaryOp (_position, Eq, value_5, Ident pears));
+ ]
+
+let test_plus () =
+ let content = {|
+apples = 5 + pears
+|} in
+ let index = None in
+ let apples = { Ast.pos = _position; name = "APPLES"; index }
+ and pears = { Ast.pos = _position; name = "PEARS"; index }
+ and value_5 = Ast.Integer (_position, "5") in
+ _test_instruction content
+ [
+ Declaration
+ ( _position,
+ apples,
+ Eq',
+ BinaryOp (_position, Plus, value_5, Ident pears) );
+ ]
+
+let test_plus_litt () =
+ let content = {|
+'five'+ pears
+|} in
+ let index = None in
+ let pears = { Ast.pos = _position; name = "PEARS"; index } in
+ _test_instruction content
+ [
+ Ast.(
+ Expression
+ (BinaryOp (_position, Plus, Literal (_position, "five"), Ident pears)));
+ ]
+
+let test_concat () =
+ let content = {|
+$firstName + ' ' + $lastName
+|} in
+ _test_instruction content
+ [
+ Tree.Ast.Expression
+ (Tree.Ast.BinaryOp
+ ( _position,
+ Plus,
+ Tree.Ast.BinaryOp
+ ( _position,
+ Plus,
+ Tree.Ast.Ident
+ {
+ Tree.Ast.pos = _position;
+ name = "$FIRSTNAME";
+ index = None;
+ },
+ Tree.Ast.Literal (_position, " ") ),
+ Tree.Ast.Ident
+ { Tree.Ast.pos = _position; name = "$LASTNAME"; index = None } ));
+ ]
+
+let test_comment () = _test_instruction "! Comment" [ Comment _position ]
+
+let test_comment2 () =
+ let index = None in
+ let a = { Ast.pos = _position; name = "A"; index }
+ and value_0 = Ast.Integer (_position, "0") in
+ _test_instruction "a = 0 &! Comment"
+ Ast.[ Declaration (_position, a, Eq', value_0); Comment _position ]
+
+let test_comment3 () = _test_instruction {|!!1234
+ |} [ Comment _position ]
+
+(** The exclamation mark here is an operation and not a comment *)
+let test_comment4 () =
+ let index = None in
+ let a = { Ast.pos = _position; name = "A"; index }
+ and value_0 = Ast.Integer (_position, "0") in
+ _test_instruction "a = rand(0, 1) ! 0"
+ [
+ Ast.(
+ Declaration
+ ( _position,
+ a,
+ Eq',
+ BinaryOp
+ ( _position,
+ Neq,
+ Function
+ ( _position,
+ Rand,
+ [ Integer (_position, "0"); Integer (_position, "1") ] ),
+ value_0 ) ));
+ ]
+
+let test_comment5 () =
+ _test_instruction "a = rand() &! Comment"
+ [
+ Ast.Declaration
+ ( _position,
+ { Ast.pos = _position; name = "A"; index = None },
+ Qsp_syntax.T.Eq',
+ Ast.Function (_position, Rand, []) );
+ Ast.Comment _position;
+ ]
+
+let test_comment6 () =
+ _test_instruction
+ "gs 'stat' &!! It should be here, because some of the strigs have to be \
+ initialized"
+ [
+ Ast.Call (_position, "GOSUB", [ Ast.Literal (_position, "stat") ]);
+ Ast.Comment _position;
+ ]
+
+let test_long_comment () =
+ _test_instruction
+ {| !'this part of the comment is inside
+single quotes' but "this is still part
+of the same comment because sometimes
+life is unfair." Oh yeah, {curly brackets
+also count}. This is still the same comment. |}
+ [ Comment _position ]
+
+(** This test ensure that the unary operator is applied to the whole expression
+ *)
+let test_precedence () =
+ let index = None in
+ let x = Ast.Ident { Ast.pos = _position; name = "X"; index }
+ and y = Ast.Ident { Ast.pos = _position; name = "Y"; index } in
+ _test_instruction "no x = y"
+ Ast.[ Expression (Op (_position, No, BinaryOp (_position, Eq, x, y))) ]
+
+(** This test ensure that a ! is not considered as a comment in an
+ expression *)
+let test_precedence2 () =
+ let index = None in
+ let x = { Ast.pos = _position; name = "X"; index }
+ and y = Ast.Ident { Ast.pos = _position; name = "Y"; index } in
+ _test_instruction "x = y ! 0"
+ Ast.
+ [
+ Declaration
+ ( _position,
+ x,
+ Eq',
+ BinaryOp (_position, Neq, y, Integer (_position, "0")) );
+ ]
+
+let test_if () =
+ let index = Some Ast.(Integer (_position, "0")) in
+ let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
+ and expr1 = Ast.(Literal (_position, "blockA"))
+ and expr2 = Ast.(Expression (Literal (_position, "You are in block A"))) in
+ _test_instruction {| if $ARGS[0] = 'blockA':
+ 'You are in block A'
+end |}
+ Ast.
+ [
+ If
+ {
+ loc = _position;
+ then_ = (_position, BinaryOp (_position, Eq, args, expr1), [ expr2 ]);
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
+let test_if2 () =
+ let index = Some Ast.(Integer (_position, "0")) in
+ let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
+ and expr1 = Ast.(Literal (_position, "blockA"))
+ and expr2 = Ast.(Expression (Literal (_position, "You are in block A"))) in
+ _test_instruction {| if $ARGS[0] = 'blockA':
+ 'You are in block A'
+end if|}
+ Ast.
+ [
+ If
+ {
+ loc = _position;
+ then_ = (_position, BinaryOp (_position, Eq, args, expr1), [ expr2 ]);
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
+let test_if_chained () =
+ let value_0 = Ast.Integer (_position, "0") in
+ _test_instruction {| if 0:
+ 0
+end &! -- |}
+ Ast.
+ [
+ If
+ {
+ loc = _position;
+ then_ = (_position, value_0, [ Expression value_0 ]);
+ elifs = [];
+ else_ = [];
+ };
+ Comment _position;
+ ]
+
+let test_if_equality () =
+ _test_instruction {|
+if 0 = 0:
+end &! --
+|}
+ [
+ Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Ast.BinaryOp
+ ( _position,
+ Qsp_syntax.T.Eq,
+ Ast.Integer (_position, "0"),
+ Ast.Integer (_position, "0") ),
+ [] );
+ elifs = [];
+ else_ = [];
+ };
+ Ast.Comment _position;
+ ]
+
+let test_if_inline () =
+ let value_0 = Ast.Integer (_position, "0") in
+ _test_instruction "if 0: 0 else 0"
+ Ast.
+ [
+ If
+ {
+ loc = _position;
+ then_ = (_position, value_0, [ Expression value_0 ]);
+ elifs = [];
+ else_ = [ Expression value_0 ];
+ };
+ ]
+
+let test_if_inline_comment () =
+ let value_0 = Ast.Integer (_position, "0") in
+ _test_instruction "if 0: 0 else 0 &! comment "
+ Ast.
+ [
+ If
+ {
+ loc = _position;
+ then_ = (_position, value_0, [ Expression value_0 ]);
+ elifs = [];
+ else_ = [ Expression value_0 ];
+ };
+ Comment _position;
+ ]
+
+let test_if_inline_comment2 () =
+ _test_instruction "if 0: 1 & !! Comment"
+ [
+ Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Ast.Integer (_position, "0"),
+ [
+ Ast.Expression (Ast.Integer (_position, "1"));
+ Ast.Comment _position;
+ ] );
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
+let test_if_inline_act () =
+ _test_instruction "if 1 and hour >= 8: minut += 1 & act 'go': gt 'go'"
+ [
+ Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Ast.BinaryOp
+ ( _position,
+ Qsp_syntax.T.And,
+ Ast.Integer (_position, "1"),
+ Ast.BinaryOp
+ ( _position,
+ Qsp_syntax.T.Gte,
+ Ast.Ident
+ { Ast.pos = _position; name = "HOUR"; index = None },
+ Ast.Integer (_position, "8") ) ),
+ [
+ Ast.Declaration
+ ( _position,
+ { Ast.pos = _position; name = "MINUT"; index = None },
+ Qsp_syntax.T.Inc,
+ Ast.Integer (_position, "1") );
+ Ast.Act
+ {
+ loc = _position;
+ label = Ast.Literal (_position, "go");
+ statements =
+ [
+ Ast.Call
+ (_position, "GOTO", [ Ast.Literal (_position, "go") ]);
+ ];
+ };
+ ] );
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
+let test_if_inline_act2 () =
+ _test_instruction "if 1: act 'go': gt 'go' &! comment "
+ [
+ Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Ast.Integer (_position, "1"),
+ [
+ Ast.Act
+ {
+ loc = _position;
+ label = Ast.Literal (_position, "go");
+ statements =
+ [
+ Ast.Call
+ (_position, "GOTO", [ Ast.Literal (_position, "go") ]);
+ Ast.Comment _position;
+ ];
+ };
+ ] );
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
+let test_precedence3 () =
+ let index = Some Ast.(Integer (_position, "0")) in
+ let args = Ast.(Ident { pos = _position; name = "$ARGS"; index })
+ and expr1 = Ast.(Literal (_position, "blockA"))
+ and expr2 = Ast.(Expression (Literal (_position, "You are in block A")))
+ and expr3 = Ast.(Expression (Integer (_position, "0"))) in
+ _test_instruction {| if $ARGS[0] = 'blockA': 'You are in block A' & 0|}
+ Ast.
+ [
+ If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ BinaryOp (_position, Eq, args, expr1),
+ [ expr2; expr3 ] );
+ elifs = [];
+ else_ = [];
+ };
+ ]
+
+let test_gs () =
+ _test_instruction "gs '123'"
+ [ Ast.(Call (_position, "GOSUB", [ Literal (_position, "123") ])) ]
+
+let test_gt () =
+ _test_instruction "gt $curloc"
+ [
+ Ast.Call
+ ( _position,
+ "GOTO",
+ [ Ast.Ident { Ast.pos = _position; name = "$CURLOC"; index = None } ]
+ );
+ ]
+
+let test_nl () =
+ _test_instruction "*NL 'It'"
+ [ Ast.Call (_position, "*NL", [ Ast.Literal (_position, "It") ]) ]
+
+let test_function () =
+ _test_instruction "iif(123, 1, 0)"
+ [
+ Ast.(
+ Expression
+ (Function
+ ( _position,
+ Iif,
+ [
+ Integer (_position, "123");
+ Integer (_position, "1");
+ Integer (_position, "0");
+ ] )));
+ ]
+
+(** Include a space before the parameters *)
+let test_function2 () =
+ _test_instruction "rand (0, 1)"
+ [
+ Ast.(
+ Expression
+ (Function
+ ( _position,
+ Rand,
+ [ Integer (_position, "0"); Integer (_position, "1") ] )));
+ ]
+
+let test_precedence4 () =
+ _test_instruction "trim()" Ast.[ Expression (Function (_position, Trim, [])) ]
+
+(** This should not be a keyword without arguments, followed by an expression *)
+let test_precedence5 () =
+ _test_instruction "clear()" Ast.[ Call (_position, "CLEAR", []) ]
+
+let test_precedence6 () =
+ _test_instruction "(1 = 0 and 2 ! 3)"
+ [
+ Ast.Expression
+ (Ast.BinaryOp
+ ( _position,
+ And,
+ Ast.BinaryOp
+ ( _position,
+ Eq,
+ Ast.Integer (_position, "1"),
+ Ast.Integer (_position, "0") ),
+ Ast.BinaryOp
+ ( _position,
+ Neq,
+ Ast.Integer (_position, "2"),
+ Ast.Integer (_position, "3") ) ));
+ ]
+
+(** An identifier cannot start by a number *0 is a product and not an
+ identifier *)
+let test_operator () =
+ let index = None in
+ let a = { Ast.pos = _position; name = "A"; index }
+ and value_0 = Ast.Integer (_position, "0") in
+ _test_instruction "a *0"
+ Ast.[ Expression (BinaryOp (_position, Product, Ident a, value_0)) ]
+
+let test_operator2 () =
+ let value_0 = Ast.Integer (_position, "0") in
+ _test_instruction "0 *rand()"
+ Ast.
+ [
+ Expression
+ (BinaryOp (_position, Product, value_0, Function (_position, Rand, [])));
+ ]
+
+let test_dyneval () =
+ _test_instruction "dyneval ''"
+ [
+ Ast.Expression
+ (Ast.Function (_position, Dyneval, [ Ast.Literal (_position, "") ]));
+ ]
+
+(** The parens after input are considered as arguments for the function, not a
+ following expression.
+
+ This expression is a boolean.
+*)
+let test_input () =
+ _test_instruction "( input('') = '' )"
+ [
+ Tree.Ast.Expression
+ (Tree.Ast.BinaryOp
+ ( _position,
+ Eq,
+ Tree.Ast.Function
+ (_position, Input, [ Tree.Ast.Literal (_position, "") ]),
+ Tree.Ast.Literal (_position, "") ));
+ ]
+
+let test_mutiple_inline_ifs () =
+ _test_instruction "if 1 > 0: 1 else if 1 < 0: 0"
+ [
+ Tree.Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Tree.Ast.BinaryOp
+ ( _position,
+ Gt,
+ Tree.Ast.Integer (_position, "1"),
+ Tree.Ast.Integer (_position, "0") ),
+ [ Tree.Ast.Expression (Tree.Ast.Integer (_position, "1")) ] );
+ elifs = [];
+ else_ =
+ [
+ Tree.Ast.If
+ {
+ loc = _position;
+ then_ =
+ ( _position,
+ Tree.Ast.BinaryOp
+ ( _position,
+ Lt,
+ Tree.Ast.Integer (_position, "1"),
+ Tree.Ast.Integer (_position, "0") ),
+ [
+ Tree.Ast.Expression (Tree.Ast.Integer (_position, "0"));
+ ] );
+ elifs = [];
+ else_ = [];
+ };
+ ];
+ };
+ ]
+
+let test_precedence7 () =
+ _test_instruction "(1 + 1 = '')"
+ [
+ Tree.Ast.Expression
+ (Tree.Ast.BinaryOp
+ ( _position,
+ Eq,
+ Tree.Ast.BinaryOp
+ ( _position,
+ Plus,
+ Tree.Ast.Integer (_position, "1"),
+ Tree.Ast.Integer (_position, "1") ),
+ Tree.Ast.Literal (_position, "") ));
+ ]
+
+let test_precedence8 () =
+ _test_instruction "(0 = 1 or 0 = 1)"
+ [
+ Tree.Ast.Expression
+ (Tree.Ast.BinaryOp
+ ( _position,
+ Or,
+ Tree.Ast.BinaryOp
+ ( _position,
+ Eq,
+ Tree.Ast.Integer (_position, "0"),
+ Tree.Ast.Integer (_position, "1") ),
+ Tree.Ast.BinaryOp
+ ( _position,
+ Eq,
+ Tree.Ast.Integer (_position, "0"),
+ Tree.Ast.Integer (_position, "1") ) ));
+ ]
+
+let test =
+ ( "Syntax",
+ [
+ Alcotest.test_case "Location" `Quick test_empty_location;
+ Alcotest.test_case "Location" `Quick test_location_without_database;
+ Alcotest.test_case " Numeric expression" `Quick test_numeric_expression;
+ Alcotest.test_case "-Numeric expression" `Quick
+ test_negative_numeric_expression;
+ Alcotest.test_case "-Numeric expression2" `Quick
+ test_negative_numeric_expression2;
+ Alcotest.test_case "$Variable expression" `Quick test_str_variable;
+ Alcotest.test_case " Variable expression" `Quick test_variable;
+ Alcotest.test_case "Indexed Variable expression" `Quick
+ test_indexed_variable;
+ Alcotest.test_case "Let instruction" `Quick test_let_literal;
+ Alcotest.test_case "Set array_append" `Quick test_set_array_append;
+ Alcotest.test_case "Variable_assignation" `Quick test_direct_assignation;
+ Alcotest.test_case "Command assignation" `Quick test_command_assignation;
+ Alcotest.test_case "Variable_assignation2" `Quick test_assignation2;
+ Alcotest.test_case "Literal" `Quick test_literal;
+ Alcotest.test_case "Literal2" `Quick test_qutoted_literal;
+ Alcotest.test_case "Literal3" `Quick test_multilie_literal;
+ Alcotest.test_case "Concat Literal" `Quick test_concat_literal;
+ Alcotest.test_case "Nested Literal" `Quick test_nested_literal;
+ Alcotest.test_case "Multiline1" `Quick test_multiline1;
+ Alcotest.test_case "Multiline2" `Quick test_multiline2;
+ Alcotest.test_case "Equality" `Quick test_equality;
+ Alcotest.test_case "Plus" `Quick test_plus;
+ Alcotest.test_case "Plus_litt" `Quick test_plus_litt;
+ Alcotest.test_case "PlusChained" `Quick test_concat;
+ Alcotest.test_case "Comment" `Quick test_comment;
+ Alcotest.test_case "Comment2" `Quick test_comment2;
+ Alcotest.test_case "Comment3" `Quick test_comment3;
+ Alcotest.test_case "Comment4" `Quick test_comment4;
+ Alcotest.test_case "Comment5" `Quick test_comment5;
+ Alcotest.test_case "Comment6" `Quick test_comment6;
+ Alcotest.test_case "Multiline Comment" `Quick test_long_comment;
+ Alcotest.test_case "If" `Quick test_if;
+ Alcotest.test_case "If - end if" `Quick test_if2;
+ Alcotest.test_case "If_chained" `Quick test_if_chained;
+ Alcotest.test_case "If_equality" `Quick test_if_equality;
+ Alcotest.test_case "If inline" `Quick test_if_inline;
+ Alcotest.test_case "If inline &!" `Quick test_if_inline_comment;
+ Alcotest.test_case "If inline & !!" `Quick test_if_inline_comment2;
+ Alcotest.test_case "If : act" `Quick test_if_inline_act;
+ Alcotest.test_case "If : act: &!" `Quick test_if_inline_act2;
+ Alcotest.test_case "Precedence1" `Quick test_precedence;
+ Alcotest.test_case "Precedence2" `Quick test_precedence2;
+ Alcotest.test_case "Precedence3" `Quick test_precedence3;
+ Alcotest.test_case "Call gs" `Quick test_gs;
+ Alcotest.test_case "Call gt" `Quick test_gt;
+ Alcotest.test_case "Call nl" `Quick test_nl;
+ Alcotest.test_case "Function iif" `Quick test_function;
+ Alcotest.test_case "Function rand" `Quick test_function2;
+ Alcotest.test_case "Precedence4" `Quick test_precedence4;
+ Alcotest.test_case "Precedence5" `Quick test_precedence5;
+ Alcotest.test_case "Precedence6" `Quick test_precedence6;
+ Alcotest.test_case "Operator" `Quick test_operator;
+ Alcotest.test_case "Operator2" `Quick test_operator2;
+ Alcotest.test_case "Dyneval" `Quick test_dyneval;
+ Alcotest.test_case "Input" `Quick test_input;
+ Alcotest.test_case "inline if else if" `Quick test_mutiple_inline_ifs;
+ Alcotest.test_case "Precedence7" `Quick test_precedence7;
+ Alcotest.test_case "Precedence8" `Quick test_precedence8;
+ ] )
diff --git a/test/syntax_error.ml b/test/syntax_error.ml
new file mode 100644
index 0000000..b907bc7
--- /dev/null
+++ b/test/syntax_error.ml
@@ -0,0 +1,85 @@
+module Parser = Qparser.Parser.Make (Qsp_syntax.Tree)
+module Ast = Qsp_syntax.Tree.Ast
+
+let _position = (Lexing.dummy_pos, Lexing.dummy_pos)
+
+type 'a report = { level : Qsp_syntax.Report.level; loc : 'a; message : string }
+[@@deriving eq, show]
+
+let report : Ast.pos report Alcotest.testable =
+ let equal = equal_report (fun _ _ -> true) in
+ let pp = pp_report (fun formater _ -> Format.fprintf formater "_position") in
+ Alcotest.testable pp equal
+
+let get_report :
+ (Ast.pos Syntax.location, Qsp_syntax.Report.t) result -> Ast.pos report =
+ function
+ | Ok _ -> failwith "No error"
+ | Error { level; loc; message } -> { level; loc; message }
+
+let _test_instruction : string -> Ast.pos report -> unit =
+ fun literal expected ->
+ let _location = Printf.sprintf {|# Location
+%s
+------- |} literal in
+ let actual = get_report @@ Syntax.parse _location and msg = literal in
+
+ Alcotest.(check' report ~msg ~expected ~actual)
+
+let else_column () =
+ _test_instruction
+ {|IF 1:
+ 0
+ ELSE:
+ 1
+ END|}
+ {
+ level = Error;
+ loc = _position;
+ message = "Unexpected operator after `ELSE`";
+ }
+
+let elseif_no_column () =
+ _test_instruction
+ {|IF 1:
+ 0
+ ELSEIF 0
+ 1
+ END|}
+ {
+ level = Error;
+ loc = _position;
+ message =
+ "The `ELIF` expression does not end properly. A `:` is expected before \
+ any instruction.";
+ }
+
+let unclosed_paren () =
+ _test_instruction
+ {|(1
+ |}
+ {
+ level = Error;
+ loc = _position;
+ message = "Unexpected '('. Did you forgot a function before ?";
+ }
+
+let act_no_column () =
+ _test_instruction
+ {|ACT 1
+ 0
+ END|}
+ {
+ level = Error;
+ loc = _position;
+ message = "Invalid `ACT` label. You probably missed a ':'";
+ }
+
+let test =
+ ( "Syntax Errors",
+ [
+ Alcotest.test_case "else:" `Quick else_column;
+ Alcotest.test_case "elseif" `Quick elseif_no_column;
+ Alcotest.test_case "(1" `Quick unclosed_paren;
+ Alcotest.test_case "act 1" `Quick act_no_column;
+ ] )