Class SourcePreProcessor
java.lang.Object
org.ek9lang.compiler.formatter.SourcePreProcessor
Pre-processes EK9 source that does not parse, applying simple text-level fixes
to make it parseable before the formatting pipeline runs.
Fixes applied in order:
- CRLF line endings — normalized to LF
- Missing
#!ek9shebang — inserted as line 1 - Tab characters — replaced with 2 spaces
- Odd-width indentation — normalized to 2-space-per-level
- Misspelled structural keywords — fuzzy-corrected via positional matching
Keyword correction uses positional rules (not blind matching) to avoid false positives on user identifiers and module names:
- First word on a line: checked against control flow and structural keywords
- Word after
defines: checked against block-type keywords - Word after
override/default: checked againstoperator - Last 3 words on line: checked against end-of-line modifiers
(
pure,abstract,open,dispatcher) matching the grammar patternAS? PURE? (ABSTRACT | OPEN)? - Word at position 1 after uppercase identifier: checked against
extends - Any lowercase word of 7+ chars: checked against
constrain
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) StringpreProcess(String source) Apply all pre-processing fixes to the source.
-
Constructor Details
-
SourcePreProcessor
SourcePreProcessor()
-
-
Method Details
-
preProcess
-