raise (HExtlib.Localized
(floc,CicNotationParser.Parse_error (Printexc.to_string exn)))
-let parse_statement grafite_parser lexbuf =
+let parse_statement grafite_parser parsable =
exc_located_wrapper
- (fun () -> (Grammar.Entry.parse (Obj.magic grafite_parser) (Obj.magic lexbuf)))
+ (fun () -> (Grammar.Entry.parse_parsable (Obj.magic grafite_parser) parsable))
let add_raw_attribute ~text t = N.AttributedTerm (`Raw text, t)
(* never_include: do not call LexiconEngine to do includes,
* always raise NoInclusionPerformed *)
(** @raise End_of_file *)
-val parse_statement: #status -> Ulexing.lexbuf -> GrafiteAst.statement
+val parse_statement: #status -> Grammar.parsable -> GrafiteAst.statement
(Filename.dirname
(Http_getter.filename ~local:true ~writable:true (baseuri ^
"foo.con")));
- let buf = Ulexing.from_utf8_channel (open_in fname) in
+ let grammar = CicNotationParser.level2_ast_grammar grafite_status in
+ let buf =
+ Grammar.parsable grammar
+ (Obj.magic (Ulexing.from_utf8_channel (open_in fname)))
+ in
let print_cb =
if not (Helm_registry.get_bool "matita.verbose") then (fun _ _ -> ())
else pp_ast_statement
exception CircularDependency of string
val get_ast:
- GrafiteTypes.status -> include_paths:string list -> Ulexing.lexbuf ->
+ GrafiteTypes.status -> include_paths:string list -> Grammar.parsable ->
GrafiteAst.statement
(* heavy checks slow down the compilation process but give you some interesting
match statement with
| `Raw text ->
if Pcre.pmatch ~rex:only_dust_RE text then raise Margin;
- let strm = Ulexing.from_utf8_string text in
+ let grammar = CicNotationParser.level2_ast_grammar grafite_status in
+ let strm =
+ Grammar.parsable grammar (Obj.magic(Ulexing.from_utf8_string text)) in
let ast = MatitaEngine.get_ast grafite_status include_paths strm in
ast, text
| `Ast (st, text) -> st, text
method eos =
let rec is_there_only_comments lexicon_status s =
if Pcre.pmatch ~rex:only_dust_RE s then raise Margin;
- match
- GrafiteParser.parse_statement lexicon_status (Ulexing.from_utf8_string s)
- with
+ let grammar = CicNotationParser.level2_ast_grammar lexicon_status in
+ let strm =
+ Grammar.parsable grammar (Obj.magic(Ulexing.from_utf8_string s)) in
+ match GrafiteParser.parse_statement lexicon_status strm with
| GrafiteAst.Comment (loc,_) ->
let _,parsed_text_length = MatitaGtkMisc.utf8_parsed_text s loc in
(* CSC: why +1 in the following lines ???? *)