0 | module Parser.Rule.Package
2 | import public Parser.Lexer.Package
6 | import Core.Name.Namespace
12 | Rule = Grammar () Token True
15 | EmptyRule : Type -> Type
16 | EmptyRule = Grammar () Token False
20 | equals = terminal "Expected equals" $
27 | lte = terminal "Expected <=" $
34 | gte = terminal "Expected >=" $
41 | lt = terminal "Expected <=" $
48 | gt = terminal "Expected >=" $
55 | eqop = terminal "Expected ==" $
62 | andop = terminal "Expected &&" $
69 | eoi = terminal "Expected end of input" $
71 | EndOfInput => Just ()
75 | exactProperty : String -> Rule String
76 | exactProperty p = terminal ("Expected property " ++ p) $
78 | DotSepIdent Nothing p' =>
79 | if p == p' then Just p else Nothing
83 | stringLit : Rule String
84 | stringLit = terminal "Expected string" $
86 | StringLit str => Just str
90 | integerLit : Rule Integer
91 | integerLit = terminal "Expected integer" $
93 | IntegerLit i => Just i
97 | namespacedIdent : Rule (Maybe Namespace, String)
98 | namespacedIdent = terminal "Expected namespaced identifier" $
100 | DotSepIdent ns n => Just (ns, n)
104 | moduleIdent : Rule ModuleIdent
105 | moduleIdent = terminal "Expected module identifier" $
107 | DotSepIdent ns m =>
108 | Just $
nsAsModuleIdent $
109 | mkNestedNamespace ns m
113 | packageName : Rule String
114 | packageName = terminal "Expected package name" $
116 | DotSepIdent Nothing str =>
117 | if isIdent AllowDashes str
124 | dot' = terminal "Expected dot" $
130 | sep' = terminal "Expected separator" $
132 | Separator => Just ()
136 | sep : Rule t -> Rule (List t)
137 | sep rule = forget <$> sepBy1 sep' rule