add let
to frontend syntax
This commit is contained in:
parent
59e7a457a6
commit
68d8019f00
6 changed files with 55 additions and 0 deletions
|
@ -264,6 +264,9 @@ mutual
|
|||
<*> fromPTermDScope ds ns [< j1] val1
|
||||
<*> pure loc
|
||||
|
||||
Let (qty, x, rhs) body loc =>
|
||||
?fromPTerm_let
|
||||
|
||||
private
|
||||
fromPTermEnumArms : Loc -> Context' PatVar d -> Context' PatVar n ->
|
||||
List (PTagVal, PTerm) ->
|
||||
|
|
|
@ -261,6 +261,9 @@ reserved =
|
|||
Word "caseω" `Or` Word "case#",
|
||||
Word1 "return",
|
||||
Word1 "of",
|
||||
Word1 "let", Word1 "in",
|
||||
Word1 "let0", Word1 "let1",
|
||||
Word "letω" `Or` Word "let#",
|
||||
Word1 "fst", Word1 "snd",
|
||||
Word1 "_",
|
||||
Word1 "Eq",
|
||||
|
|
|
@ -585,13 +585,28 @@ where
|
|||
foldr (\(q, x, s), t => Pi q x s t loc) cod $ toDoms (toQty q) doms
|
||||
|
||||
|
||||
letIntro : FileName -> Grammar True PQty
|
||||
letIntro fname =
|
||||
withLoc fname (PQ Zero <$ res "let0")
|
||||
<|> withLoc fname (PQ One <$ res "let1")
|
||||
<|> withLoc fname (PQ Any <$ res "letω")
|
||||
<|> do resC "let"
|
||||
qty fname <* needRes "." <|> defLoc fname (PQ One)
|
||||
|
||||
export
|
||||
letTerm : FileName -> Grammar True PTerm
|
||||
letTerm fname = withLoc fname $ do
|
||||
qty <- letIntro fname
|
||||
x <- patVar fname <* mustWork (resC "=")
|
||||
rhs <- assert_total term fname <* mustWork (resC "in")
|
||||
body <- assert_total term fname
|
||||
pure $ Let (qty, x, rhs) body
|
||||
|
||||
-- term : FileName -> Grammar True PTerm
|
||||
term fname = lamTerm fname
|
||||
<|> piTerm fname
|
||||
<|> sigmaTerm fname
|
||||
<|> letTerm fname
|
||||
|
||||
|
||||
export
|
||||
|
|
|
@ -100,6 +100,8 @@ namespace PTerm
|
|||
| Coe (PatVar, PTerm) PDim PDim PTerm Loc
|
||||
| Comp (PatVar, PTerm) PDim PDim PTerm PDim
|
||||
(PatVar, PTerm) (PatVar, PTerm) Loc
|
||||
|
||||
| Let (PQty, PatVar, PTerm) PTerm Loc
|
||||
%name PTerm s, t
|
||||
|
||||
public export
|
||||
|
@ -144,6 +146,7 @@ Located PTerm where
|
|||
(Ann _ _ loc).loc = loc
|
||||
(Coe _ _ _ _ loc).loc = loc
|
||||
(Comp _ _ _ _ _ _ _ loc).loc = loc
|
||||
(Let _ _ loc).loc = loc
|
||||
|
||||
export
|
||||
Located PCaseBody where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue