Class ErrorDirectiveText
java.lang.Object
org.ek9lang.compiler.common.ErrorDirectiveText
THE text-level reading of the
@Error: PHASE: CLASSIFICATION directive lines in an example SOURCE - for the
readers that show an error example to a person or a model, not for the compiler (which parses directives with the
grammar and checks them with ErrorDirectiveListener). Use it; never write another regex for these lines.
Shared by the site's code block renderer and publisher (org.ek9lang.site.Ek9CodeBlockRenderer,
SiteExamplePublisher, QaPageRenderer), the error catalogue (ErrorExamples, whose plain-text
[EXAMPLE] reaches ek9 -h <CODE> and -E3) and the gates that check those examples. The
source keeps its directive lines, where a gate reads them; a reader is shown the source without them and one
caption naming the error ("Fails with E05240: <meaning>", decision D4 of the site-examples spec).
-
Method Summary
Modifier and TypeMethodDescriptionerrorCodes(String source) The error codes the source's@Errordirectives name, in source order, without repeats.expectedErrorLines(String source) Where each directive says its error is, as"<line>:<CLASSIFICATION>"- the line after the directive, counting from 1 - in source order.static booleanisErrorExample(String source) True when the source carries at least one@Errordirective - an error example.static StringThe one-line meaning of a semantic error code, from the compiler's own classification.The phase names the source's@Errordirectives give, in source order, without repeats.static StringwithoutErrorDirectives(String source) The source with every@Errordirective line removed - what a reader would type.
-
Method Details
-
isErrorExample
True when the source carries at least one@Errordirective - an error example. -
withoutErrorDirectives
-
errorCodes
The error codes the source's@Errordirectives name, in source order, without repeats.- Throws:
IllegalArgumentException- when a directive names a classification that does not exist
-
phases
-
expectedErrorLines
Where each directive says its error is, as"<line>:<CLASSIFICATION>"- the line after the directive, counting from 1 - in source order. The exact check of aPARSINGdirective reads this: a syntax error stops the parse, so no directive is ever read from a parse tree, and the text is all there is.- Throws:
IllegalArgumentException- when a directive names a classification that does not exist
-
meaningOf
The one-line meaning of a semantic error code, from the compiler's own classification.- Throws:
IllegalArgumentException- when no classification has the code
-