Class SyntaxProbe
java.lang.Object
org.ek9lang.compiler.repair.SyntaxProbe
THE parse-only check of a piece of EK9 text, for every repair: the syntax errors the ANTLR parser reports, no
symbol phase run. Hold one and use it - a file's first error (
first(String)), whether it parses (parses(String)),
whether a caller's statement entry parses inside a throwaway body (statementParses(String)) - rather than building
another ParserSpec and ErrorListener by hand. It is stateless, so one instance serves any thread.
One rule the grammar no longer states is reported here too: an aggregate body's member order (E01086,
AggregateMemberOrder). The grammar accepts any order so phase 1 can report it once, on the member; a source
with a member out of order still does not "parse" for a repair, exactly as when the grammar enforced it.
A SyntaxProbe.SyntaxError also renders as the diagnostic map every repair reads (SyntaxProbe.SyntaxError.asDiagnostic()):
line 1-based, column 0-based, errorCode (empty for an uncoded parser error) and
message - the keys the MCP diagnostics carry, so a CLI caller and an MCP caller hand the repairs the
same thing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA parse tree and the token stream it came from (HIDDEN-channel comments included).static final recordOne syntax error. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEvery syntax error insource, in text order; empty when it parses (or is null).The first syntax error insource; empty when it parses.THE parse ofsourceinto a tree and its tokens, whether or not it parses cleanly (the parser recovers); empty when it could not be read at all.booleanTrue whensourceparses.booleanstatementParses(String entry) True whenentry- one statement, possibly several lines with its relative indentation - parses as the body of a function.
-
Constructor Details
-
SyntaxProbe
public SyntaxProbe()
-
-
Method Details
-
parse
THE parse ofsourceinto a tree and its tokens, whether or not it parses cleanly (the parser recovers); empty when it could not be read at all. -
errors
Every syntax error insource, in text order; empty when it parses (or is null). -
first
The first syntax error insource; empty when it parses. -
parses
True whensourceparses. -
statementParses
True whenentry- one statement, possibly several lines with its relative indentation - parses as the body of a function. Its lines are re-indented as a block, the shallowest to the body's indent.
-