Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nicer error message #238

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/parser/ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ module Term = struct
and quote = { data : string; loc : Loc.t; kind : string option }
[@@deriving show]

exception NotInProlog of Loc.t * string

let mkC x = CData x
let mkLam x t = Lam (Func.from_string x,t)
let mkNil = Const Func.nilf
Expand All @@ -83,7 +85,11 @@ let mkQuoted loc s =
match s.[i] with
| '{' -> find_data (i+1)
| ':' ->
let rec find_space i = match s.[i] with
let len = String.length s in
let rec find_space i =
if i >= len then
raise (NotInProlog(loc,"syntax error: bad named quotation: {{"^s^"}}.\nDid you separate the name from the data with a space as in {{:name data}} ?."));
match s.[i] with
| ' ' -> i
| '\n' -> i
| _ -> find_space (i+1) in
Expand All @@ -103,7 +109,6 @@ let mkSeq l =
in
aux l

exception NotInProlog of Loc.t * string

let rec best_effort_pp = function
| Lam (x,t) -> "x\\" ^ best_effort_pp t
Expand Down
Loading