Main expression handle (should only be used as parent class).
More...
#include <syntax.hpp>
|
|
std::size_t | depth |
| |
|
Expr * | lastEval = nullptr |
| |
Main expression handle (should only be used as parent class).
- See also
- StackFrameObj
To use Expr as local heap variable, use a StackFrameObj.
◆ equals()
| virtual bool Expr::equals |
( |
const Expr * |
expr, |
|
|
bool |
exact = false |
|
) |
| const |
|
inlinevirtualnoexcept |
Checks if this expression and expr have the same structure, Every expression has the same structure as '_' (it's called ANY after all).
- Parameters
-
| expr | The expression to compare to this. |
| exact | If true any must equal any and nothing else. Otherwise any is equal to anyting else. |
Reimplemented in LetExpr, AnyExpr, IfExpr, AtomExpr, LambdaExpr, IdExpr, IntExpr, NumExpr, UnOpExpr, and BiOpExpr.
◆ eval()
◆ evalWithLookup()
- Returns
- Returns Last evaluation if already computed (except assignments). If no last evaluation, evaluate. To reset evaluation "lastEval = nullptr".
- Parameters
-
◆ getExpressionType()
| ExprType Expr::getExpressionType |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Returns the type of expression.
- See also
- ExprType
◆ getIdentifiers()
| virtual std::vector<std::string> Expr::getIdentifiers |
( |
| ) |
const |
|
inlinevirtualnoexcept |
◆ getTokenPos()
| const TokenPos& Expr::getTokenPos |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Returns position of token in code.
◆ hasLastEval()
| bool Expr::hasLastEval |
( |
| ) |
const |
|
inlinenoexcept |
- Returns
- Returns true, if has last evaluation (not nullptr), otherwise false.
◆ optimize()
◆ replace()
| virtual Expr* Expr::replace |
( |
GCMain & |
gc, |
|
|
const std::string & |
name, |
|
|
Expr * |
expr |
|
) |
| const |
|
inlinevirtualnoexcept |
Replace all identifiers equal to name with expr.
- Parameters
-
| gc | |
| name | Identifer name to replace. If name is empty, every identifier will be replaced by AnyExpr(expr_any). |
| expr | The expression to replaces identifiers. |
- Returns
- Returns new expression, where matching identifiers are replaced. Returns itself if not possible (expression can't contain any identifiers) or if expression is a lambda function, where the <id> is equal to name.
Reimplemented in LetExpr, IfExpr, LambdaExpr, IdExpr, and BiOpExpr.
◆ toString()
| virtual std::string Expr::toString |
( |
| ) |
const |
|
inlinevirtualnoexcept |
The documentation for this class was generated from the following file: