@@ -4,10 +4,20 @@ import Data.Bool.Extra
44
55import public Text.Parser.Core
66import public Text.Quantity
7+import public Text.Token
78
89%access export
910%default total
1011
12+||| Parse a terminal based on a kind of token.
13+match : (Eq k, TokenKind k) =>
14+ (kind : k) ->
15+ Grammar (Token k) True (tokType kind)
16+match kind = terminal $
17+ \(Tok kind' text) => if kind' == kind
18+ then Just $ tokValue kind text
19+ else Nothing
20+
1121||| Optionally parse a thing, with a default value if the grammar doesn't
1222||| match. May match the empty input.
1323option : {c : Bool} ->