Finish R7RS token parser
Getty Ritter
10 years ago
| 82 | 82 | subsequent = initial <|> digit <|> specSubsequent |
| 83 | 83 | specSubsequent = expSign <|> oneOf ".@" |
| 84 | 84 | expSign = oneOf "+-" |
| 85 | symbolElement = undefined | |
| 86 | peculiar = undefined | |
| 85 | symbolElement = noneOf "\\|" | |
| 86 | <|> hexEscape | |
| 87 | <|> mnemEscape | |
| 88 | <|> ('|' <$ string "\\|") | |
| 89 | hexEscape = chr . fromIntegral <$> (string "\\x" *> hexNumber <* char ';') | |
| 90 | mnemEscape = '\a' <$ string "\\a" | |
| 91 | <|> '\b' <$ string "\\b" | |
| 92 | <|> '\t' <$ string "\\t" | |
| 93 | <|> '\n' <$ string "\\n" | |
| 94 | <|> '\r' <$ string "\\r" | |
| 95 | peculiar = (:[]) <$> expSign | |
| 96 | <|> cons2 <$> expSign <*> signSub <*> many subsequent | |
| 97 | <|> cons3 <$> expSign | |
| 98 | <*> char '.' | |
| 99 | <*> dotSub | |
| 100 | <*> many subsequent | |
| 101 | <|> cons2 <$> char '.' <*> dotSub <*> many subsequent | |
| 102 | dotSub = signSub <|> char '.' | |
| 103 | signSub = initial <|> expSign <|> char '@' | |
| 104 | cons2 a b cs = a : b : cs | |
| 105 | cons3 a b c ds = a : b : c : ds | |
| 87 | 106 | |
| 88 | 107 | -- | A helper function for defining parsers for arbitrary-base integers. |
| 89 | 108 | -- The first argument will be the base, and the second will be the |