feat: add declModifiers to constructor declarations
The goal is to allow users to attach doc strings and `private/protected` to constructor declarations. TODO: reject non applicable modifiers such as `unsafe` and `partial`. cc @Kha
This commit is contained in:
parent
83431dc88e
commit
6e12987dd9
2 changed files with 4 additions and 4 deletions
|
|
@ -130,10 +130,10 @@ withDeclId declId fun name => do
|
|||
levelNames ← getLevelNames;
|
||||
declName ← mkDeclName declId modifiers name;
|
||||
ctors ← (decl.getArg (numTokens + 2)).getArgs.mapM fun ctor => do {
|
||||
-- def ctor := parser! " | " >> ident >> optional inferMod >> optDeclSig
|
||||
let ctorName := ctor.getIdAt 1;
|
||||
-- def ctor := parser! declModifiers >> " | " >> ident >> optional inferMod >> optDeclSig
|
||||
let ctorName := ctor.getIdAt 2;
|
||||
let ctorName := declName ++ ctorName;
|
||||
checkNotAlreadyDeclared (ctor.getArg 1) ctorName;
|
||||
checkNotAlreadyDeclared (ctor.getArg 2) ctorName;
|
||||
pure (ctorName, ctor)
|
||||
};
|
||||
pure {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ def «instance» := parser! "instance " >> optional declId >> declSig >> d
|
|||
def «axiom» := parser! "axiom " >> declId >> declSig
|
||||
def «example» := parser! "example " >> declSig >> declVal
|
||||
def inferMod := parser! try ("{" >> "}")
|
||||
def ctor := parser! " | " >> ident >> optional inferMod >> optDeclSig
|
||||
def ctor := parser! declModifiers >> " | " >> ident >> optional inferMod >> optDeclSig
|
||||
def «inductive» := parser! "inductive " >> declId >> optDeclSig >> many ctor
|
||||
def classInductive := parser! try ("class " >> "inductive ") >> declId >> optDeclSig >> many ctor
|
||||
def structExplicitBinder := parser! "(" >> many ident >> optional inferMod >> optDeclSig >> optional Term.binderDefault >> ")"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue