diff options
author | Maxime Dénès <mail@maximedenes.fr> | 2017-09-15 10:42:13 +0200 |
---|---|---|
committer | Maxime Dénès <mail@maximedenes.fr> | 2017-09-15 10:42:13 +0200 |
commit | 9e6b192adcaadcdb1935a68f39ce5ea877562188 (patch) | |
tree | c0b66a5665b1068c694466e8c64ec57c748530fb /parsing/pcoq.ml | |
parent | d6d7a12eb49c997dd83298477e216349fad74c7f (diff) | |
parent | 7f816f00fed5ee7c7e94bd5f02a88880cdfa96aa (diff) |
Merge PR #1051: Using an algebraic type for distinguishing toplevel input from location in file
Diffstat (limited to 'parsing/pcoq.ml')
-rw-r--r-- | parsing/pcoq.ml | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/parsing/pcoq.ml b/parsing/pcoq.ml index 0d24599ea..40c5da7a5 100644 --- a/parsing/pcoq.ml +++ b/parsing/pcoq.ml @@ -15,8 +15,11 @@ let curry f x y = f (x, y) let uncurry f (x,y) = f x y (** Location Utils *) +let coq_file_of_ploc_file s = + if s = "" then Loc.ToplevelInput else Loc.InFile s + let to_coqloc loc = - { Loc.fname = Ploc.file_name loc; + { Loc.fname = coq_file_of_ploc_file (Ploc.file_name loc); Loc.line_nb = Ploc.line_nb loc; Loc.bol_pos = Ploc.bol_pos loc; Loc.bp = Ploc.first_pos loc; @@ -80,7 +83,7 @@ module type S = Gramext.position option * single_extend_statment list type coq_parsable - val parsable : ?file:string -> char Stream.t -> coq_parsable + val parsable : ?file:Loc.source -> char Stream.t -> coq_parsable val action : 'a -> action val entry_create : string -> 'a entry val entry_parse : 'a entry -> coq_parsable -> 'a @@ -104,7 +107,7 @@ end with type 'a Entry.e = 'a Grammar.GMake(CLexer).Entry.e = struct Gramext.position option * single_extend_statment list type coq_parsable = parsable * CLexer.lexer_state ref - let parsable ?file c = + let parsable ?(file=Loc.ToplevelInput) c = let state = ref (CLexer.init_lexer_state file) in CLexer.set_lexer_state !state; let a = parsable c in |