Skip to content

v2.0.0

Latest

Choose a tag to compare

@github-actions github-actions released this 18 Nov 22:54
2f13326

2.0.0 (2026-11-15)

⚠ Breaking changes

These are all the changes that can break code built against 1.6.3. Only the first one is marked as breaking in the generated list below.

  • The deprecated rule definition API inherited from SSLR is gone (6056700).
    • Rule.is(...), Rule.override(...), Rule.skip() and Rule.skipIfOneChild() are removed, and so are RuleDefinition.is(...) and RuleDefinition.override(...). Define rules through LexerfulGrammarBuilder or LexerlessGrammarBuilder instead: b.rule(KEY).is(...), .override(...), .skip(), .skipIfOneChild().
    • A Grammar no longer fills its Rule fields by reflection, and Grammar.getRuleFields(...) and Grammar.getAllRuleFields(...) are removed. A grammar written as a class with Rule fields must move to a GrammarRuleKey and a grammar builder.
    • MockHelper (mockToken, mockTokenBuilder, mockAstNode) is removed from flr-testing-harness. Build tokens with Token.builder().
  • AstNode.fromIndex and AstNode.toIndex are removed (01f197e). The parser no longer records them.
  • AstNode.children is read-only (d37e2f5). Its Kotlin type is now List<AstNode> instead of MutableList<AstNode>. From Java the signature is unchanged, but children.add(...), remove(...) or clear() now throws UnsupportedOperationException at runtime. Use AstNode.addChild(...) to add a child.
  • A nonterminal that matched no input has no token (85cc5fd). It used to carry the next token of the input, which gave it a wrong position and listed that token twice in AstNode.tokens. On such a node:
    • token and lastToken throw IllegalStateException;
    • use tokenOrNull, hasToken() or lastTokenOrNull instead;
    • tokenValue and tokenOriginalValue are empty, and tokenLine is -1.
      A walk that reads node.token on every node must check hasToken() first.
  • Minor:
    • GrammarRuleBuilder has a new abstract method, enableMemoRetention(), so a class outside flr that implements the interface must add it.
    • In Kotlin, RuleDefinition.getName() is now the property name. From Java nothing changes.

Features

These two came in through a merge of the 1.6.x branch, so the generated list does not show them.

  • Parsing profiler (760805c). Opt-in per-rule counts of memo hits, misses, matches and overwrites: pass a ParsingProfiler to Parser.parse(..., profiler) and read profiler.snapshot().
  • Selective memo retention (4e8e38c). GrammarRuleBuilder.enableMemoRetention() keeps a rule's successful memoized results after another result displaces them from the ordinary memo table. It pays off only for rules whose displaced results are requested again; the profiler shows these as memo matcher misses.

Bug Fixes

  • ast: build no token for a nonterminal that matched no input (85cc5fd)
  • build: pin JGit and configure Mockito java agent (71113c9)
  • deps: update dependency jacoco to v0.8.16 (2a219e1)
  • deps: update dependency jacoco to v0.8.16 (196a27a)
  • deps: update dependency org.ow2.asm:asm to v9.11.1 (738ee1d)
  • deps: update dependency org.ow2.asm:asm to v9.11.1 (1becf03)
  • lexer: uppercase words independently of the default locale (1a93b7d)

Performance Improvements

  • ast: remove the unused fromIndex and toIndex from AstNode (01f197e)
  • ast: stop copying the node type array at every node of a tree walk (259fe28)
  • ast: store node children in exact-size read-only storage (d37e2f5)
  • ast: walk children by index without allocating iterators (795f04c)
  • lexer: share equal token strings within one lex (d2afa7c)

Code Refactoring

  • remove the deprecated rule definition API and the reflective rule fields inherited from SSLR (6056700)