Commit 55882211 authored by POTTIER Francois's avatar POTTIER Francois

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 }
File "either-another-production.mly", line 6, characters 0-5:
Error: syntax error after '{ () }' and before '%type'.
Either another production '|' ...
or another rule is expected at this point.
%%
main:
{ () }
%type<unit> main
File "either-another-rule.mly", line 4, characters 14-15:
Error: syntax error after 'foo' and before '('.
Either another rule
or another production '|' ...
is expected at this point.
Examples of well-formed rules:
option(X): { None } | x = X { Some x }
File "either-public.mly", line 3, characters 8-13:
Error: syntax error after '%inline' and before '%type'.
Ill-formed rule.
Either '%public' or a non-terminal symbol is expected at this point.
Examples of well-formed rules:
%public option(X): { None } | x = X { Some x }
%inline clist(X): xs = separated_nonempty_list(COMMA?, X) { xs }
%public %inline pair(X, Y): x = X; y = Y { (x, y) }
%%
%inline %type<int> main:
{ () }
File "equals-expected.mly", line 3, characters 13-17:
Error: syntax error after '~' and before 'main'.
An equals sign '=' is expected at this point.
File "expression-expected.mly", line 3, characters 9-11:
Error: syntax error after ':=' and before ':='.
An expression is expected at this point.
Examples of expressions:
term
t = term; { t }
LPAREN; ~ = term; RPAREN; <>
factor | term; MUL; factor
File "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; MUL; factor
%%
let main :=
A |
%token FOO
File "expressions.mly", line 6, characters 0-6:
Error: syntax error after '(' and before '%token'.
A comma-separated list of expressions is expected at this point.
%%
let main :=
A(
%token FOO
File "ill-formed-attribute.mly", line 2, characters 0-6:
Error: syntax error after 'A' and before '%token'.
Ill-formed '%attribute' declaration.
An '%attribute' declaration should contain a nonempty list of symbols,
followed with a nonempty list of attributes.
Examples of well-formed declarations:
%attribute FOO [@printer "foo"]
%attribute bar BAZ [@printer "bar/BAZ"] [@cost 2.0]
File "ill-formed-prec.mly", line 5, characters 4-6:
Error: syntax error after '%prec' and before '{}'.
Ill-formed %prec annotation.
A symbol is expected at this point.
Examples of well-formed annotations:
expr: MINUS e = expr %prec UMINUS { -e }
File "invalid-parameter-declaration.mly", line 1, characters 11-12:
Error: syntax error after '%parameter' and before 'F'.
Ill-formed '%parameter' declaration.
Examples of well-formed declarations:
%parameter <X : sig type t end>
File "let-comma.mly", line 4, characters 0-0:
Error: syntax error after '(' and before ''.
A comma-delimited list of formal parameters is expected at this point.
File "let-more.mly", line 3, characters 10-11:
Error: syntax error after 'A' and before '+'.
At this point, one of the following is expected:
a comma ',' followed with an expression, or
a closing parenthesis ')'.
%%
let main(A+, X) := X
File "list-of-productions-expected.mly", line 6, characters 0-5:
Error: syntax error after '|' and before '%type'.
Ill-formed rule.
A list of productions is expected at this point.
Examples of well-formed rules:
main: e = expr; EOL { e }
expr: i = INT { i } | e1 = expr; PLUS; e2 = expr { e1 + e2 }
symbol: s = LID | s = UID { s }
File "mixed.mly", line 3, characters 8-15:
Error: syntax error after '%public' and before '%public'.
Ill-formed rule.
'let' or '%inline' or a non-terminal symbol is expected at this point.
Examples of well-formed rules:
%public option(X): { None } | x = X { Some x }
%public let option(X) := { None } | x = X; { Some x }
%%
%public %public foo:
{}
File "modifier.mly", line 1, characters 21-25:
Error: syntax error after '+' and before 'tail'.
Ill-formed list of actual parameters.
Either a modifier '*' or '+' or '?'
or a closing parenthesis ')'
or a comma ',' is expected at this point.
Examples of well-formed actual parameters:
expr
expr+
option(expr)
separated_list(COMMA, expr)
%type<int> list(exp+ tail)
%%
File "non-terminal-is-expected.mly", line 3, characters 16-21:
Error: syntax error after '%inline' and before '%type'.
Ill-formed rule.
A non-terminal symbol is expected at this point.
Examples of well-formed rules:
%public option(X): { None } | x = X { Some x }
%inline clist(X): xs = separated_nonempty_list(COMMA?, X) { xs }
%public %inline pair(X, Y): x = X; y = Y { (x, y) }
%%
%public %inline %type<int> main:
{ () }
File "pattern.mly", line 4, characters 6-11:
Error: syntax error after ',' and before '%prec'.
A pattern is expected at this point.
Examples of patterns:
x
~
_
(x, y, _)
%%
let main :=
(_, %prec hop) = bar
{}
File "production-expected.mly", line 4, characters 15-16:
Error: syntax error after '|' and before ':'.
A production is expected at this point.
A production is a sequence of producers, followed with a semantic action.
Examples of well-formed producers:
expr
option(COMMA)
separated_list(COMMA, expr)
e = expr
ds = declaration*
es = list(terminated(expr, SEMI))
es = list(e = expr SEMI { e })
xs = list(x = var { Some x } | WILDCARD { None })
File "semantic.mly", line 6, characters 0-3:
Error: syntax error after 'stable' and before 'let'.
A semantic action is expected at this point.
%%
let main :=
%prec stable
let bar =
main
File "semibar.mly", line 6, characters 0-6:
Error: syntax error after 'A' and before '%token'.
At this point, one of the following is expected:
a semicolon ';' followed with an expression, or
a bar '|' followed with an expression, or
another rule.
%%
let main :=
A
%token FOO
File "semibarcomma.mly", line 8, characters 0-6:
Error: syntax error after 'B' and before '%token'.
At this point, one of the following is expected:
a semicolon ';' followed with an expression, or
a bar '|' followed with an expression, or
a comma ',' followed with an expression, or
a closing parenthesis ')'.
%token A B
%%
let main :=
A(B
%token FOO
File "semicolon.mly", line 6, characters 0-3:
Error: syntax error after 'foo' and before 'let'.
A semicolon ';' is expected at this point.
%%
let main :=
~ = foo
let bar =
main
File "symbol-expected.mly", line 4, characters 6-7:
Error: syntax error after '=' and before '('.
A symbol is expected at this point.
File "tired.mly", line 6, characters 0-6:
Error: syntax error after '{}' and before '%token'.
At this point, one of the following is expected:
a bar '|' followed with an expression, or
another rule.
%%
let tired :=
{}
%token TIRED
File "tricky-deep.mly", line 6, characters 0-6:
Error: syntax error after 'bar' and before '%token'.
At this point, one of the following is expected:
an equals sign '=' followed with a symbol, or
a semicolon ';' followed with an expression, or
a bar '|' followed with an expression, or
a closing parenthesis ')'.
%%
let main :=
list(bar
%token FOO
File "tricky.mly", line 6, characters 0-6:
Error: syntax error after 'bar' and before '%token'.
At this point, one of the following is expected:
an equals sign '=' followed with a symbol, or
a semicolon ';' followed with an expression, or
a bar '|' followed with an expression, or
another rule.
%%
let main :=
bar
%token FOO
File "tuple-pattern-previous.mly", line 4, characters 5-10:
Error: syntax error after '_' and before '%prec'.
The previous opening parenthesis seemed to be the beginning of a tuple pattern.
Thus, either a comma ',' followed with a pattern
or a closing parenthesis ')' is expected at this point.
%%
let main :=
(_ %prec hop) = bar
{}
File "tuple-pattern.mly", line 4, characters 3-8:
Error: syntax error after '(' and before '%prec'.
This opening parenthesis seems to be the beginning of a tuple pattern.
Thus, a comma-separated list of patterns is expected at this point.
Markdown is supported
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