Interface Expression
- All Superinterfaces:
AST
- All Known Implementing Classes:
BinaryOperation,BracketedExpression,Constant,FunctionCall,Lambda,ListDeclaration,ParameterToken,PropertyAccess,SelectAllExpression,StructDeclaration
An as yet Unrealized expression AST. Note that an Expression is a bit of executable riskscape code that operates on
an individual tuple (as scope), whereas a PipelineDeclaration is AST that organises the flow of execution.
Implementing bits of AST should not consider the underlying source code to be part of the objects identity, only the meaningful bits of the AST. For the most part, this boils down to ignoring whitespace and location the source.
-
Method Summary
Modifier and TypeMethodDescription<T,R> R accept(ExpressionVisitor<T, R> visitor, T data) booleanTests whether this expression is a literal expression - a literal expression is a constant expression that is unaffected by the scope in which it was realized/evaluated and contains no function-defined behaviour.Methods inherited from interface nz.org.riskscape.rl.ast.AST
getBoundary, isA, switchType, toSource
-
Method Details
-
accept
-
isLiteral
boolean isLiteral()Tests whether this expression is a literal expression - a literal expression is a constant expression that is unaffected by the scope in which it was realized/evaluated and contains no function-defined behaviour. Therefore a literal expression is one that contains no property access (unless the receiver is a literal) and no function calls.
A literal expression will always realize to being a constant (e.g.
RealizedExpression.isConstant()will return true), however there are constant expressions that are not literal.One edge case to be aware of is a limitation of the AST in determining literal expressions in contrived cases like this one -
{foo: 'bar', baz: qux}.foo. The struct is not literal, but the property being accessed is. But because the AST is relatively 'dumb', the expression itself is not literal. It can, however, be realized as a constant - realization is 'smarter' and can pick out the that the property being accessed is constant.
-