Skip to content

Commit 138b311

Browse files
committed
Parse Twig string literals with escaped quotes and backslash escapes
1 parent 70777e5 commit 138b311

9 files changed

Lines changed: 8790 additions & 8735 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Parse Twig string literals with escaped quotes and backslash escapes
56
- Decode static Twig helper arguments with Twig string semantics
67
- Decode escaped Twig literals in template, route and PHP symbol references
78
- Ignore unrelated named arguments in positional Doctrine and Metadata call slots

THIRD_PARTY_NOTICES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The Tree-sitter parser ships compiled into the server binaries.
3737
| Component | Revision | License |
3838
| --- | --- | --- |
3939
| tree-sitter | `64402de2857cc197ecc4ca3bc144ea91fda7e72e` | MIT License |
40-
| tree-sitter-twig | `0afd9a6d808944e65a7be393e31868b85345735f` | WTFPL |
40+
| tree-sitter-twig | `0afd9a6d808944e65a7be393e31868b85345735f` with a local string-escape fix | WTFPL |
4141
| tree-sitter-yaml | `a1c4812a73ec5e089de8e441fdea3a921e8d5079` | MIT License |
4242
| Unicode data used by tree-sitter | Unicode License V3 |
4343

ext/tree_sitter/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ The vendored sources are pinned to:
77
| Source | Revision | License |
88
| --- | --- | --- |
99
| `tree-sitter/tree-sitter` | `v0.26.11` (`64402de2857cc197ecc4ca3bc144ea91fda7e72e`) | MIT |
10-
| `gbprod/tree-sitter-twig` | `0afd9a6d808944e65a7be393e31868b85345735f` | WTFPL |
10+
| `gbprod/tree-sitter-twig` | `0afd9a6d808944e65a7be393e31868b85345735f` with `vendor/twig/string-escapes.patch` | WTFPL |
1111
| `tree-sitter-grammars/tree-sitter-yaml` | `a1c4812a73ec5e089de8e441fdea3a921e8d5079` | MIT |
1212

1313
The Twig grammar was selected because it recognizes extension tags generically, preserves useful nodes around incomplete Twig, has a maintained parser corpus, and has a substantially smaller generated parser than the evaluated alternative. The YAML grammar accepts Symfony custom tags without application-specific grammar changes.
1414

15+
The vendored Twig parser is regenerated from the pinned revision plus `vendor/twig/string-escapes.patch`, which fixes double-escaped string regexes so escaped quotes and generic backslash escapes lex like Twig's own lexer. To regenerate after changing the patch: clone the pinned revision, apply the patch, run `tree-sitter generate --abi 14`, verify `tree-sitter test` still passes the full corpus, and copy `src/parser.c` and `src/tree_sitter/*.h` into `vendor/twig/src/`.
16+
1517
Build the extension from the repository root:
1618

1719
```console

0 commit comments

Comments
 (0)