Class ConstantArithmeticOrError
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.ConstantArithmeticOrError
- All Implemented Interfaces:
Consumer<EK9Parser.ExpressionContext>
final class ConstantArithmeticOrError
extends TypedSymbolAccess
implements Consumer<EK9Parser.ExpressionContext>
Detects arithmetic expressions that always produce a constant result (E08083).
Two sub-patterns are detected:
- Self-arithmetic: same symbol on both sides of
-,/,mod, orrem. For examplex - xis always 0,x / xis always 1. - Trivial modular: right operand is integer literal
1withmodorrem. For examplex mod 1is always 0.
x + x (valid doubling) and x * x (valid squaring) are NOT flagged.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionConstantArithmeticOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
ConstantArithmeticOrError
ConstantArithmeticOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.ExpressionContext>
-