Class MultipleArrowOrError
java.lang.Object
org.ek9lang.compiler.phase1.MultipleArrowOrError
Detects multiple arrow usage and emits clear educational error messages.
EK9 uses a single '->' for parameters (with indented block for multiple params)
and a single '<-' for returns. When developers (or AI assistants) incorrectly
use multiple arrows, they receive helpful error messages explaining the
correct syntax.
This checker works because the grammar has been modified to allow argumentParam* and returningParam* in operationDetails. This enables parsing of the incorrect pattern so we can emit a much better error than ANTLR's default recovery would provide.
Correct EK9 syntax for multiple parameters:
add() as pure
->
a as Integer
b as Integer
<- result as Integer: a + b
Incorrect syntax (what developers often try):
badFunction()
-> param1 as String
-> param2 as Integer // ERROR - second -> not allowed
<- result as String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidCheck operationDetails for multiple argument or return arrows.
-
Constructor Details
-
MultipleArrowOrError
MultipleArrowOrError(ErrorListener errorListener)
-
-
Method Details
-
checkOperationDetails
Check operationDetails for multiple argument or return arrows. Called when exiting operationDetails to detect the error pattern.
-