😎 Task 4 and 5
This commit is contained in:
@@ -51,7 +51,7 @@ lVName = lexeme $ try $ do
|
||||
|
||||
lStringLit :: Parser String
|
||||
lStringLit =
|
||||
lexeme $ read <$> some (satisfy isAlpha) <* notFollowedBy (satisfy isAlphaNum)
|
||||
lexeme $ some (satisfy (/= '"'))
|
||||
|
||||
lInteger :: Parser Integer
|
||||
lInteger =
|
||||
@@ -101,6 +101,16 @@ pLExp =
|
||||
<$> (lKeyword "if" *> pExp)
|
||||
<*> (lKeyword "then" *> pExp)
|
||||
<*> (lKeyword "else" *> pExp),
|
||||
Lambda
|
||||
<$> (lString "\\" *> lVName)
|
||||
<*> (lString "->" *> pExp),
|
||||
TryCatch
|
||||
<$> (lKeyword "try" *> pExp)
|
||||
<*> (lKeyword "catch" *> pExp),
|
||||
Let
|
||||
<$> (lKeyword "let" *> lVName)
|
||||
<*> (lString "=" *> pExp)
|
||||
<*> (lKeyword "in" *> pExp),
|
||||
pFExp
|
||||
]
|
||||
|
||||
@@ -110,7 +120,10 @@ pExp3 =
|
||||
[
|
||||
Print
|
||||
<$> (lKeyword "print" *> pStringLit)
|
||||
<*> pExp,
|
||||
<*> pAtom,
|
||||
KvGet <$> (lKeyword "get" *> pAtom),
|
||||
KvPut <$> (lKeyword "put" *> pAtom)
|
||||
<*> pAtom,
|
||||
pLExp
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user