Skip to content

fix(ll1): walk forward through nullable symbols when computing FOLLOW sets - #316

Merged
StoneyJackson merged 5 commits into
mainfrom
worktree-issue-188-follow-set-nullable-tail
Aug 12, 2026
Merged

fix(ll1): walk forward through nullable symbols when computing FOLLOW sets#316
StoneyJackson merged 5 commits into
mainfrom
worktree-issue-188-follow-set-nullable-tail

Conversation

@StoneyJackson

Copy link
Copy Markdown
Member

Fixes the FOLLOW-set computation in build_follow_sets.py: it added FIRST of only the
immediate next symbol after a nonterminal occurrence, then jumped straight to checking
whether the entire remainder was nullable — skipping every symbol in between. A
nonterminal followed by one nullable symbol and then a non-nullable one lost the
non-nullable symbol's FIRST set entirely, silently truncating FOLLOW and dropping
parse-table entries for empty alternatives (while plcc-ll1 still reported is_ll1: true).

  • Design: dev-docs/specs/2026-08-12-follow-set-nullable-tail-design.md

  • Plan: dev-docs/specs/2026-08-12-188-follow-set-nullable-tail-plan.md

  • Closes the issue tracked at dev-docs/issues/done/188-follow-set-omits-nullable-tail.md

  • Sign off on the DCO.

  • License their changes under the project's license.

… sets

FOLLOW-set computation added FIRST of only the immediate next symbol
after a nonterminal occurrence, then jumped straight to checking
whether the entire remainder was nullable - skipping every symbol in
between. A nonterminal followed by one nullable symbol and then a
non-nullable one lost the non-nullable symbol's FIRST set entirely,
silently truncating FOLLOW and dropping parse-table entries for empty
alternatives.

Fixes #188
…docs

Final review flagged that the plan document claimed all 13
pre-existing build_follow_sets tests would pass unchanged, but
test_derive_empty's expected FOLLOW sets were correctly updated as
part of the fix (the old values encoded the bug). Record that in the
plan and design docs so the historical record is accurate.
@StoneyJackson
StoneyJackson marked this pull request as ready for review August 12, 2026 12:41
Copilot AI lite review requested due to automatic review settings August 12, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an LL(1) FOLLOW-set under-computation bug where the algorithm only considered the immediate next symbol after a nonterminal occurrence, instead of walking forward through a nullable tail to the next non-nullable symbol (or falling back to FOLLOW(lhs) if the entire suffix is nullable). This prevents silently truncated FOLLOW sets that can drop parse-table entries for empty alternatives while still reporting is_ll1: true.

Changes:

  • Update FOLLOW-set computation to iterate forward across consecutive nullable symbols, adding FIRST(Xj) \ {ε} for each until a non-nullable symbol is reached.
  • Add/adjust unit tests to cover the nullable-tail regression (issue #188) and update expected FOLLOW sets impacted by the fix.
  • Add supporting design/plan docs and update the roadmap/issue cross-links to reflect closure of #188.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/plcc/spec/syntax/validations/ll1/build_follow_sets.py Correct FOLLOW-set forward-walk control flow across nullable suffix symbols.
src/plcc/spec/syntax/validations/ll1/build_follow_sets_test.py Add regression test for nullable-tail walking; update expected FOLLOW sets affected by the fix.
dev-docs/specs/2026-08-12-follow-set-nullable-tail-design.md Document the defect and the one-method control-flow fix strategy.
dev-docs/specs/2026-08-12-188-follow-set-nullable-tail-plan.md Provide an implementation plan and test steps for the fix/issue closure workflow.
dev-docs/roadmap.md Remove #188 from Open Issues.
dev-docs/issues/done/188-follow-set-omits-nullable-tail.md Update relative links after closure (source link + related issue link).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@StoneyJackson
StoneyJackson merged commit 119fe52 into main Aug 12, 2026
8 checks passed
@StoneyJackson
StoneyJackson deleted the worktree-issue-188-follow-set-nullable-tail branch August 12, 2026 12:44
@github-project-automation github-project-automation Bot moved this to Done in plcc-ng Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants