diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-04-09 20:09:43 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-04-09 20:09:43 +0200 |
| commit | e8e86cea2bffe23961f0a1bea8ee770343894858 (patch) | |
| tree | 2223ba98108ea98b86be4ee104a682109c56b74d /src/parser/Expr.hs | |
| parent | 9a4cf15fc0e724e6bc93c6530b47ca45836da5ba (diff) | |
| download | computorv2-e8e86cea2bffe23961f0a1bea8ee770343894858.tar.gz computorv2-e8e86cea2bffe23961f0a1bea8ee770343894858.tar.bz2 computorv2-e8e86cea2bffe23961f0a1bea8ee770343894858.zip | |
builtin cleaning
Diffstat (limited to 'src/parser/Expr.hs')
| -rw-r--r-- | src/parser/Expr.hs | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/parser/Expr.hs b/src/parser/Expr.hs index 5ba4be7..2d6937a 100644 --- a/src/parser/Expr.hs +++ b/src/parser/Expr.hs @@ -6,13 +6,13 @@ import Parser.Core import Expr -imaginaryP :: Parser Atom +imaginaryP :: Parser Expr imaginaryP = Imaginary <$> (floatP <* char 'i') -rationalP :: Parser Atom +rationalP :: Parser Expr rationalP = Rational <$> floatP -matrixP :: Parser Atom +matrixP :: Parser Expr matrixP = Matrix <$> (char '[' *> sepBy (char ';') matrixRowP <* char ']') where matrixRowP = char '[' *> sepBy (char ',') exprP <* char ']' @@ -27,16 +27,13 @@ termP = factorP `chainl1` factorOpP factorP :: Parser Expr factorP = endpointP `chainl1` expOpP where expOpP = infixOp "^" Exp - endpointP = parenthesisExprP <|> (EAtom <$> atomP) <|> functionP <|> variableP -variableP :: Parser Expr -variableP = Variable <$> alphaStringP - -functionP :: Parser Expr -functionP = Function <$> alphaStringP <*> parenthesisExprP - -parenthesisExprP :: Parser Expr -parenthesisExprP = parenthesize exprP - -atomP :: Parser Atom -atomP = imaginaryP <|> rationalP <|> matrixP + endpointP = parensExprP + <|> imaginaryP + <|> rationalP + <|> matrixP + <|> functionP + <|> variableP + where variableP = Variable <$> alphaStringP + functionP = Function <$> alphaStringP <*> parensExprP + parensExprP = parenthesize exprP |
