Commit 07b8e78e authored by POTTIER Francois's avatar POTTIER Francois
Browse files

New option [--require-aliases].

parent e6a4a9c7
...@@ -311,6 +311,17 @@ module Terminal = struct ...@@ -311,6 +311,17 @@ module Terminal = struct
f i f i
done done
let () =
if verbose && Settings.require_aliases then
iter_real begin fun tok ->
let properties = token_properties.(tok) in
if properties.tk_alias = None then
let pos = properties.tk_position in
Error.grammar_warning [pos]
"no alias has been defined for the token %s."
(print tok)
end
(* If a token named [EOF] exists, then it is assumed to represent (* If a token named [EOF] exists, then it is assumed to represent
ocamllex's [eof] pattern. *) ocamllex's [eof] pattern. *)
......
...@@ -79,7 +79,7 @@ let join_declaration filename (grammar : grammar) decl = ...@@ -79,7 +79,7 @@ let join_declaration filename (grammar : grammar) decl =
tk_position = decl.position; tk_position = decl.position;
tk_attributes = attributes; tk_attributes = attributes;
tk_is_declared = true; tk_is_declared = true;
tk_alias = None tk_alias = alias;
} }
in in
......
...@@ -295,6 +295,9 @@ type dollars = ...@@ -295,6 +295,9 @@ type dollars =
let dollars = let dollars =
ref DollarsAllowed ref DollarsAllowed
let require_aliases =
ref false
(* When new command line options are added, please update both the manual (* When new command line options are added, please update both the manual
in [doc/manual.tex] and the man page in [doc/menhir.1]. *) in [doc/manual.tex] and the man page in [doc/menhir.1]. *)
...@@ -353,6 +356,7 @@ let options = Arg.align [ ...@@ -353,6 +356,7 @@ let options = Arg.align [
"--only-tokens", Arg.Unit tokentypeonly, " Generate token type definition only, no code"; "--only-tokens", Arg.Unit tokentypeonly, " Generate token type definition only, no code";
"--raw-depend", Arg.Unit enable_raw_depend, " Invoke ocamldep and echo its raw output"; "--raw-depend", Arg.Unit enable_raw_depend, " Invoke ocamldep and echo its raw output";
"--reference-graph", Arg.Set reference_graph, " (undocumented)"; "--reference-graph", Arg.Set reference_graph, " (undocumented)";
"--require-aliases", Arg.Set require_aliases, " Check that every token has a token alias";
"--stdlib", Arg.String ignore, "<directory> Ignored (deprecated)"; "--stdlib", Arg.String ignore, "<directory> Ignored (deprecated)";
"--strict", Arg.Set strict, " Warnings about the grammar are errors"; "--strict", Arg.Set strict, " Warnings about the grammar are errors";
"--suggest-comp-flags", Arg.Unit (fun () -> suggestion := SuggestCompFlags), "--suggest-comp-flags", Arg.Unit (fun () -> suggestion := SuggestCompFlags),
...@@ -607,6 +611,9 @@ let coq_lib_path = ...@@ -607,6 +611,9 @@ let coq_lib_path =
let dollars = let dollars =
!dollars !dollars
let require_aliases =
!require_aliases
let infer = let infer =
!infer !infer
......
...@@ -262,3 +262,8 @@ type dollars = ...@@ -262,3 +262,8 @@ type dollars =
| DollarsAllowed | DollarsAllowed
val dollars: dollars val dollars: dollars
(* This flag requires every token to come with a token alias. If that is
not the case, warnings are emitted. *)
val require_aliases : bool
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