diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-03-16 14:15:42 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-03-16 14:15:42 +0100 |
| commit | 8c8f6155f1b05230c271059c52a503211aec872b (patch) | |
| tree | 53626fa32ad3f6178b42a9dc5db588ee01277cd5 /src/parser/expr.hs | |
| parent | d17423cba7c15a26f835a6fa578ecb48b80d8aab (diff) | |
| download | computorv2-8c8f6155f1b05230c271059c52a503211aec872b.tar.gz computorv2-8c8f6155f1b05230c271059c52a503211aec872b.tar.bz2 computorv2-8c8f6155f1b05230c271059c52a503211aec872b.zip | |
file Renaming, basic REPL
Diffstat (limited to 'src/parser/expr.hs')
| -rw-r--r-- | src/parser/expr.hs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/parser/expr.hs b/src/parser/expr.hs deleted file mode 100644 index b84362d..0000000 --- a/src/parser/expr.hs +++ /dev/null @@ -1,45 +0,0 @@ -module Parser.Expr where - -import Control.Applicative - -import Parser.Core -import Atom -import Expr - - -imaginaryP :: Parser Atom -imaginaryP = AImaginary <$> (floatP <* char 'i') - -rationalP :: Parser Atom -rationalP = ARational <$> floatP - -termOpP :: Parser (Expr -> Expr -> Expr) -termOpP = infixOp "+" Add <|> infixOp "-" Sub - -factorOpP :: Parser (Expr -> Expr -> Expr) -factorOpP = infixOp "*" Mul <|> infixOp "/" Div <|> infixOp "%" Mod - -expOpP :: Parser (Expr -> Expr -> Expr) -expOpP = infixOp "^" Exp - -exprP :: Parser Expr -exprP = termP `chainl1` termOpP - -termP :: Parser Expr -termP = factorP `chainl1` factorOpP - -variableP :: Parser Expr -variableP = Variable <$> alphaStringP - -functionP :: Parser Expr -functionP = Function <$> alphaStringP <*> parenthesisExprP - -factorP :: Parser Expr -factorP = endpointP `chainl1` expOpP - where endpointP = parenthesisExprP <|> (EAtom <$> atomP) <|> functionP <|> variableP - -parenthesisExprP :: Parser Expr -parenthesisExprP = parenthesize exprP - -atomP :: Parser Atom -atomP = imaginaryP <|> rationalP |
