From 7364919175a6bc988d17523005917933f0680492 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Wed, 19 Jul 2017 12:30:10 +0000 Subject: Nomenclature: Application type is now Expression --- Sil/Parse.icl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Sil/Parse.icl') diff --git a/Sil/Parse.icl b/Sil/Parse.icl index 2e21d08..2ee2bc1 100644 --- a/Sil/Parse.icl +++ b/Sil/Parse.icl @@ -139,17 +139,17 @@ initialisation = statement :: Parser Token Statement statement = declaration - <|> liftM Application (application <* item TSemicolon) + <|> liftM Application (expression <* item TSemicolon) <|> return <|> if` //<|> while <|> machinecode where declaration :: Parser Token Statement - declaration = liftM2 Declaration name (item TAssign *> application <* item TSemicolon) + declaration = liftM2 Declaration name (item TAssign *> expression <* item TSemicolon) return :: Parser Token Statement - return = liftM Return (item TReturn *> optional application <* item TSemicolon) + return = liftM Return (item TReturn *> optional expression <* item TSemicolon) machinecode :: Parser Token Statement machinecode = (\(TMachineCode s) -> MachineStm s) <$> satisfy isMachineCode @@ -157,19 +157,19 @@ where if` :: Parser Token Statement if` = item TIf *> - parenthised application >>= \cond -> + parenthised expression >>= \cond -> braced codeblock >>= \iftrue -> many elseif >>= \elseifs -> optional (item TElse *> braced codeblock) >>= \iffalse -> pure $ If [(cond,iftrue):elseifs] iffalse where elseif = list [TElse, TIf] *> - parenthised application >>= \cond -> + parenthised expression >>= \cond -> braced codeblock >>= \block -> pure (cond, block) -application :: Parser Token Application -application +expression :: Parser Token Expression +expression = rightAssoc (op TDoubleBar LogOr) $ rightAssoc (op TDoubleAmpersand LogAnd) $ rightAssoc (op TDoubleEquals Equals) @@ -187,17 +187,17 @@ where op :: Token Op2 -> Parser Token Op2 op token operator = item token *> pure operator - rightAssoc :: (Parser Token Op2) (Parser Token Application) -> Parser Token Application + rightAssoc :: (Parser Token Op2) (Parser Token Expression) -> Parser Token Expression rightAssoc opp appp = appp >>= \e1 -> optional (opp >>= \op -> rightAssoc opp appp >>= \e -> pure (op,e)) >>= pure o maybe e1 (\(op,e2) -> BuiltinApp2 e1 op e2) - leftAssoc :: (Parser Token Op2) (Parser Token Application) -> Parser Token Application + leftAssoc :: (Parser Token Op2) (Parser Token Expression) -> Parser Token Expression leftAssoc opp appp = appp >>= \e1 -> many (opp >>= \op -> appp >>= \e -> pure (op,e)) >>= foldM (\e (op,e2) -> pure $ BuiltinApp2 e op e2) e1 - noInfix :: Parser Token Application + noInfix :: Parser Token Expression noInfix - = liftM2 App name (item TParenOpen *> seplist TComma application <* item TParenClose) + = liftM2 App name (item TParenOpen *> seplist TComma expression <* item TParenClose) <|> liftM (BuiltinApp Neg) (item TTilde *> noInfix) <|> liftM Literal literal <|> liftM Name name -- cgit v1.2.3