hpp-0.3.0.0: A Haskell pre-processor

Safe HaskellSafe
LanguageHaskell2010

Hpp.Expr

Description

An expression language corresponding to the subset of C syntax that may be used in preprocessor conditional directives. See https://gcc.gnu.org/onlinedocs/cpp/If.html

Synopsis

Documentation

data Expr Source

Expressions are literal values, binary operators applied to two sub-expressions, or unary operators applied to a single sub-expression.

Constructors

ELit Lit 
EBinOp BinOp Expr Expr 
EUnaryOp UnaryOp Expr 

readLitInt :: String -> Maybe CppInt Source

Read a literal integer. These may be decimal, octal, or hexadecimal, and may have a case-insensitive suffix of u, l, or ul.

parseExpr :: [Token] -> Maybe Expr Source

Try to read an Expr from a sequence of Tokens.

renderExpr :: Expr -> String Source

Pretty-print an Expr to something semantically equivalent to the original C syntax (some parentheses may be added).

evalExpr :: Expr -> Int Source

All Exprs can be evaluated to an Int.