Commit 63638a8a by POTTIER Francois

New tests.

parent 35e59e49
Error: the parameterized nonterminal symbols in this grammar
cannot be expanded away: expansion would not terminate.
The first formal parameter of "F(list,_)" grows without bound.
(* A more complicated variant of jh. *)
%token B
%start<unit> main
%%
app2(F, X, Y):
F(X, Y) {}
F(A, U):
app2(F, A, id(U)) {}
id(V):
V {}
main:
F(list, B) {}
Error: the parameterized nonterminal symbols in this grammar
cannot be expanded away: expansion would not terminate.
The first formal parameter of "F(_,_)" grows without bound.
(* A more complicated variant of jh. *)
%token A B
%start<unit> main
%%
app2(F, X, Y):
F(X, Y) {}
F(X, U):
app2(F, id(X), U) {}
id(V):
V {}
main:
F(A, B) {}
Error: the parameterized nonterminal symbols in this grammar
cannot be expanded away: expansion would not terminate.
The first formal parameter of "F(_)" grows without bound.
(* This grammar was accepted by Menhir prior to 2017/12/06,
even though its expansion does not terminate.
https://gitlab.inria.fr/fpottier/menhir/issues/4 *)
%token A
%start<unit> main
%%
app(X, Y):
X(Y) {}
F(U):
app(F, id(U)) {}
id(V):
V {}
main:
F(A) {}
File "not-well-founded-rec.mly", line 7, characters 7-8:
Error: mutually recursive definitions must have the same parameters.
This is not the case for b.
Error: the parameterized nonterminal symbols in this grammar
cannot be expanded away: expansion would not terminate.
The first formal parameter of "b(_)" grows without bound.
Grammar has 7 nonterminal symbols, among which 1 start symbols.
Grammar has 4 terminal symbols.
Grammar has 10 productions.
nullable(main) = false
nullable(expr_or_assign(empty)) = false
nullable(expr_or_assign(cr)) = false
nullable(expr(empty)) = false
nullable(expr(cr)) = false
nullable(empty) = true
nullable(cr) = true
first(main) = UNIT LPAR
first(expr_or_assign(empty)) = UNIT LPAR
first(expr_or_assign(cr)) = UNIT NEW_LINE LPAR
first(expr(empty)) = UNIT LPAR
first(expr(cr)) = UNIT NEW_LINE LPAR
first(empty) =
first(cr) = NEW_LINE
follow(main) = #
follow(expr_or_assign(empty)) = #
follow(expr_or_assign(cr)) = RPAR NEW_LINE
follow(expr(empty)) = #
follow(expr(cr)) = RPAR NEW_LINE
follow(empty) = LPAR
follow(cr) = RPAR LPAR
Built an LR(0) automaton with 19 states.
The grammar is SLR(1).
Built an LR(1) automaton with 19 states.
9 out of 19 states have a default reduction.
5 out of 19 states are represented.
0 out of 14 symbols keep track of their start position.
0 out of 14 symbols keep track of their end position.
8 out of 11 productions exploit shiftreduce optimization.
0 out of 19 states can peek at an error.
62 functions before inlining, 9 functions after inlining.
(* Submitted by Martin Bodin.
https://gitlab.inria.fr/fpottier/menhir/issues/4
This file was rejected by Menhir prior to 2017/12/06
because expr_or_assign(el) invokes expr(el)
which invokes expr_or_assign(cr). *)
%token NEW_LINE
%token LPAR RPAR
%token UNIT
%start<unit> main
%%
main:
| e = expr_or_assign (empty) { e }
expr_or_assign (el):
| e = expr (el) { e }
expr (el):
| el; p = LPAR; e = expr_or_assign (cr); cr; RPAR { e }
| e = UNIT { e }
cr:
| NEW_LINE cr { }
| { }
empty:
| { }
%%
%start main
%token LPAR
%token NEW_LINE
%token RPAR
%token UNIT
%type <unit> main
%%
main:
e = expr_or_assign_empty_
{ ( e )}
expr_or_assign_cr_:
e = expr_cr_
{ ( e )}
expr_or_assign_empty_:
e = expr_empty_
{ ( e )}
expr_cr_:
_1 = cr p = LPAR e = expr_or_assign_cr_ _4 = cr _5 = RPAR
{ ( e )}
| e = UNIT
{ ( e )}
expr_empty_:
_1 = empty p = LPAR e = expr_or_assign_cr_ _4 = cr _5 = RPAR
{ ( e )}
| e = UNIT
{ ( e )}
cr:
_1 = NEW_LINE _2 = cr
{ ( )}
|
{ ( )}
empty:
{ ( )}
%%
Grammar has 8 nonterminal symbols, among which 1 start symbols.
Grammar has 4 terminal symbols.
Grammar has 11 productions.
nullable(main) = false
nullable(expr_or_assign_cr) = false
nullable(expr_or_assign(empty)) = false
nullable(expr_or_assign(cr)) = false
nullable(expr(empty)) = false
nullable(expr(cr)) = false
nullable(empty) = true
nullable(cr) = true
first(main) = UNIT LPAR
first(expr_or_assign_cr) = UNIT NEW_LINE LPAR
first(expr_or_assign(empty)) = UNIT LPAR
first(expr_or_assign(cr)) = UNIT NEW_LINE LPAR
first(expr(empty)) = UNIT LPAR
first(expr(cr)) = UNIT NEW_LINE LPAR
first(empty) =
first(cr) = NEW_LINE
follow(main) = #
follow(expr_or_assign_cr) = RPAR NEW_LINE
follow(expr_or_assign(empty)) = #
follow(expr_or_assign(cr)) = RPAR NEW_LINE
follow(expr(empty)) = #
follow(expr(cr)) = RPAR NEW_LINE
follow(empty) = LPAR
follow(cr) = RPAR LPAR
Built an LR(0) automaton with 20 states.
The grammar is SLR(1).
Built an LR(1) automaton with 20 states.
10 out of 20 states have a default reduction.
5 out of 20 states are represented.
0 out of 15 symbols keep track of their start position.
0 out of 15 symbols keep track of their end position.
9 out of 12 productions exploit shiftreduce optimization.
0 out of 20 states can peek at an error.
66 functions before inlining, 9 functions after inlining.
(* Submitted by Martin Bodin.
https://gitlab.inria.fr/fpottier/menhir/issues/4
This file was accepted by Menhir prior to 2017/12/06
but that was unintended.
Its close companion bodin.mly was rejected. *)
%token NEW_LINE
%token LPAR RPAR
%token UNIT
%start<unit> main
%%
main:
| e = expr_or_assign (empty) { e }
expr_or_assign (el):
| e = expr (el) { e }
expr_or_assign_cr:
| e = expr_or_assign (cr) { e }
expr (el):
| el; p = LPAR; e = expr_or_assign_cr; cr; RPAR { e }
| e = UNIT { e }
cr:
| NEW_LINE cr { }
| { }
empty:
| { }
%%
%start main
%token LPAR
%token NEW_LINE
%token RPAR
%token UNIT
%type <unit> main
%%
main:
e = expr_or_assign_empty_
{ ( e )}
expr_or_assign_cr_:
e = expr_cr_
{ ( e )}
expr_or_assign_empty_:
e = expr_empty_
{ ( e )}
expr_or_assign_cr:
e = expr_or_assign_cr_
{ ( e )}
expr_cr_:
_1 = cr p = LPAR e = expr_or_assign_cr _4 = cr _5 = RPAR
{ ( e )}
| e = UNIT
{ ( e )}
expr_empty_:
_1 = empty p = LPAR e = expr_or_assign_cr _4 = cr _5 = RPAR
{ ( e )}
| e = UNIT
{ ( e )}
cr:
_1 = NEW_LINE _2 = cr
{ ( )}
|
{ ( )}
empty:
{ ( )}
%%
Warning: you are using the standard library and/or the %inline keyword. We
recommend switching on --infer in order to avoid obscure type error messages.
Grammar has 16 nonterminal symbols, among which 1 start symbols.
Grammar has 6 terminal symbols.
Grammar has 30 productions.
nullable(weird(separated_list,SEMI)) = false
nullable(weird(separated_list,COMMA)) = false
nullable(separated_nonempty_list(SEMI,weird(separated_list,COMMA))) = false
nullable(separated_nonempty_list(SEMI,expr(separated_list,SEMI))) = false
nullable(separated_nonempty_list(SEMI,bizarre(nonseparated_list,SEMI))) = false
nullable(separated_nonempty_list(COMMA,weird(separated_list,COMMA))) = false
nullable(nonseparated_list(SEMI,bizarre(nonseparated_list,SEMI))) = true
nullable(main) = false
nullable(loption(separated_nonempty_list(SEMI,weird(separated_list,COMMA)))) = true
nullable(loption(separated_nonempty_list(SEMI,expr(separated_list,SEMI)))) = true
nullable(loption(separated_nonempty_list(SEMI,bizarre(nonseparated_list,SEMI)))) = true
nullable(loption(separated_nonempty_list(COMMA,weird(separated_list,COMMA)))) = true
nullable(list(bizarre(nonseparated_list,SEMI))) = true
nullable(expr(separated_list,SEMI)) = false
nullable(bizarre(separated_list,SEMI)) = false
nullable(bizarre(nonseparated_list,SEMI)) = false
first(weird(separated_list,SEMI)) = LBRACE INT
first(weird(separated_list,COMMA)) = LBRACE INT
first(separated_nonempty_list(SEMI,weird(separated_list,COMMA))) = LBRACE INT
first(separated_nonempty_list(SEMI,expr(separated_list,SEMI))) = LBRACE INT
first(separated_nonempty_list(SEMI,bizarre(nonseparated_list,SEMI))) = LBRACE INT
first(separated_nonempty_list(COMMA,weird(separated_list,COMMA))) = LBRACE INT
first(nonseparated_list(SEMI,bizarre(nonseparated_list,SEMI))) = LBRACE INT
first(main) = LBRACE INT
first(loption(separated_nonempty_list(SEMI,weird(separated_list,COMMA)))) = LBRACE INT
first(loption(separated_nonempty_list(SEMI,expr(separated_list,SEMI)))) = LBRACE INT
first(loption(separated_nonempty_list(SEMI,bizarre(nonseparated_list,SEMI)))) = LBRACE INT
first(loption(separated_nonempty_list(COMMA,weird(separated_list,COMMA)))) = LBRACE INT
first(list(bizarre(nonseparated_list,SEMI))) = LBRACE INT
first(expr(separated_list,SEMI)) = LBRACE INT
first(bizarre(separated_list,SEMI)) = LBRACE INT
first(bizarre(nonseparated_list,SEMI)) = LBRACE INT
follow(weird(separated_list,SEMI)) = LBRACE INT
follow(weird(separated_list,COMMA)) = SEMI RBRACE COMMA
follow(separated_nonempty_list(SEMI,weird(separated_list,COMMA))) = RBRACE
follow(separated_nonempty_list(SEMI,expr(separated_list,SEMI))) = RBRACE
follow(separated_nonempty_list(SEMI,bizarre(nonseparated_list,SEMI))) = RBRACE
follow(separated_nonempty_list(COMMA,weird(separated_list,COMMA))) = RBRACE
follow(nonseparated_list(SEMI,bizarre(nonseparated_list,SEMI))) = RBRACE
follow(main) = #
follow(loption(separated_nonempty_list(SEMI,weird(separated_list,COMMA)))) = RBRACE
follow(loption(separated_nonempty_list(SEMI,expr(separated_list,SEMI)))) = RBRACE
follow(loption(separated_nonempty_list(SEMI,bizarre(nonseparated_list,SEMI)))) = RBRACE
follow(loption(separated_nonempty_list(COMMA,weird(separated_list,COMMA)))) = RBRACE
follow(list(bizarre(nonseparated_list,SEMI))) = RBRACE
follow(expr(separated_list,SEMI)) = SEMI RBRACE LBRACE INT
follow(bizarre(separated_list,SEMI)) = EOF
follow(bizarre(nonseparated_list,SEMI)) = SEMI RBRACE LBRACE INT
Built an LR(0) automaton with 45 states.
The grammar is SLR(1).
Built an LR(1) automaton with 45 states.
22 out of 45 states have a default reduction.
11 out of 45 states are represented.
0 out of 25 symbols keep track of their start position.
0 out of 25 symbols keep track of their end position.
22 out of 31 productions exploit shiftreduce optimization.
0 out of 45 states can peek at an error.
143 functions before inlining, 25 functions after inlining.
%token INT EOF SEMI LBRACE RBRACE COMMA
%start<unit> main
%%
main:
expr(separated_list, SEMI)
weird(separated_list, SEMI)
bizarre(separated_list, SEMI)
EOF
{}
expr(seq, sep):
INT
| LBRACE seq(sep, expr(seq, sep)) RBRACE
{}
weird(seq, sep):
INT
| LBRACE seq(sep, weird(seq, COMMA)) RBRACE
{}
bizarre(seq, sep):
INT
| LBRACE seq(sep, bizarre(nonseparated_list, sep)) RBRACE
{}
nonseparated_list(sep, X):
list(X)
{}
Warning: you are using the standard library and/or the %inline keyword. We
recommend switching on --infer in order to avoid obscure type error messages.
%start main
%token COMMA
%token EOF
%token INT
%token LBRACE
%token RBRACE
%token SEMI
%type <unit> main
%%
loption_separated_nonempty_list_COMMA_weird_separated_list_COMMA___:
{ ( [] )}
| x = separated_nonempty_list_COMMA_weird_separated_list_COMMA__
{ ( x )}
loption_separated_nonempty_list_SEMI_bizarre_nonseparated_list_SEMI___:
{ ( [] )}
| x = separated_nonempty_list_SEMI_bizarre_nonseparated_list_SEMI__
{ ( x )}
loption_separated_nonempty_list_SEMI_expr_separated_list_SEMI___:
{ ( [] )}
| x = separated_nonempty_list_SEMI_expr_separated_list_SEMI__
{ ( x )}
loption_separated_nonempty_list_SEMI_weird_separated_list_COMMA___:
{ ( [] )}
| x = separated_nonempty_list_SEMI_weird_separated_list_COMMA__
{ ( x )}
list_bizarre_nonseparated_list_SEMI__:
{ ( [] )}
| x = bizarre_nonseparated_list_SEMI_ xs = list_bizarre_nonseparated_list_SEMI__
{ ( x :: xs )}
separated_nonempty_list_COMMA_weird_separated_list_COMMA__:
x = weird_separated_list_COMMA_
{ ( [ x ] )}
| x = weird_separated_list_COMMA_ _2 = COMMA xs = separated_nonempty_list_COMMA_weird_separated_list_COMMA__
{ ( x :: xs )}
separated_nonempty_list_SEMI_bizarre_nonseparated_list_SEMI__:
x = bizarre_nonseparated_list_SEMI_
{ ( [ x ] )}
| x = bizarre_nonseparated_list_SEMI_ _2 = SEMI xs = separated_nonempty_list_SEMI_bizarre_nonseparated_list_SEMI__
{ ( x :: xs )}
separated_nonempty_list_SEMI_expr_separated_list_SEMI__:
x = expr_separated_list_SEMI_
{ ( [ x ] )}
| x = expr_separated_list_SEMI_ _2 = SEMI xs = separated_nonempty_list_SEMI_expr_separated_list_SEMI__
{ ( x :: xs )}
separated_nonempty_list_SEMI_weird_separated_list_COMMA__:
x = weird_separated_list_COMMA_
{ ( [ x ] )}
| x = weird_separated_list_COMMA_ _2 = SEMI xs = separated_nonempty_list_SEMI_weird_separated_list_COMMA__
{ ( x :: xs )}
main:
_1 = expr_separated_list_SEMI_ _2 = weird_separated_list_SEMI_ _3 = bizarre_separated_list_SEMI_ _4 = EOF
{ ()}
expr_separated_list_SEMI_:
_1 = INT
{ ()}
| _1 = LBRACE xs0 = loption_separated_nonempty_list_SEMI_expr_separated_list_SEMI___ _3 = RBRACE
{let _2 =
let xs = xs0 in
( xs )
in
()}
weird_separated_list_COMMA_:
_1 = INT
{ ()}
| _1 = LBRACE xs0 = loption_separated_nonempty_list_COMMA_weird_separated_list_COMMA___ _3 = RBRACE
{let _2 =
let xs = xs0 in
( xs )
in
()}
weird_separated_list_SEMI_:
_1 = INT
{ ()}
| _1 = LBRACE xs0 = loption_separated_nonempty_list_SEMI_weird_separated_list_COMMA___ _3 = RBRACE
{let _2 =
let xs = xs0 in
( xs )
in
()}
bizarre_nonseparated_list_SEMI_:
_1 = INT
{ ()}
| _1 = LBRACE _2 = nonseparated_list_SEMI_bizarre_nonseparated_list_SEMI__ _3 = RBRACE
{ ()}
bizarre_separated_list_SEMI_:
_1 = INT
{ ()}
| _1 = LBRACE xs0 = loption_separated_nonempty_list_SEMI_bizarre_nonseparated_list_SEMI___ _3 = RBRACE
{let _2 =
let xs = xs0 in
( xs )
in
()}
nonseparated_list_SEMI_bizarre_nonseparated_list_SEMI__:
_1 = list_bizarre_nonseparated_list_SEMI__
{ ()}
%%
Grammar has 3 nonterminal symbols, among which 1 start symbols.
Grammar has 2 terminal symbols.
Grammar has 5 productions.
nullable(main) = false
nullable(F(id(A),A)) = false
nullable(F(A,id(A))) = false
first(main) = B A
first(F(id(A),A)) = B A
first(F(A,id(A))) = B A
follow(main) = #
follow(F(id(A),A)) = #
follow(F(A,id(A))) = #
Built an LR(0) automaton with 9 states.
The grammar is SLR(1).
Built an LR(1) automaton with 9 states.
6 out of 9 states have a default reduction.
2 out of 9 states are represented.
0 out of 8 symbols keep track of their start position.
0 out of 8 symbols keep track of their end position.
6 out of 6 productions exploit shiftreduce optimization.
0 out of 9 states can peek at an error.
33 functions before inlining, 6 functions after inlining.
(* Another (artificial) example where the parameters are exchanged
in the recursive call. *)
%token A B
%start<unit> main
%%
F(X,Y):
B {}
| A F(Y, X) {}
id(X):
X {}
main:
F(A, id(A)) {}
%start main
%token A
%token B
%type <unit> main
%%
F_A_id_A__:
_1 = B
{ ()}
| _1 = A _2 = F_id_A__A_
{ ()}
F_id_A__A_:
_1 = B
{ ()}
| _1 = A _2 = F_A_id_A__
{ ()}
main:
_1 = F_A_id_A__
{ ()}
%%
Grammar has 3 nonterminal symbols, among which 1 start symbols.
Grammar has 3 terminal symbols.
Grammar has 5 productions.
nullable(main) = false
nullable(aseq(B,A)) = true
nullable(aseq(A,B)) = true
first(main) = EOF A
first(aseq(B,A)) = B
first(aseq(A,B)) = A
follow(main) = #
follow(aseq(B,A)) = EOF
follow(aseq(A,B)) = EOF
Built an LR(0) automaton with 8 states.
The grammar is SLR(1).
Built an LR(1) automaton with 8 states.
4 out of 8 states have a default reduction.
2 out of 8 states are represented.
0 out of 9 symbols keep track of their start position.
0 out of 9 symbols keep track of their end position.
3 out of 6 productions exploit shiftreduce optimization.
0 out of 8 states can peek at an error.
31 functions before inlining, 7 functions after inlining.
%token A B EOF
%start<unit> main
%%
(* A list of alternating X's and Y's,
possibly empty, beginning with an X. *)
(* This grammar was rejected by Menhir prior to 2017/12/06
because aseq(X, Y) calls itself recursively as aseq(Y, X). *)
aseq(X, Y):
/* epsilon */ {}
| X aseq(Y, X) {}
main:
aseq(A, B) EOF {}
%start main
%token A
%token B
%token EOF
%type <unit> main
%%
aseq_A_B_:
{ ()}
| _1 = A _2 = aseq_B_A_
{ ()}
aseq_B_A_:
{ ()}
| _1 = B _2 = aseq_A_B_
{ ()}
main:
_1 = aseq_A_B_ _2 = EOF
{ ()}
%%
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