diff options
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index dcbfdb1..9813f5c 100644 --- a/src/Parser.hs +++ b/src/Parser.hs | |||
@@ -3,7 +3,7 @@ module Parser ( parseLispValue | |||
3 | , parseString | 3 | , parseString |
4 | , parseInt | 4 | , parseInt |
5 | , parseFloat | 5 | , parseFloat |
6 | , parseAtom | 6 | , parseId |
7 | , parseList | 7 | , parseList |
8 | , parseQuote | 8 | , parseQuote |
9 | , parseDottedList | 9 | , parseDottedList |
@@ -37,7 +37,7 @@ parseInt = IntLiteral . read <$> many1 digit | |||
37 | 37 | ||
38 | parseFloat :: Parser Expr | 38 | parseFloat :: Parser Expr |
39 | parseFloat = do | 39 | parseFloat = do |
40 | characteristic <- many digit | 40 | characteristic <- many1 digit |
41 | char '.' | 41 | char '.' |
42 | mantissa <- many1 digit | 42 | mantissa <- many1 digit |
43 | return $ (FloatLiteral . read) $ characteristic ++ "." ++ mantissa | 43 | return $ (FloatLiteral . read) $ characteristic ++ "." ++ mantissa |
@@ -45,8 +45,8 @@ parseFloat = do | |||
45 | symbol :: Parser Char | 45 | symbol :: Parser Char |
46 | symbol = oneOf "!#$%&|*+:/-=<?>@^_~" | 46 | symbol = oneOf "!#$%&|*+:/-=<?>@^_~" |
47 | 47 | ||
48 | parseAtom :: Parser Expr | 48 | parseId :: Parser Expr |
49 | parseAtom = do | 49 | parseId = do |
50 | first <- letter <|> symbol | 50 | first <- letter <|> symbol |
51 | rest <- many (letter <|> symbol <|> digit) | 51 | rest <- many (letter <|> symbol <|> digit) |
52 | let atom = first:rest | 52 | let atom = first:rest |
@@ -77,12 +77,12 @@ parseQuote = do | |||
77 | 77 | ||
78 | parseLispValue :: Parser Expr | 78 | parseLispValue :: Parser Expr |
79 | parseLispValue = | 79 | parseLispValue = |
80 | try parseAtom | 80 | try parseId |
81 | <|> parseString | 81 | <|> parseString |
82 | <|> try parseFloat | ||
82 | <|> parseInt | 83 | <|> parseInt |
83 | <|> parseQuote | 84 | <|> parseQuote |
84 | -- TODO: figure out a way to have floats and dotted lists | 85 | -- TODO: figure out a way to have floats and dotted lists |
85 | -- <|> parseFloat | ||
86 | <|> do | 86 | <|> do |
87 | char '(' | 87 | char '(' |
88 | x <- try parseList <|> parseDottedList | 88 | x <- try parseList <|> parseDottedList |