diff --git a/src/Lean/Parser/Syntax.lean b/src/Lean/Parser/Syntax.lean index 5872ba0ae6..52a05056df 100644 --- a/src/Lean/Parser/Syntax.lean +++ b/src/Lean/Parser/Syntax.lean @@ -44,28 +44,25 @@ namespace Command def optPrio := optional ("[" >> numLit >> "]") -def «scoped» := parser! "scoped " -def «local» := parser! "local " -def attrKind := optional («scoped» <|> «local») def «prefix» := parser! "prefix" def «infix» := parser! "infix" def «infixl» := parser! "infixl" def «infixr» := parser! "infixr" def «postfix» := parser! "postfix" def mixfixKind := «prefix» <|> «infix» <|> «infixl» <|> «infixr» <|> «postfix» -@[builtinCommandParser] def «mixfix» := parser! attrKind >> mixfixKind >> optPrecedence >> optPrio >> ppSpace >> strLit >> darrow >> termParser +@[builtinCommandParser] def «mixfix» := parser! Term.attrKind >> mixfixKind >> optPrecedence >> optPrio >> ppSpace >> strLit >> darrow >> termParser -- NOTE: We use `suppressInsideQuot` in the following parsers because quotations inside them are evaluated in the same stage and -- thus should be ignored when we use `checkInsideQuot` to prepare the next stage for a builtin syntax change def identPrec := parser! ident >> optPrecedence def optKind : Parser := optional ("[" >> ident >> "]") def notationItem := ppSpace >> withAntiquot (mkAntiquot "notationItem" `Lean.Parser.Command.notationItem) (strLit <|> identPrec) -@[builtinCommandParser] def «notation» := parser! attrKind >> "notation" >> optPrecedence >> optPrio >> many notationItem >> darrow >> termParser +@[builtinCommandParser] def «notation» := parser! Term.attrKind >> "notation" >> optPrecedence >> optPrio >> many notationItem >> darrow >> termParser @[builtinCommandParser] def «macro_rules» := suppressInsideQuot (parser! "macro_rules" >> optKind >> Term.matchAlts) def parserKind := parser! ident def parserPrio := parser! numLit def parserKindPrio := parser! atomic (ident >> ", ") >> numLit def optKindPrio : Parser := optional ("[" >> (parserKindPrio <|> parserKind <|> parserPrio) >> "]") -@[builtinCommandParser] def «syntax» := parser! attrKind >> "syntax " >> optPrecedence >> optKindPrio >> many1 syntaxParser >> " : " >> ident +@[builtinCommandParser] def «syntax» := parser! Term.attrKind >> "syntax " >> optPrecedence >> optKindPrio >> many1 syntaxParser >> " : " >> ident @[builtinCommandParser] def syntaxAbbrev := parser! "syntax " >> ident >> " := " >> many1 syntaxParser @[builtinCommandParser] def syntaxCat := parser! "declare_syntax_cat " >> ident def macroArgSimple := parser! ident >> checkNoWsBefore "no space before ':'" >> ":" >> syntaxParser maxPrec diff --git a/src/Lean/Parser/Term.lean b/src/Lean/Parser/Term.lean index 2e198feffd..18b10881c8 100644 --- a/src/Lean/Parser/Term.lean +++ b/src/Lean/Parser/Term.lean @@ -152,7 +152,10 @@ def letDecl := nodeWithAntiquot "letDecl" `Lean.Parser.Term.letDecl (notFoll @[builtinTermParser] def «let*» := parser!:leadPrec withPosition ("let* " >> letDecl) >> optSemicolon termParser def attrArg : Parser := ident <|> strLit <|> numLit -- use `rawIdent` because of attribute names such as `instance` -def attrInstance := ppGroup $ parser! optional "scoped" >> rawIdent >> many (ppSpace >> attrArg) +def «scoped» := parser! "scoped " +def «local» := parser! "local " +def attrKind := optional («scoped» <|> «local») +def attrInstance := ppGroup $ parser! attrKind >> rawIdent >> many (ppSpace >> attrArg) def attributes := parser! "@[" >> sepBy1 attrInstance ", " >> "]" def letRecDecls := sepBy1 (group (optional «attributes» >> letDecl)) ", "