Class BinaryExpressions
java.lang.Object
org.ek9lang.compiler.phase1.BinaryExpressions
THE reading of a binary or prefix
expression alternative for the phase-1 operand-parentheses checks -
E08269 (CoalescingOperandParenthesesOrError), E08273 (NotOperandParenthesesOrError) and E08274
(DoubleNegationOrError). Use it for any further rule over an operator's operand rather than another
private copy.
A binary expression is any alternative with both a left and a right operand. A prefix expression is
one of the symbol/word prefix alternatives of EK9.g4 (PREFIX_OPERATORS) with no left.
Word not is a prefix too, but it is the loose negation and is read on its own (isWordNot(EK9Parser.ExpressionContext)). A
parenthesised operand is a primary, so it is never a binary or prefix expression here.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe prefix operators ofexpressionother than wordnot, exactly asEK9.g4lists them:$$(TOJSON),$(DOLLAR),#^(PROMOTE),length [of],#<(PREFIX),#>(SUFFIX),#?(HASHCODE),abs [of],sqrt [of],~(TILDE) and unary-(SUB with no left operand). -
Method Summary
Modifier and TypeMethodDescription(package private) static boolean(package private) static booleanA negation applied to one operand: wordnot b,~bor unary-x.(package private) static booleanA prefix expression (not wordnot): the operator comes first and there is one operand,prefixOperandOf(EK9Parser.ExpressionContext).(package private) static booleanA literal with its sign folded in (-5,-2.5,-10#GBP): not a negation - it calls nothing - but SPELT with one, so E08274 counts it when a negation is applied to it (- -5is5).(package private) static booleanWordnotapplied to an operand:not b.(package private) static EK9Parser.ExpressionContextnegatedOperandOf(EK9Parser.ExpressionContext negation) What a negation is applied to, looking through parentheses (Q8): innot (not b)and-(-x)the operand of the outer negation is the inner one.(package private) static EK9Parser.ExpressionContextThe negation thatctxis the operand of, looking through parentheses (ctxisnot bin~((not b))); null when it is not the operand of a negation.(package private) static org.antlr.v4.runtime.TokenThe operator token of a binary expression.(package private) static EK9Parser.ExpressionContextThe single operand of a prefix expression (or of wordnot).(package private) static StringsourceText(org.antlr.v4.runtime.ParserRuleContext ctx) The source as written (getText() would drop the spaces).(package private) static EK9Parser.ExpressionContextThe expression inside any number of enclosing parentheses:bfor((b)).
-
Field Details
-
PREFIX_OPERATORS
The prefix operators ofexpressionother than wordnot, exactly asEK9.g4lists them:$$(TOJSON),$(DOLLAR),#^(PROMOTE),length [of],#<(PREFIX),#>(SUFFIX),#?(HASHCODE),abs [of],sqrt [of],~(TILDE) and unary-(SUB with no left operand). Pinned against the grammar byBinaryExpressionsTest.
-
-
Method Details
-
isPrefix
A prefix expression (not wordnot): the operator comes first and there is one operand,prefixOperandOf(EK9Parser.ExpressionContext). -
prefixOperandOf
The single operand of a prefix expression (or of wordnot). -
isWordNot
Wordnotapplied to an operand:not b. Not thenotinsideis not empty,not matches,not containsornot in, which is aneglabel on another operator. -
isNegation
A negation applied to one operand: wordnot b,~bor unary-x. Keyed on the OPERATOR, not the spelling (Steve, 2026-10-08, Q9): all three call_negate(OperatorMap.getPrefixForward(String), the mapping IR generation lowers them through), so any two of them applied to one operand cancel out (E08274,DoubleNegationOrError). Binary-has a left operand and is subtraction, never a negation, and--is the decrement token, never two negations. -
isSignedLiteral
A literal with its sign folded in (-5,-2.5,-10#GBP): not a negation - it calls nothing - but SPELT with one, so E08274 counts it when a negation is applied to it (- -5is5). -
negatedOperandOf
What a negation is applied to, looking through parentheses (Q8): innot (not b)and-(-x)the operand of the outer negation is the inner one. Parentheses group; they do not change what is negated. -
negationApplyingTo
The negation thatctxis the operand of, looking through parentheses (ctxisnot bin~((not b))); null when it is not the operand of a negation. -
withoutParentheses
The expression inside any number of enclosing parentheses:bfor((b)). -
isBinary
-
operatorOf
The operator token of a binary expression. The 'in' alternative has no 'op' label. -
sourceText
The source as written (getText() would drop the spaces).
-