Stefan pushed to branch master at Stefan / Typer
Commits: abf28d5c by Stefan Monnier at 2018-07-18T17:27:27Z Be more careful about which grammar to use while parsing
* src/REPL.ml (_ieval, _raw_eval): Use grammar from ctx. Rename arg to `ectx`. * src/debug_util.ml (format_source, main): Use grammar from pervasive.
- - - - -
2 changed files:
- src/REPL.ml - src/debug_util.ml
Changes:
===================================== src/REPL.ml ===================================== @@ -1,6 +1,6 @@ (* REPL.ml --- Read Eval Print Loop (REPL)
-Copyright (C) 2016-2017 Free Software Foundation, Inc. +Copyright (C) 2016-2018 Free Software Foundation, Inc.
Author: Pierre Delaunay pierre.delaunay@hec.ca
@@ -142,25 +142,25 @@ let ieval lexps rctx = let vals = eval_all lexprs rctx false in vals, rctx
-let _ieval f str lctx rctx = +let _ieval f str ectx rctx = let pres = (f str) in let sxps = lex default_stt pres in (* FIXME: This is too eager: it prevents one declaration from changing * the grammar used in subsequent declarations. *) - let nods = sexp_parse_all_to_list default_grammar sxps (Some ";") in + let nods = sexp_parse_all_to_list (ectx_to_grm ectx) sxps (Some ";") in
(* Different from usual typer *) let pxps = ipexp_parse nods in - let lxps, lctx = ilexp_parse pxps lctx in + let lxps, ectx = ilexp_parse pxps ectx in let elxps = ierase_type lxps in let v, rctx = ieval elxps rctx in - v, lctx, rctx + v, ectx, rctx
-let _raw_eval f str lctx rctx = +let _raw_eval f str ectx rctx = let pres = (f str) in let sxps = lex default_stt pres in - let nods = sexp_parse_all_to_list default_grammar sxps (Some ";") in - let lxps, lctx = Elab.lexp_p_decls nods lctx in + let nods = sexp_parse_all_to_list (ectx_to_grm ectx) sxps (Some ";") in + let lxps, ectx = Elab.lexp_p_decls nods ectx in let elxps = List.map OL.clean_decls lxps in (* At this point, `elxps` is a `(vname * elexp) list list`, where: * - each `(vname * elexp)` is a definition @@ -170,7 +170,7 @@ let _raw_eval f str lctx rctx = * blocs of mutually-recursive definitions. *) let rctx = eval_decls_toplevel elxps rctx in (* This is for consistency with ieval *) - [], lctx, rctx + [], ectx, rctx
let ieval_string = _ieval prelex_string let ieval_file = _ieval prelex_file
===================================== src/debug_util.ml ===================================== @@ -193,7 +193,8 @@ let format_source () = let filename = List.hd (!arg_files) in let pretoks = prelex_file filename in let toks = lex default_stt pretoks in - let nodes = sexp_parse_all_to_list default_grammar toks (Some ";") in + let nodes = sexp_parse_all_to_list (ectx_to_grm Elab.default_ectx) + toks (Some ";") in let ctx = Elab.default_ectx in let lexps, _ = Elab.lexp_p_decls nodes ctx in
@@ -253,7 +254,8 @@ let main () =
(* get node sexp *) print_string yellow; - let nodes = sexp_parse_all_to_list default_grammar toks (Some ";") in + let nodes = sexp_parse_all_to_list (ectx_to_grm Elab.default_ectx) + toks (Some ";") in print_string reset;
(if (get_p_option "sexp") then(
View it on GitLab: https://gitlab.com/monnier/typer/commit/abf28d5c9debf582288868514532b7c14942...
Afficher les réponses par date