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. Use this - 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.
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. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<SyntaxProbe.SyntaxError> Every syntax error insource, in text order; empty when it parses (or is null).static Optional<SyntaxProbe.SyntaxError> The first syntax error insource; empty when it parses.(package private) static intThe number of leading spaces ofline.static Optional<SyntaxProbe.Parsed> 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.static booleanTrue whensourceparses.static booleanstatementParses(String entry) True whenentry- one statement, possibly several lines with its relative indentation - parses as the body of a function.
-
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. -
indentOf
The number of leading spaces ofline.
-