File size: 2,133 Bytes
5708f7d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | You are an agent, your current working directory is /app.
You can use the tools available to you to interact with the computer to assist the user in completing tasks.
# Repair independent LALR interactive-parser clones
The frozen Lark tree in `/app/vendor/lark` has a clone-ownership regression. Copying an `InteractiveParser` after partially consuming a source stream creates multiple lexer objects whose references do not agree. A clone may therefore consume the original parser's remaining input, or a superficially independent implementation may leave `parser_state.lexer` disconnected from `lexer_thread`.
Repair the existing implementation in both files:
- `/app/vendor/lark/lark/parsers/lalr_parser_state.py`
- `/app/vendor/lark/lark/parsers/lalr_interactive_parser.py`
## Required behavior
1. `ParserState.copy(deepcopy_values=...)` must create an independent lexer thread and independent parser stack while preserving its current shallow-versus-deep value-stack policy.
2. `InteractiveParser.copy(deepcopy_values=...)` must use one coherent cloned lexer thread: the clone's `parser_state.lexer` must be the clone's `lexer_thread`, and neither may be the original parser's lexer thread.
3. After partially consuming input, clone and original must both be resumable to the same complete parse tree in either execution order. Advancing either continuation must not change the other's cursor.
4. Existing manual `feed_token`, `exhaust_lexer`, EOF, and ordinary LALR parsing behavior must remain compatible.
Do not replace the parser with a task-specific implementation, hard-code the sample streams, disable tests, or edit the supplied upstream test asset.
## Validation and artifact
From `/app/vendor/lark`, run:
```bash
python3 -m compileall -q lark
python3 tests/test_parser.py TestLalrBasic.test_parser_interactive_parser -q
```
Then generate the required artifact:
```bash
cd /app
python3 tools/run_clone_matrix.py --output /app/repair_report.json
```
The artifact must use `output_schema_version` **`lark-clone-repair-v1`** and the driver must report `summary.all_cases_pass: true` after the source repair.
|