fix: antiquotation for all categories

This commit is contained in:
Leonardo de Moura 2020-01-22 11:51:51 -08:00
parent e8c54ad1bf
commit 642850efb2

View file

@ -1755,13 +1755,20 @@ match (parserExtension.getState env).categories.find? catName with
| none => false
| some cat => cat.leadingIdentAsSymbol
def categoryParserFnImpl (catName : Name) : ParserFn leading :=
def categoryParserFnImplAux (catName : Name) : ParserFn leading :=
fun rbp ctx s =>
let categories := (parserExtension.getState ctx.env).categories;
match categories.find? catName with
| some cat => prattParser catName cat.tables cat.leadingIdentAsSymbol rbp ctx s
| none => s.mkUnexpectedError ("unknown parser category '" ++ toString catName ++ "'")
private def catNameToString : Name → String
| Name.str Name.anonymous s _ => s
| n => n.toString
def categoryParserFnImpl (catName : Name) : ParserFn leading :=
orelseFn (mkAntiquot (catNameToString catName) none false).fn (categoryParserFnImplAux catName)
@[init] def setCategoryParserFnRef : IO Unit :=
categoryParserFnRef.set categoryParserFnImpl