refactor #[attribute] stuff
This commit is contained in:
parent
246d80eea2
commit
50984aa1aa
4 changed files with 237 additions and 160 deletions
|
@ -395,36 +395,37 @@ tests = "parser" :- [
|
|||
parseFails term "caseω n return ℕ of { succ ⇒ 5 }"
|
||||
],
|
||||
|
||||
"definitions" :- [
|
||||
"definitions" :-
|
||||
let definition = flip definition [] in [
|
||||
parseMatch definition "defω x : {a} × {b} = ('a, 'b);"
|
||||
`(MkPDef (PQ Any _) "x"
|
||||
(PConcrete
|
||||
(Just (Sig (Unused _) (Enum ["a"] _) (Enum ["b"] _) _))
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _),
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _ _ _ _),
|
||||
parseMatch definition "def# x : {a} ** {b} = ('a, 'b)"
|
||||
`(MkPDef (PQ Any _) "x"
|
||||
(PConcrete
|
||||
(Just (Sig (Unused _) (Enum ["a"] _) (Enum ["b"] _) _))
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _),
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _ _ _ _),
|
||||
parseMatch definition "def ω.x : {a} × {b} = ('a, 'b)"
|
||||
`(MkPDef (PQ Any _) "x"
|
||||
(PConcrete
|
||||
(Just (Sig (Unused _) (Enum ["a"] _) (Enum ["b"] _) _))
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _),
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _ _ _ _),
|
||||
parseMatch definition "def x : {a} × {b} = ('a, 'b)"
|
||||
`(MkPDef (PQ Any _) "x"
|
||||
(PConcrete
|
||||
(Just (Sig (Unused _) (Enum ["a"] _) (Enum ["b"] _) _))
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _),
|
||||
(Pair (Tag "a" _) (Tag "b" _) _)) _ _ _ _),
|
||||
parseMatch definition "def0 A : ★⁰ = {a, b, c}"
|
||||
`(MkPDef (PQ Zero _) "A"
|
||||
(PConcrete (Just $ TYPE 0 _) (Enum ["a", "b", "c"] _)) _),
|
||||
(PConcrete (Just $ TYPE 0 _) (Enum ["a", "b", "c"] _)) _ _ _ _),
|
||||
parseMatch definition "postulate yeah : ℕ"
|
||||
`(MkPDef (PQ Any _) "yeah" (PPostulate (NAT _)) _),
|
||||
`(MkPDef (PQ Any _) "yeah" (PPostulate (NAT _)) _ _ _ _),
|
||||
parseMatch definition "postulateω yeah : ℕ"
|
||||
`(MkPDef (PQ Any _) "yeah" (PPostulate (NAT _)) _),
|
||||
`(MkPDef (PQ Any _) "yeah" (PPostulate (NAT _)) _ _ _ _),
|
||||
parseMatch definition "postulate0 FileHandle : ★"
|
||||
`(MkPDef (PQ Zero _) "FileHandle" (PPostulate (TYPE 0 _)) _),
|
||||
`(MkPDef (PQ Zero _) "FileHandle" (PPostulate (TYPE 0 _)) _ _ _ _),
|
||||
parseFails definition "postulate not-a-postulate : ℕ = 69",
|
||||
parseFails definition "postulate not-a-postulate = 69",
|
||||
parseFails definition "def not-a-def : ℕ"
|
||||
|
@ -432,52 +433,44 @@ tests = "parser" :- [
|
|||
|
||||
"top level" :- [
|
||||
parseMatch input "def0 A : ★⁰ = {}; def0 B : ★¹ = A;"
|
||||
`([PD $ MkPDecl []
|
||||
(PDef $ MkPDef (PQ Zero _) "A"
|
||||
(PConcrete (Just $ TYPE 0 _) (Enum [] _)) _) _,
|
||||
PD $ MkPDecl []
|
||||
(PDef $ MkPDef (PQ Zero _) "B"
|
||||
(PConcrete (Just $ TYPE 1 _) (V "A" {})) _) _]),
|
||||
`([PD $ PDef $ MkPDef (PQ Zero _) "A"
|
||||
(PConcrete (Just $ TYPE 0 _) (Enum [] _)) PSucceed False Nothing _,
|
||||
PD $ PDef $ MkPDef (PQ Zero _) "B"
|
||||
(PConcrete (Just $ TYPE 1 _) (V "A" {})) PSucceed False Nothing _]),
|
||||
parseMatch input "def0 A : ★⁰ = {} def0 B : ★¹ = A" $
|
||||
`([PD $ MkPDecl []
|
||||
(PDef $ MkPDef (PQ Zero _) "A"
|
||||
(PConcrete (Just $ TYPE 0 _) (Enum [] _)) _) _,
|
||||
PD $ MkPDecl []
|
||||
(PDef $ MkPDef (PQ Zero _) "B"
|
||||
(PConcrete (Just $ TYPE 1 _) (V "A" {})) _) _]),
|
||||
`([PD $ PDef $ MkPDef (PQ Zero _) "A"
|
||||
(PConcrete (Just $ TYPE 0 _) (Enum [] _)) PSucceed False Nothing _,
|
||||
PD $ PDef $ MkPDef (PQ Zero _) "B"
|
||||
(PConcrete (Just $ TYPE 1 _) (V "A" {})) PSucceed False Nothing _]),
|
||||
note "empty input",
|
||||
parsesAs input "" [],
|
||||
parseFails input ";;;;;;;;;;;;;;;;;;;;;;;;;;",
|
||||
parseMatch input "namespace a {}"
|
||||
`([PD $ MkPDecl [] (PNs $ MkPNamespace [< "a"] [] _) _]),
|
||||
`([PD $ PNs $ MkPNamespace [< "a"] [] PSucceed _]),
|
||||
parseMatch input "namespace a.b.c {}"
|
||||
`([PD $ MkPDecl []
|
||||
(PNs $ MkPNamespace [< "a", "b", "c"] [] _) _]),
|
||||
`([PD $ PNs $ MkPNamespace [< "a", "b", "c"] [] PSucceed _]),
|
||||
parseMatch input "namespace a {namespace b {}}"
|
||||
`([PD (MkPDecl []
|
||||
(PNs $ MkPNamespace [< "a"]
|
||||
[MkPDecl [] (PNs $ MkPNamespace [< "b"] [] _) _] _) _)]),
|
||||
`([PD (PNs $ MkPNamespace [< "a"]
|
||||
[PNs $ MkPNamespace [< "b"] [] PSucceed _] PSucceed _)]),
|
||||
parseMatch input "namespace a {def x = 't ∷ {t}}"
|
||||
`([PD (MkPDecl []
|
||||
(PNs $ MkPNamespace [< "a"]
|
||||
[MkPDecl []
|
||||
(PDef $ MkPDef (PQ Any _) "x"
|
||||
(PConcrete Nothing
|
||||
(Ann (Tag "t" _) (Enum ["t"] _) _)) _) _] _) _)]),
|
||||
`([PD (PNs $ MkPNamespace [< "a"]
|
||||
[PDef $ MkPDef (PQ Any _) "x"
|
||||
(PConcrete Nothing (Ann (Tag "t" _) (Enum ["t"] _) _))
|
||||
PSucceed False Nothing _]
|
||||
PSucceed _)]),
|
||||
parseMatch input "namespace a {def x : {t} = 't} def y = a.x"
|
||||
`([PD (MkPDecl []
|
||||
(PNs $ MkPNamespace [< "a"]
|
||||
[MkPDecl []
|
||||
(PDef $ MkPDef (PQ Any _) "x"
|
||||
(PConcrete (Just (Enum ["t"] _))
|
||||
(Tag "t" _)) _) _] _) _),
|
||||
PD (MkPDecl []
|
||||
(PDef $ MkPDef (PQ Any _) "y"
|
||||
(PConcrete Nothing (V (MakePName [< "a"] "x") Nothing _)) _) _)]),
|
||||
`([PD (PNs $ MkPNamespace [< "a"]
|
||||
[PDef $ MkPDef (PQ Any _) "x"
|
||||
(PConcrete (Just (Enum ["t"] _)) (Tag "t" _))
|
||||
PSucceed False Nothing _]
|
||||
PSucceed _),
|
||||
PD (PDef $ MkPDef (PQ Any _) "y"
|
||||
(PConcrete Nothing (V (MakePName [< "a"] "x") Nothing _))
|
||||
PSucceed False Nothing _)]),
|
||||
parseMatch input #" load "a.quox"; def b = a.b "#
|
||||
`([PLoad "a.quox" _,
|
||||
PD (MkPDecl []
|
||||
(PDef $ MkPDef (PQ Any _) "b"
|
||||
(PConcrete Nothing (V (MakePName [< "a"] "b") Nothing _)) _) _)])
|
||||
PD (PDef $ MkPDef (PQ Any _) "b"
|
||||
(PConcrete Nothing (V (MakePName [< "a"] "b") Nothing _))
|
||||
PSucceed False Nothing _)])
|
||||
]
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue