Class ExcludedKeywordOrError
This checker REJECTS these keywords in TWO contexts:
- As statements/expressions (break, continue, return, goto, null, new)
- As identifiers (variable names, function names, class names) - these words cause cognitive confusion even when used as names
The grammar recognizes these keywords to enable helpful error messages instead of cryptic ANTLR parse errors. But they are NOT allowed in EK9.
Exception: Module segment names CAN contain these words (e.g., bad.break.usage) because they are read as hierarchical paths, not executable code.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidCheck for excluded control flow statements (break, continue, return, goto, elif, def, close).(package private) voidcheckExcludedDefinition(org.antlr.v4.runtime.tree.TerminalNode def) Check a function or method declaration for a 'def' header (def greet(name as String)).(package private) voidCheck for excluded instantiation (new TypeName()).(package private) voidCheck for Python list comprehensions.(package private) voidCheck for excluded literal (null, None).(package private) voidCheck if an identifier is an excluded keyword.(package private) voidCheck for semicolons in instruction blocks.
-
Constructor Details
-
ExcludedKeywordOrError
ExcludedKeywordOrError(ErrorListener errorListener)
-
-
Method Details
-
checkIdentifier
Check if an identifier is an excluded keyword. Called when an identifier is used as a name for variable, function, class, etc. Module segment names are allowed to contain these keywords. -
checkExcludedControlFlowStatement
Check for excluded control flow statements (break, continue, return, goto, elif, def, close).close xwas a statement until 2026-10-06; closing is now generated (a try resource when its try ends, a statement-owned temporary when its statement finishes, a type's own closeable properties by itsoperator closechain), so the grammar keeps it only to say so. -
checkExcludedDefinition
void checkExcludedDefinition(org.antlr.v4.runtime.tree.TerminalNode def) Check a function or method declaration for a 'def' header (def greet(name as String)).The grammar parses
def name(...)at a declaration position (adefines functionblock, a class, trait, record, component or program body) only to report E01077 on thedef; the declaration is otherwise defined as normal, so nothing later trips over a missing symbol. -
checkExcludedInstantiation
Check for excluded instantiation (new TypeName()). EK9 uses TypeName() directly, not new TypeName(). -
checkExcludedLiteral
Check for excluded literal (null, None). -
checkSemicolon
Check for semicolons in instruction blocks. Called when processing an instruction block to detect semicolons. -
checkExcludedListComprehension
Check for Python list comprehensions. EK9 uses stream pipelines instead.
-