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

Cleanup in [PreFront].

parent 051dd7f7
open Printf (* The front-end. *)
(* ------------------------------------------------------------------------- *)
(* Reading a grammar from a file. *)
let load_partial_grammar filename = let load_partial_grammar filename =
let validExt = if Settings.coq then ".vy" else ".mly" in let validExt = if Settings.coq then ".vy" else ".mly" in
if Filename.check_suffix filename validExt then if not (Filename.check_suffix filename validExt) then
Error.error [] (Printf.sprintf
"argument file names should end in %s. \"%s\" is not accepted."
validExt filename);
Error.set_filename filename Error.set_filename filename
else
Error.error [] (sprintf "argument file names should end in %s. \"%s\" is not accepted." validExt filename);
try try
let contents = IO.read_whole_file filename in let contents = IO.read_whole_file filename in
...@@ -27,15 +32,28 @@ let load_partial_grammar filename = ...@@ -27,15 +32,28 @@ let load_partial_grammar filename =
with Sys_error msg -> with Sys_error msg ->
Error.error [] msg Error.error [] msg
(* ------------------------------------------------------------------------- *)
(* Read all of the grammar files that are named on the command line. *)
let partial_grammars = let partial_grammars =
List.map load_partial_grammar Settings.filenames List.map load_partial_grammar Settings.filenames
let () = let () =
Time.tick "Lexing and parsing" Time.tick "Lexing and parsing"
(* ------------------------------------------------------------------------- *)
(* If several grammar files were specified, merge them. *)
let parameterized_grammar = let parameterized_grammar =
PartialGrammar.join_partial_grammars partial_grammars PartialGrammar.join_partial_grammars partial_grammars
(* ------------------------------------------------------------------------- *)
(* Expand away all applications of parameterized nonterminal symbols, so as to
obtain a grammar without parameterized nonterminal symbols. *)
let grammar = let grammar =
ParameterizedGrammar.expand parameterized_grammar ParameterizedGrammar.expand parameterized_grammar
......
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