Class ReadabilityAssessor
java.lang.Object
org.ek9lang.compiler.tokenizer.ReadabilityAssessor
- All Implemented Interfaces:
Serializable
THE incremental readability (ARI) scorer - feed it every token exactly once, in order,
then ask for the score.
This is the single implementation of the ARI counting rules. TokenStreamAssessment
drives it over a whole lexer for standalone/debug use; CompilableSource
drives it from tokenConsumed so that readability is computed during the parser's own
lex rather than by lexing the file a second time.
Do NOT re-derive the counting rules elsewhere. An instance is stateful and single-use per
source; call reset() before feeding a fresh token stream.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAccept one token.voidreset()Discard all accumulated counts, ready for a fresh token stream.score()The ARI score for everything accepted so far.(package private) StringtidyLiteralContent(String content) Also used for token display, so escaping must stay identical to what was shown historically.
-
Constructor Details
-
ReadabilityAssessor
public ReadabilityAssessor()
-
-
Method Details
-
accept
Accept one token. The symbolic name may be null, in which case the literal content is used in its place - matching the historic behaviour of the whole-stream assessment.- Parameters:
symbolicName- the lexer's symbolic name for the token type, or nullrawTokenText- the token's text, exactly as the lexer produced it
-
score
The ARI score for everything accepted so far. -
reset
public void reset()Discard all accumulated counts, ready for a fresh token stream. -
tidyLiteralContent
-