summaryrefslogtreecommitdiff
path: root/src/process_file.ml
diff options
context:
space:
mode:
authorAlasdair Armstrong2017-10-09 19:01:36 +0100
committerAlasdair Armstrong2017-10-09 19:01:36 +0100
commit34d76d1234bfd3ecae1e3e39687d0d202c0fb02c (patch)
tree2c7d7cc1d13dde878f0c60a3d3b71169e901db67 /src/process_file.ml
parentd3604c52e19e4e71965b5d96d6fab879bac7effc (diff)
Improvements to menhir pretty printer and ocaml backend
Menhir pretty printer can now print enough sail to be useful with ASL parser Fixity declarations are now preserved in the AST Menhir parser now runs without the Pre-lexer Ocaml backend now supports variant typedefs, as the machinery to generate arbitrary instances of variant types has been added to the -undefined_gen flag
Diffstat (limited to 'src/process_file.ml')
-rw-r--r--src/process_file.ml27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/process_file.ml b/src/process_file.ml
index 1749bc03..f176f198 100644
--- a/src/process_file.ml
+++ b/src/process_file.ml
@@ -59,20 +59,25 @@ let get_lexbuf f =
lexbuf, in_chan
let parse_file (f : string) : Parse_ast.defs =
- let scanbuf, in_chan = get_lexbuf f in
- let type_names =
- try
- Pre_parser.file Pre_lexer.token scanbuf
- with
+ if not !opt_new_parser
+ then
+ let scanbuf, in_chan = get_lexbuf f in
+ let type_names =
+ try
+ Pre_parser.file Pre_lexer.token scanbuf
+ with
| Parsing.Parse_error ->
- let pos = Lexing.lexeme_start_p scanbuf in
- raise (Reporting_basic.Fatal_error (Reporting_basic.Err_syntax (pos, "pre")))
+ let pos = Lexing.lexeme_start_p scanbuf in
+ raise (Reporting_basic.Fatal_error (Reporting_basic.Err_syntax (pos, "pre")))
| Parse_ast.Parse_error_locn(l,m) ->
- raise (Reporting_basic.Fatal_error (Reporting_basic.Err_syntax_locn (l, m)))
+ raise (Reporting_basic.Fatal_error (Reporting_basic.Err_syntax_locn (l, m)))
| Lexer.LexError(s,p) ->
- raise (Reporting_basic.Fatal_error (Reporting_basic.Err_lex (p, s))) in
- let () = Lexer.custom_type_names := !Lexer.custom_type_names @ type_names in
- close_in in_chan;
+ raise (Reporting_basic.Fatal_error (Reporting_basic.Err_lex (p, s)))
+ in
+ close_in in_chan;
+ Lexer.custom_type_names := !Lexer.custom_type_names @ type_names
+ else ();
+
let lexbuf, in_chan = get_lexbuf f in
try
let ast =