hpp-0.4.1: 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 

Instances

Eq Expr Source # 

Methods

(==) :: Expr -> Expr -> Bool #

(/=) :: Expr -> Expr -> Bool #

Ord Expr Source # 

Methods

compare :: Expr -> Expr -> Ordering #

(<) :: Expr -> Expr -> Bool #

(<=) :: Expr -> Expr -> Bool #

(>) :: Expr -> Expr -> Bool #

(>=) :: Expr -> Expr -> Bool #

max :: Expr -> Expr -> Expr #

min :: Expr -> Expr -> Expr #

Show Expr Source # 

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

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 String] -> 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.