Skip to content

docs: add English docstrings and SLR(1) algorithm comments (T0)#34

Merged
henrylee97 merged 9 commits into
masterfrom
task/t0-english-docs
May 4, 2026
Merged

docs: add English docstrings and SLR(1) algorithm comments (T0)#34
henrylee97 merged 9 commits into
masterfrom
task/t0-english-docs

Conversation

@henrylee97

Copy link
Copy Markdown
Member

Summary

  • Add module-level docstrings to all plare/*.py files
  • Add class and method docstrings to every public type (Token, Lexer, Parser, Rule, Item, State, action types, etc.)
  • Add block comments on the five construction phases in Parser.__init__ and on closure, goto, calc_first, calc_follow, and Parser.parse stating this is SLR(1), the invariants each routine relies on, and the over-approximation that T6 will fix

No logic changes — git diff --stat shows additions in docstrings and comments only.

Checklist

  • pytest -q green (8 passed)
  • No behavior changes (pure documentation pass)
  • No Korean strings remain
  • HANDOFF.md T0 marked as DONE

henrylee97 and others added 6 commits May 4, 2026 08:11
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add module-level docstring explaining the SLR(1) construction pipeline,
class-level docstrings for all public and internal types (EOS, EPSILON,
Maker variants, StartVariable, Item, State, action types, Table, Rule,
Parser), and block comments on the five phases of Parser.__init__ and on
the key algorithm routines (closure, goto, calc_first, calc_follow,
parse) stating the SLR(1) invariants and the over-approximation that T6
will fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@henrylee97 henrylee97 self-assigned this May 4, 2026
@henrylee97 henrylee97 added the documentation Improvements or additions to documentation label May 4, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Super-linter summary

Language Validation result
PYTHON_BLACK Fail ❌
PYTHON_ISORT Pass ✅
YAML Pass ✅

Super-linter detected linting errors

For more information, see the GitHub Actions workflow run

Powered by Super-linter

PYTHON_BLACK
--- /github/workspace/plare/lexer.py	2026-05-04 08:29:28.521939+00:00
+++ /github/workspace/plare/lexer.py	2026-05-04 08:29:35.727461+00:00
@@ -110,11 +110,11 @@
                     continue
                 matched = match.group(0)
                 logger.debug(
                     "Pattern matched: %s (from %s), %s", regex, var, repr(matched)
                 )
-                src = src[len(matched):]
+                src = src[len(matched) :]
                 match pattern:
                     case str():
                         var = pattern
                     case type():
                         yield pattern(matched, lineno=lineno, offset=offset)would reformat /github/workspace/plare/lexer.py

Oh no! 💥 💔 💥
1 file would be reformatted, 9 files would be left unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Super-linter summary

Language Validation result
PYTHON_BLACK Fail ❌
PYTHON_ISORT Pass ✅
YAML Pass ✅

Super-linter detected linting errors

For more information, see the GitHub Actions workflow run

Powered by Super-linter

PYTHON_BLACK
--- /github/workspace/plare/lexer.py	2026-05-04 08:32:43.442057+00:00
+++ /github/workspace/plare/lexer.py	2026-05-04 08:32:50.225424+00:00
@@ -110,11 +110,11 @@
                     continue
                 matched = match.group(0)
                 logger.debug(
                     "Pattern matched: %s (from %s), %s", regex, var, repr(matched)
                 )
-                src = src[len(matched):]
+                src = src[len(matched) :]
                 match pattern:
                     case str():
                         var = pattern
                     case type():
                         yield pattern(matched, lineno=lineno, offset=offset)would reformat /github/workspace/plare/lexer.py

Oh no! 💥 💔 💥
1 file would be reformatted, 9 files would be left unchanged.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Super-linter summary

Language Validation result
PYTHON_BLACK Fail ❌
PYTHON_ISORT Pass ✅
YAML Pass ✅

Super-linter detected linting errors

For more information, see the GitHub Actions workflow run

Powered by Super-linter

PYTHON_BLACK
--- /github/workspace/plare/lexer.py	2026-05-04 08:32:48.064321+00:00
+++ /github/workspace/plare/lexer.py	2026-05-04 08:32:55.197770+00:00
@@ -110,11 +110,11 @@
                     continue
                 matched = match.group(0)
                 logger.debug(
                     "Pattern matched: %s (from %s), %s", regex, var, repr(matched)
                 )
-                src = src[len(matched):]
+                src = src[len(matched) :]
                 match pattern:
                     case str():
                         var = pattern
                     case type():
                         yield pattern(matched, lineno=lineno, offset=offset)would reformat /github/workspace/plare/lexer.py

Oh no! 💥 💔 💥
1 file would be reformatted, 9 files would be left unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@henrylee97
henrylee97 enabled auto-merge (squash) May 4, 2026 08:34
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Pytest Report

Test Results

  • Tests: 8
  • Errors: 0
  • Failures: 0
  • Skipped: 0

Comment by ✨sambyeol/publish-pytest-action

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Pytest Report

Test Results

  • Tests: 8
  • Errors: 0
  • Failures: 0
  • Skipped: 0

Comment by ✨sambyeol/publish-pytest-action

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

Super-linter summary

Language Validation result
PYTHON_BLACK Pass ✅
PYTHON_ISORT Pass ✅
YAML Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@henrylee97
henrylee97 merged commit bbf3fe5 into master May 4, 2026
7 checks passed
@henrylee97
henrylee97 deleted the task/t0-english-docs branch May 4, 2026 08:36
@henrylee97 henrylee97 mentioned this pull request May 11, 2026
2 tasks
henrylee97 added a commit that referenced this pull request May 11, 2026
## Summary

- Fix hash semantics for `Item`, `State`, and `Token` to be value-based
and class-aware
- Replace recursive FIRST/FOLLOW computation with worklist fixed-point
algorithms, fixing incorrect results on mutually recursive grammars
- Make LR(0) state construction deterministic across repeated `Parser`
instantiations
- Add English docstrings and SLR(1) algorithm comments throughout the
codebase
- Expand test coverage with 4 new test modules (safety-net,
FIRST/FOLLOW, determinism, hash semantics)

## Changes

### Bug Fixes
- Correct hash implementations for `Item`, `State`, `Token` (#38)
- Fixed-point FIRST / FOLLOW computation replacing re-entry-guard
recursion (#36)

### Improvements
- Deterministic LR(0) state construction (#37)

### Documentation
- English docstrings and SLR(1) inline algorithm comments (#34)

### Tests
- Parser safety-net suite, FIRST/FOLLOW unit tests, determinism tests,
hash semantics tests (#35 #36 #37 #38)

### Maintenance
- Bumped GitHub Actions: `actions/checkout` 4→6, `actions/setup-python`
5→6, `sambyeol/publish-pytest-action` 2→4, `super-linter/super-linter`
7→8 (#28 #29 #31 #32 #33)

## Test plan

- [x] `pytest -q` passes (`29 passed, 2 xfailed`)
- [x] `python examples/calc/calc.py examples/calc/data/ex01.calc` prints
`2`

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant