howl-0.1.0.0: A small Wolfram Language interpreter and symbolic rewriting library
Safe HaskellNone
LanguageGHC2021

Howl.Parser

Description

Parse Wolfram Language expressions.

The parsed expression may be a compound expression, e.g. a sequence of semicolon-separated subexpressions.

Synopsis

Documentation

parseExprText :: Text -> Either String Expr #

Parse an expression from Text.

readExprFile :: MonadIO m => FilePath -> m (Either String Expr) #

Read and parse an expression from a file.

normalizeParsedExpr :: Expr -> Expr #

Normalize an expression into the canonical form used by Howl.

This is used for parser internals and tests. Users should prefer parseExprText, which already applies this normalization.

The normalization pass rewrites some surface syntax into more uniform expression forms. For example, it replaces - and / with expressions built from Plus, Times, and Power, flattens associative heads such as Plus and Times, and removes redundant Sequence wrappers.