Skip to content

Commit

Permalink
parser: hide NotInProlog exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gares committed Jan 9, 2019
1 parent 9323cbd commit f7705f1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/elpi_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -745,28 +745,30 @@ let init ?(silent=true) ~lp_syntax ~paths ~cwd () =
let parse_program filenames : program =
if !parser_initialized = false then U.anomaly "parsing before calling init";
parse lp filenames
try parse lp filenames with NotInProlog s -> raise (Stream.Error ("NotInProlog: " ^ s))
;;
let parse_program_from_stream strm : program =
assert(!parser_initialized = true);
if !parser_initialized = false then U.anomaly "parsing before calling init";
try Grammar.Entry.parse lp strm
with
Ploc.Exc(l,(Token.Error msg | Stream.Error msg)) -> raise(Stream.Error msg)
| Ploc.Exc(l,(Token.Error msg | Stream.Error msg)) -> raise(Stream.Error msg)
| Ploc.Exc(_,e) -> raise e
| NotInProlog s -> raise (Stream.Error ("NotInProlog: " ^ s))
;;
let parse_goal s : goal =
if !parser_initialized = false then U.anomaly "parsing before calling init";
parse_string goal s
try parse_string goal s with NotInProlog s -> raise (Stream.Error ("NotInProlog: " ^ s))
let parse_goal_from_stream strm =
if !parser_initialized = false then U.anomaly "parsing before calling init";
try Grammar.Entry.parse goal strm
with
Ploc.Exc(l,(Token.Error msg | Stream.Error msg)) -> raise(Stream.Error msg)
| Ploc.Exc(l,(Token.Error msg | Stream.Error msg)) -> raise(Stream.Error msg)
| Ploc.Exc(_,e) -> raise e
| NotInProlog s -> raise (Stream.Error ("NotInProlog: " ^ s))
let lp_gramext = [
{ fix = Infixl; sym = ":-"; prec = 0; };
Expand Down

0 comments on commit f7705f1

Please sign in to comment.