aboutsummaryrefslogtreecommitdiff
path: root/src/Parser.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Parser.hs')
-rw-r--r--src/Parser.hs12
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
38parseFloat :: Parser Expr 38parseFloat :: Parser Expr
39parseFloat = do 39parseFloat = 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
45symbol :: Parser Char 45symbol :: Parser Char
46symbol = oneOf "!#$%&|*+:/-=<?>@^_~" 46symbol = oneOf "!#$%&|*+:/-=<?>@^_~"
47 47
48parseAtom :: Parser Expr 48parseId :: Parser Expr
49parseAtom = do 49parseId = 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
78parseLispValue :: Parser Expr 78parseLispValue :: Parser Expr
79parseLispValue = 79parseLispValue =
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