Commit b3c88513 authored by POTTIER Francois's avatar POTTIER Francois

Fix [NonTerminalDefinitionInlining] by removing %on_error_reduce

declarations for symbols that are inlined away (and warning about
them, at the same time).
parent 6600287f
Warning: the declaration %on_error_reduce ioption(A)
has no effect, since this symbol is marked %inline and is expanded away.
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.
%token A B
%start<unit> main
%on_error_reduce ioption(A)
%%
main:
ioption(A) B {}
Warning: the declaration %on_error_reduce ioption(A)
has no effect, since this symbol is marked %inline and is expanded away.
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 B
%token A
%type <unit> main
%%
main:
_2 = B
{let _1 =
( None )
in
()}
| x0 = A _2 = B
{let _1 =
let x = x0 in
( Some x )
in
()}
%%
......@@ -321,7 +321,19 @@ let inline grammar =
true (* could be: assert false? *)
in
(* Remove %on_error_reduce declarations for symbols that are expanded away,
and warn about them, at the same time. *)
let useful_warn (k : string) : bool =
let u = useful k in
if not u then
Error.grammar_warning []
"the declaration %%on_error_reduce %s\n\
has no effect, since this symbol is marked %%inline and is expanded away." k;
u
in
{ grammar with
rules = StringMap.filter (fun _ r -> not r.inline_flag) expanded_rules;
types = StringMap.filter (fun k _ -> useful k) grammar.types;
on_error_reduce = StringMap.filter (fun k _ -> useful_warn k) grammar.on_error_reduce;
}, !use_inline
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