From 29b2bcc7c32637e16e6d3db8909e51e610831ad5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:00:04 +0000 Subject: [PATCH 1/2] Initial plan From e7e830e3cabb2fcaa976eb5eaab34d421575ae4b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 26 Feb 2026 16:01:03 +0000 Subject: [PATCH 2/2] Fix British spellings to American in all docs Co-authored-by: alejandroklever <45394625+alejandroklever@users.noreply.github.com> --- docs/api-reference.md | 4 ++-- docs/changelog.md | 6 +++--- docs/defining-grammar.md | 2 +- docs/error-handling.md | 4 ++-- docs/index.md | 2 +- docs/parser.md | 4 ++-- docs/serialization.md | 14 +++++++------- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/api-reference.md b/docs/api-reference.md index 4fa9a3c..836ed20 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -203,7 +203,7 @@ Raises `ValueError` for unknown names. --- -### Serialisation +### Serialization --- @@ -225,7 +225,7 @@ Generate `parsertab.py` in the current working directory. #### `Grammar.to_json() -> str` -Serialise the grammar structure (terminals, non-terminals, productions) to a JSON string. Semantic actions and regexes are **not** included. +Serialize the grammar structure (terminals, non-terminals, productions) to a JSON string. Semantic actions and regexes are **not** included. --- diff --git a/docs/changelog.md b/docs/changelog.md index 72c0293..9cab546 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -28,7 +28,7 @@ This project follows [Semantic Versioning](https://semver.org) and the ### Planned — Testing - Add tests for LR(1) and LALR(1) parsers. - Add tests for lexer and parser error handling. -- Add tests for serialisation round-trips. +- Add tests for serialization round-trips. - Add edge-case tests (empty grammar, duplicate symbols, epsilon productions). - Enforce minimum test coverage threshold. @@ -62,7 +62,7 @@ This project follows [Semantic Versioning](https://semver.org) and the - Improved `RuleList` error API. ### Fixed -- Reset lexer parameters when analysing a new string (`Lexer.__call__`). +- Reset lexer parameters when analyzing a new string (`Lexer.__call__`). --- @@ -77,7 +77,7 @@ This project follows [Semantic Versioning](https://semver.org) and the ### Added - SLR, LR(1), and LALR(1) parsers. -- Serialisation of lexer and parser to Python source files. +- Serialization of lexer and parser to Python source files. - `@g.terminal` decorator for inline rule definition. - `@g.production` decorator for inline production rules. - `@g.lexical_error` and `@g.parsing_error` decorators. diff --git a/docs/defining-grammar.md b/docs/defining-grammar.md index 68d6459..e289f3a 100644 --- a/docs/defining-grammar.md +++ b/docs/defining-grammar.md @@ -224,4 +224,4 @@ g2 = Grammar.from_json(json_str) ``` !!! note - JSON serialisation does not preserve terminal regexes, terminal rules, or semantic actions. It is useful for inspecting grammar structure, not for production use. Use [Python file serialisation](serialization.md) for production scenarios. + JSON serialization does not preserve terminal regexes, terminal rules, or semantic actions. It is useful for inspecting grammar structure, not for production use. Use [Python file serialization](serialization.md) for production scenarios. diff --git a/docs/error-handling.md b/docs/error-handling.md index 43262e9..c07d93f 100644 --- a/docs/error-handling.md +++ b/docs/error-handling.md @@ -6,7 +6,7 @@ Good error handling is one of PyJapt's core design goals. This page describes ho ## Lexical Error Handling -### Default behaviour +### Default behavior When the lexer encounters a character that matches no terminal pattern, it calls the *lexical error handler*. By default, this adds an error message to the internal errors list and advances past the bad character. @@ -70,7 +70,7 @@ if lexer.contain_errors: ## Syntactic Error Handling -### Default behaviour +### Default behavior When the parser cannot find an action for the current `(state, token)` pair it enters *panic-mode recovery*: it calls the error handler and then skips input tokens until it finds one that fits the current state. diff --git a/docs/index.md b/docs/index.md index 6836a2b..6a16168 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,7 @@ | **Three LR parser types** | SLR, LR(1), and LALR(1) — choose the power level you need. | | **Custom error handling** | Lexical and syntactic error handlers are first-class citizens. | | **Semantic actions** | Attach a lambda or a decorated function to any production rule. | -| **Serialisation** | Pre-build the parsing tables and serialise them to a Python module for faster startup. | +| **Serialization** | Pre-build the parsing tables and serialize them to a Python module for faster startup. | | **Decorator-based API** | Define terminals and production rules without leaving Python. | --- diff --git a/docs/parser.md b/docs/parser.md index 2944285..6ffa344 100644 --- a/docs/parser.md +++ b/docs/parser.md @@ -38,7 +38,7 @@ The parsing tables (ACTION and GOTO) encode which action to take for every (stat When two actions are valid for the same (state, lookahead) pair, a conflict arises: -- **Shift-reduce (SR)** — the parser can either shift or reduce. PyJapt resolves SR conflicts in favour of **shift** (same as most tools, because it handles `if-else` correctly). +- **Shift-reduce (SR)** — the parser can either shift or reduce. PyJapt resolves SR conflicts in favor of **shift** (same as most tools, because it handles `if-else` correctly). - **Reduce-reduce (RR)** — two different reductions are possible. PyJapt keeps whichever was registered first. Conflicts are printed to `stderr` and stored in `parser.conflicts`: @@ -141,4 +141,4 @@ print(parser.goto) print(parser.augmented_grammar) ``` -These are Python dicts and can be serialised — see [Serialisation](serialization.md). +These are Python dicts and can be serialized — see [Serialization](serialization.md). diff --git a/docs/serialization.md b/docs/serialization.md index bf7b3b5..dec32b8 100644 --- a/docs/serialization.md +++ b/docs/serialization.md @@ -1,6 +1,6 @@ -# Serialisation +# Serialization -For large grammars, building the parsing tables from scratch on every run can take seconds. PyJapt lets you *serialise* the pre-computed tables into plain Python modules so that subsequent runs skip the construction step entirely. +For large grammars, building the parsing tables from scratch on every run can take seconds. PyJapt lets you *serialize* the pre-computed tables into plain Python modules so that subsequent runs skip the construction step entirely. --- @@ -12,7 +12,7 @@ The generated classes extend `Lexer` and `ShiftReduceParser` respectively, so th --- -## Serialising the Lexer +## Serializing the Lexer ```python import inspect @@ -48,7 +48,7 @@ class MyLexer(Lexer): --- -## Serialising the Parser +## Serializing the Parser ```python if __name__ == '__main__': @@ -96,7 +96,7 @@ result = parser(lexer(source_code)) ## Full Example -**`grammar.py`** — define the grammar and conditionally serialise: +**`grammar.py`** — define the grammar and conditionally serialize: ```python import inspect @@ -165,6 +165,6 @@ parsertab.py ## Caveats -- **Semantic actions are not serialised.** The generated parser still imports the original grammar module (`grammar_module_name`) at runtime to access production rules and semantic actions. +- **Semantic actions are not serialized.** The generated parser still imports the original grammar module (`grammar_module_name`) at runtime to access production rules and semantic actions. - **The grammar module must be importable.** Make sure `grammar.py` (or whatever you named it) is on the Python path when running the generated classes. -- **Files are written to the current working directory.** Run the serialisation script from the directory where you want the files to be created. +- **Files are written to the current working directory.** Run the serialization script from the directory where you want the files to be created.