@@ -57,13 +57,13 @@ opt l = l <|> Empty
57||| Recognise a sequence of at least one sub-lexers
57||| Recognise a sequence of at least one sub-lexers
59some : Lexer -> Lexer
59some : Lexer -> Lexer
60−some l = l <+> (some l <|> Empty)
60+some l = l <+> opt (some l)
62||| Recognise a sequence of at zero or more sub-lexers. This is not
62||| Recognise a sequence of at zero or more sub-lexers. This is not
63||| guaranteed to consume input
63||| guaranteed to consume input
65many : Lexer -> Recognise False
65many : Lexer -> Recognise False
66−many l = some l <|> Empty
66+many l = opt (some l)
68||| Recognise the first matching lexer from a non-empty list.
68||| Recognise the first matching lexer from a non-empty list.
@@ -76,11 +76,8 @@ choice (x :: xs@(_ :: _)) = x <|> choice xs
77||| Useful for defining comments.
77||| Useful for defining comments.
79−manyTill : (l : Lexer)
80− -> (end : Lexer) -> Recognise False
79+manyTill : (l : Lexer) -> (end : Lexer) -> Recognise False
81−manyTill l end = end
80+manyTill l end = end <|> opt (l <+> manyTill l end)
82− <|> (l <+> manyTill l end)
85||| Recognise any character
82||| Recognise any character
@@ -188,7 +185,7 @@ charLit = is '\'' <+> strChar <+> is '\''
188||| Recognise an integer literal (possibly with a '-' prefix)
185||| Recognise an integer literal (possibly with a '-' prefix)
190intLit : Lexer
187intLit : Lexer
191−intLit = (is '-' <|> Empty) <+> digits
188+intLit = opt (is '-') <+> digits
193||| A mapping from lexers to the tokens they produce.
190||| A mapping from lexers to the tokens they produce.
194||| This is a list of pairs `(Lexer, String -> tokenType)`
191||| This is a list of pairs `(Lexer, String -> tokenType)`