on master help sign in
allow for negative IntAtoms in TutorialD parser
b8d7e0bAgentM
TutorialD/Interpreter/Base.hs+3
@@ -44,6 +44,9 @@ semi = Token.semi lexer
44whiteSpace :: Parser ()
44whiteSpace :: Parser ()
45whiteSpace = Token.whiteSpace lexer
45whiteSpace = Token.whiteSpace lexer
46
46
47+integer :: Parser (Integer)
48+integer = Token.integer lexer
49+
47atomTypeToTutDType :: AtomType -> Maybe T.Text
50atomTypeToTutDType :: AtomType -> Maybe T.Text
48atomTypeToTutDType atomType = case atomType of
51atomTypeToTutDType atomType = case atomType of
49 StringAtomType -> Just "char"
52 StringAtomType -> Just "char"
TutorialD/Interpreter/RelationalExpr.hs+1−3
@@ -240,9 +240,7 @@ stringAtomP :: Parser Atom
240stringAtomP = liftA (StringAtom . T.pack) (string "\"" *> many quotedChar <* string "\"")
240stringAtomP = liftA (StringAtom . T.pack) (string "\"" *> many quotedChar <* string "\"")
241
241
242intAtomP :: Parser Atom
242intAtomP :: Parser Atom
243−intAtomP = do
243+intAtomP = (IntAtom . fromIntegral) <$> integer
244− intstr <- many1 digit
245− return $ IntAtom (read intstr)
246
244
247boolAtomP :: Parser Atom
245boolAtomP :: Parser Atom
248boolAtomP = do
246boolAtomP = do