Skip to content

Commit

Permalink
add placeholder to identifier parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
javra committed Jul 10, 2024
1 parent 16cc192 commit 5957dc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Aegis/Parser.lean
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ inductive Parameter where
| userfunc (s : Identifier)
| libfunc (i : Identifier)
| tuple (ps : List Parameter)
| placeholder
deriving Repr, Inhabited, Hashable, BEq, ToExpr

end
Expand Down Expand Up @@ -62,6 +63,7 @@ partial def parameterToString : Parameter → String
| .usertype i => "ut@" ++ identifierToString i
| .userfunc i => "user@" ++ identifierToString i
| .libfunc i => "lib@" ++ identifierToString i
| .placeholder => "_"

end

Expand All @@ -84,6 +86,7 @@ syntax "end" : atom
syntax atom ("[" ident "]")? atomic("::"? "<" parameter,* ">")? ("::" identifier)? : identifier
syntax "[" num "]" : identifier

syntax "_" : parameter
syntax "-" num : parameter
syntax num : parameter
syntax "user@" identifier : parameter
Expand Down Expand Up @@ -133,6 +136,7 @@ partial def elabIdentifier : Syntax → Except String Identifier
| _ => .error "Could not elab identifier"

partial def elabParameter : TSyntax `parameter → Except String Parameter
| `(parameter|_) => .ok .placeholder
| `(parameter|-$n:num) => .ok <| .const <| -n.getNat
| `(parameter|user@$i) => do
let i ← elabIdentifier i
Expand Down
1 change: 1 addition & 0 deletions Aegis/Types.lean
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ partial def Parameter.quote : Parameter → Q(Parameter)
| .userfunc i => q(.userfunc $(Identifier.quote i))
| .libfunc i => q(.libfunc $(Identifier.quote i))
| .tuple ps => ParameterList.quote ps
| .placeholder => q(.placeholder)

partial def ParameterList.quote : List Parameter → Q(List Parameter)
| [] => q([])
Expand Down

0 comments on commit 5957dc8

Please sign in to comment.