Commit 9b0ac0fc authored by Robbert Krebbers's avatar Robbert Krebbers

Improve intro and spec pattern parsers.

- Better error messages
- Handle more inputs
parent 45b378c1
......@@ -128,11 +128,11 @@ Ltac parse s :=
| intro_pat => constr:([s])
| list string =>
lazymatch eval vm_compute in (mjoin <$> mapM parse s) with
| Some ?pats => pats | _ => fail "invalid list intro_pat" s
| Some ?pats => pats | _ => fail "intro_pat.parse: cannot parse" s
end
| string =>
lazymatch eval vm_compute in (parse s) with
| Some ?pats => pats | _ => fail "invalid list intro_pat" s
| Some ?pats => pats | _ => fail "intro_pat.parse: cannot parse" s
end
| ident => constr:([IIdent s])
| ?X => fail "intro_pat.parse:" s "has unexpected type" X
......@@ -142,7 +142,7 @@ Ltac parse_one s :=
| intro_pat => s
| string =>
lazymatch eval vm_compute in (parse s) with
| Some [?pat] => pat | _ => fail "invalid intro_pat" s
| Some [?pat] => pat | _ => fail "intro_pat.parse_one: cannot parse" s
end
| ?X => fail "intro_pat.parse_one:" s "has unexpected type" X
end.
......
......@@ -72,8 +72,11 @@ Definition parse (s : string) : option (list spec_pat) :=
Ltac parse s :=
lazymatch type of s with
| list spec_pat => s
| spec_pat => constr:([s])
| string => lazymatch eval vm_compute in (parse s) with
| Some ?pats => pats | _ => fail "invalid list spec_pat" s
| Some ?pats => pats | _ => fail "spec_pat.parse: cannot parse" s
end
| ident => constr:([SIdent s])
| ?X => fail "spec_pat.parse:" s "has unexpected type" X
end.
End spec_pat.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment