Commit 55882211 authored by POTTIER Francois's avatar POTTIER Francois
Browse files

Add negative tests of the parser.

parent d068fc1b
File "a-rule-is-expected.mly", line 5, characters 0-6:
Error: syntax error after '%%' and before '%start'.
A rule is expected at this point.
(* The percentpercent sign is misplaced; it comes too early. *)
%%
%start<int> main
%token A
main:
A { 0 }
File "actuals.mly", line 4, characters 12-13:
Error: syntax error after ',' and before ')'.
Ill-formed list of actual parameters.
A comma-delimited list of actual parameters is expected at this point.
Examples of well-formed actual parameters:
expr
expr+
option(expr)
separated_list(COMMA, expr)
%%
main:
foo(bar(A,))
{}
File "after-a-semicolon.mly", line 8, characters 0-6:
Error: syntax error after ';' and before '%token'.
After a semicolon, an expression is expected.
(A rule cannot be terminated with a semicolon.)
Examples of expressions:
term
t = term; { t }
LPAREN; ~ = term; RPAREN; <>
%token A B
%%
let main :=
A(B;
%token FOO
File "another-rule-is-expected.mly", line 9, characters 0-5:
Error: syntax error after ';' and before '%type'.
Another rule is expected at this point.
%start<int> main
%token A
%%
main:
A { 0 };
%type<int> main
File "choice-expression.mly", line 6, characters 0-6:
Error: syntax error after ',' and before '%token'.
An expression is expected at this point.
Examples of expressions:
term
t = term; { t }
LPAREN; ~ = term; RPAREN; <>
factor | ~ = term; ~ = op; ~ = factor; <EBinOp>
%%
let main :=
A(B,
%token A B
File "closing-paren-expected.mly", line 3, characters 6-7:
Error: syntax error after 'X' and before ':'.
Ill-formed rule.
A closing parenthesis ')' is expected at this point.
Examples of well-formed rules:
option(X): { None } | x = X { Some x }
pair(X, Y): x = X; y = Y { (x, y) }
File "colon.mly", line 4, characters 2-3:
Error: syntax error after ')' and before 'A'.
Ill-formed rule.
A colon ':' is expected at this point.
Examples of well-formed rules:
option(X): { None } | x = X { Some x }
%%
main(X)
A B X {}
File "comma-delimited-list-expected.mly", line 3, characters 5-6:
Error: syntax error after '(' and before ')'.
Ill-formed rule.
A comma-delimited list of formal parameters is expected at this point.
Examples of well-formed rules:
option(X): { None } | x = X { Some x }
pair(X, Y): x = X; y = Y { (x, y) }
File "commabar.mly", line 8, characters 0-6:
Error: syntax error after '{}' and before '%token'.
At this point, one of the following is expected:
a comma ',' followed with an expression, or
a bar '|' followed with an expression, or
a closing parenthesis ')'.
%token A B
%%
let main :=
A({}
%token FOO
File "either-a-semantic-action.mly", line 4, characters 12-13:
Error: syntax error after 'foo' and before 'A'.
Ill-formed rule.
Either a semantic action '{' ... '}'
or another production '|' ...
is expected at this point.
Examples of well-formed rules:
expr: MINUS e = expr %prec UMINUS { -e }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment