Sam Stone
07/09/2023, 8:20 AMa == b && c || a == d && !e
ephemient
07/09/2023, 9:08 AM$ kotlin parse.main.kts 'a == b && c || a == d && !e'
packageHeader
functionDeclaration
FUN >>>fun<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
simpleIdentifier
Identifier >>>main<<< (DEFAULT_TOKEN_CHANNEL)
functionValueParameters
LPAREN >>>(<<< (DEFAULT_TOKEN_CHANNEL)
RPAREN >>>)<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
functionBody
block
LCURL >>>{<<< (DEFAULT_TOKEN_CHANNEL)
NL >>>\n<<< (DEFAULT_TOKEN_CHANNEL)
statements
statement
expression
disjunction
conjunction
equality
comparison
genericCallLikeComparison
infixOperation
elvisExpression
infixFunctionCall
rangeExpression
additiveExpression
multiplicativeExpression
asExpression
prefixUnaryExpression
postfixUnaryExpression
primaryExpression
simpleIdentifier
Identifier >>>a<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
equalityOperator
EQEQ >>>==<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
comparison
genericCallLikeComparison
infixOperation
elvisExpression
infixFunctionCall
rangeExpression
additiveExpression
multiplicativeExpression
asExpression
prefixUnaryExpression
postfixUnaryExpression
primaryExpression
simpleIdentifier
Identifier >>>b<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
CONJ >>>&&<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
equality
comparison
genericCallLikeComparison
infixOperation
elvisExpression
infixFunctionCall
rangeExpression
additiveExpression
multiplicativeExpression
asExpression
prefixUnaryExpression
postfixUnaryExpression
primaryExpression
simpleIdentifier
Identifier >>>c<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
DISJ >>>||<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
conjunction
equality
comparison
genericCallLikeComparison
infixOperation
elvisExpression
infixFunctionCall
rangeExpression
additiveExpression
multiplicativeExpression
asExpression
prefixUnaryExpression
postfixUnaryExpression
primaryExpression
simpleIdentifier
Identifier >>>a<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
equalityOperator
EQEQ >>>==<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
comparison
genericCallLikeComparison
infixOperation
elvisExpression
infixFunctionCall
rangeExpression
additiveExpression
multiplicativeExpression
asExpression
prefixUnaryExpression
postfixUnaryExpression
primaryExpression
simpleIdentifier
Identifier >>>d<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
CONJ >>>&&<<< (DEFAULT_TOKEN_CHANNEL)
WS >>> <<< (HIDDEN)
equality
comparison
genericCallLikeComparison
infixOperation
elvisExpression
infixFunctionCall
rangeExpression
additiveExpression
multiplicativeExpression
asExpression
prefixUnaryExpression
unaryPrefix
prefixUnaryOperator
excl
EXCL_NO_WS >>>!<<< (DEFAULT_TOKEN_CHANNEL)
postfixUnaryExpression
primaryExpression
simpleIdentifier
Identifier >>>e<<< (DEFAULT_TOKEN_CHANNEL)
semis
NL >>>\n<<< (DEFAULT_TOKEN_CHANNEL)
RCURL >>>}<<< (DEFAULT_TOKEN_CHANNEL)
Klitos Kyriacou
07/09/2023, 4:37 PM||
vs &&
precedence? For me, I treat them like +
and *
. We all know the precedence of those arithmetic operators since junior school. If you treat booleans as numbers, with 0 being false and non-zero being true (as is the case with C), then:
||
is like +
: true or false = 1 + 0 = 1 = true
&&
is like *
: true and false = 1 * 0 = 0 = falseephemient
07/09/2023, 4:41 PM||
is saturating add, which doesn't have an operator, while wrapping add (+
) is `xor`… but that's the right analogy in generaland
or
xor
etc. do not have separate precedence from each other, because of how infix functions work in Kotlin. but you should very rarely (if ever) see those used on Boolean