add clause rule to verbatim, comment, and blocktrans

This commit is contained in:
danhanson committed 2026-09-12 17:41:25 -05:00
1 parent 22362ed393
commit db3caa1672
12 files changed
+25367 -56302

No files matched your search

+7 -4
View File
@@ -112,9 +112,12 @@ the group node does not exist yet.
Do not reach for lookahead to solve that instead: `ts_language_next_state` follows only the shift on `{%`, Do not reach for lookahead to solve that instead: `ts_language_next_state` follows only the shift on `{%`,
which lands in the "a tag starts here" state no matter how the tree is shaped. which lands in the "a tag starts here" state no matter how the tree is shaped.
`else_clause` is shared by `if_group` and `ifchanged_group`. `comment_group` and `verbatim_group` have no `else_clause` is shared by `if_group` and `ifchanged_group`. `comment_clause` and `verbatim_clause` hold raw
clause — their bodies are raw scanner text that admits no tags — and neither does `blocktranslate_group`, scanner text that admits no tags. `blocktranslate_group` has one clause per spelling, `blocktrans_clause` and
whose body is `_translate_body`. `blocktranslate_clause`, because each must be closed by its own end tag; the counted form nests a
`plural_clause` inside it, since `{% plural %}` is only valid after `count`. Their bodies are
`_translate_body`, not `template`, which is why these four clauses need no `conflicts` entry — the rule
below is about a body that can itself start with `{%`.
**Every clause needs a `conflicts` entry.** The generator offers a left associativity instead; taking it is **Every clause needs a `conflicts` entry.** The generator offers a left associativity instead; taking it is
what broke `{% for %}` in `06aa870`, where `prec.left` resolved the shift/reduce on `{%` statically and what broke `{% for %}` in `06aa870`, where `prec.left` resolved the shift/reduce on `{%` statically and
@@ -248,7 +251,7 @@ captured through its field instead (`(filter name: (identifier))`, `(custom_tag
filter added from a library belongs in it. `queries/locals.scm` relies on the `variable:` field to tell a filter added from a library belongs in it. `queries/locals.scm` relies on the `variable:` field to tell a
binding from a reference — another reason to keep `asVariable` uniform. `{% blocktranslate %}`'s `asvar` binding from a reference — another reason to keep `asVariable` uniform. `{% blocktranslate %}`'s `asvar`
target carries an `asvar:` field instead, because it is written inside the tag but assigned outside it: target carries an `asvar:` field instead, because it is written inside the tag but assigned outside it:
the scope on `blocktranslate_group` confines the `with` and `count` bindings, and would swallow `asvar` the scope on `blocktrans_clause` / `blocktranslate_clause` confines the `with` and `count` bindings, and would swallow `asvar`
too if it were spelled the same way. `queries/exports.scm` names it for a tool to too if it were spelled the same way. `queries/exports.scm` names it for a tool to
bind in the scope around the block, which a locals query cannot do: it places a definition in the innermost bind in the scope around the block, which a locals query cannot do: it places a definition in the innermost
scope containing it and offers no way out again. scope containing it and offers no way out again.
+35 -29
View File
@@ -204,6 +204,31 @@ function simpleTag($, tag, args = true, kwargs = true) {
return block(tag, ...parts, optional(asVariable($))); return block(tag, ...parts, optional(asVariable($)));
} }
/**
* @param {GrammarSymbols<string>} $
* @param {string} tag
* @returns {ChoiceRule}
*/
function blocktrans_clause_rule($, tag) {
return choice(
seq(
block(tag, $._tag_open, repeat($._translate_option)),
optional($._translate_body),
),
seq(
block(
tag,
$._tag_open,
repeat($._translate_option),
$._translate_count,
repeat($._translate_option),
),
optional($._translate_body),
$.plural_clause,
),
);
}
/** /**
* Django checks a filter's argument count against the registered function * Django checks a filter's argument count against the registered function
* while it parses the template, so the arity of a builtin is syntax here: * while it parses the template, so the arity of a builtin is syntax here:
@@ -577,30 +602,13 @@ const django = grammar({
block_clause: ($) => block_clause: ($) =>
seq(block("block", field("name", $.push_block)), optional($.template)), seq(block("block", field("name", $.push_block)), optional($.template)),
block_group: ($) => seq($.block_clause, block("endblock", $.pop_block)), block_group: ($) => seq($.block_clause, block("endblock", $.pop_block)),
plural_clause: ($) => seq(block("plural"), optional($._translate_body)),
blocktrans_clause: ($) => blocktrans_clause_rule($, "blocktrans"),
blocktranslate_clause: ($) => blocktrans_clause_rule($, "blocktranslate"),
blocktranslate_group: ($) => blocktranslate_group: ($) =>
choice( choice(
...["blocktrans", "blocktranslate"].map((name) => seq($.blocktrans_clause, block("endblocktrans")),
choice( seq($.blocktranslate_clause, block("endblocktranslate")),
seq(
block(name, $._tag_open, repeat($._translate_option)),
optional($._translate_body),
block("end" + name),
),
seq(
block(
name,
$._tag_open,
repeat($._translate_option),
$._translate_count,
repeat($._translate_option),
),
$._translate_body,
block("plural"),
optional($._translate_body),
block("end" + name),
),
),
),
), ),
/** /**
* The scanner reads the name of the option before the grammar does, so it * The scanner reads the name of the option before the grammar does, so it
@@ -658,12 +666,12 @@ const django = grammar({
optional($.template), optional($.template),
), ),
cache_group: ($) => seq($.cache_clause, block("endcache")), cache_group: ($) => seq($.cache_clause, block("endcache")),
comment_group: ($) => comment_clause: ($) =>
seq( seq(
block("comment", optional(part($.string))), block("comment", optional(part($.string))),
optional($.comment_content), optional($.comment_content),
block("endcomment"),
), ),
comment_group: ($) => seq($.comment_clause, block("endcomment")),
// csp_nonce_attr(context, media=None) // csp_nonce_attr(context, media=None)
csp_nonce_attr: ($) => csp_nonce_attr: ($) =>
simpleTag($, "csp_nonce_attr", 1, { media: $.filtered_value }), simpleTag($, "csp_nonce_attr", 1, { media: $.filtered_value }),
@@ -914,12 +922,10 @@ const django = grammar({
), ),
optional(asVariable($)), optional(asVariable($)),
), ),
verbatim_clause: ($) =>
seq(block("verbatim", $.push_verbatim), optional($.verbatim_content)),
verbatim_group: ($) => verbatim_group: ($) =>
seq( seq($.verbatim_clause, block("endverbatim", $.pop_verbatim)),
block("verbatim", $.push_verbatim),
optional($.verbatim_content),
block("endverbatim", $.pop_verbatim),
),
width_ratio: ($) => width_ratio: ($) =>
block( block(
"widthratio", "widthratio",
+4 -1
View File
@@ -21,5 +21,8 @@
; scope span could have separated them; that is why this is a separate file ; scope span could have separated them; that is why this is a separate file
; rather than a narrower scope in locals.scm. ; rather than a narrower scope in locals.scm.
(blocktranslate_group (blocktrans_clause
asvar: (identifier) @export.name) @export.from
(blocktranslate_clause
asvar: (identifier) @export.name) @export.from asvar: (identifier) @export.name) @export.from
+1 -1
View File
@@ -10,7 +10,7 @@ variable: (identifier) @variable.parameter
(partialdef_clause (partialdef_clause
(push_partial) @type) (push_partial) @type)
(verbatim_group (verbatim_clause
(push_verbatim) @type) (push_verbatim) @type)
(comment_content) @comment (comment_content) @comment
+5 -4
View File
@@ -24,10 +24,11 @@
(get_media_prefix (get_media_prefix
tag: ("get_media_prefix") @library.static) tag: ("get_media_prefix") @library.static)
(blocktranslate_group (blocktrans_clause
tag: [ tag: ("blocktrans") @library.i18n)
("blocktrans")
("blocktranslate")] @library.i18n) (blocktranslate_clause
tag: ("blocktranslate") @library.i18n)
(translate (translate
tag: [ tag: [
+2 -1
View File
@@ -23,4 +23,5 @@ variable: (identifier) @local.definition
; outside it, and carries an "asvar" field rather than "variable" so that this ; outside it, and carries an "asvar" field rather than "variable" so that this
; scope does not swallow it. A tool that wants it must define it in the scope ; scope does not swallow it. A tool that wants it must define it in the scope
; around the block, which a locals query has no way to say. ; around the block, which a locals query has no way to say.
(blocktranslate_group) @local.scope (blocktrans_clause) @local.scope
(blocktranslate_clause) @local.scope
+416 -498
View File
@@ -1622,82 +1622,409 @@
} }
] ]
}, },
"plural_clause": {
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "plural"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}
]
},
"blocktrans_clause": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "plural_clause"
}
]
}
]
},
"blocktranslate_clause": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "plural_clause"
}
]
}
]
},
"blocktranslate_group": { "blocktranslate_group": {
"type": "CHOICE",
"members": [
{
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_tag_open" "name": "blocktrans_clause"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "SEQ", "type": "SEQ",
@@ -1749,256 +2076,9 @@
{ {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktrans"
}
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "_tag_open" "name": "blocktranslate_clause"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "plural"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "endblocktrans"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
}
]
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
}, },
{ {
"type": "SEQ", "type": "SEQ",
@@ -2046,186 +2126,6 @@
] ]
} }
] ]
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "blocktranslate"
}
},
{
"type": "SYMBOL",
"name": "_tag_open"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "SYMBOL",
"name": "_translate_count"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_translate_option"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "plural"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_translate_body"
},
{
"type": "BLANK"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{%"
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "STRING",
"value": "endblocktranslate"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[ \\t\\r\\n]+"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "%}"
}
]
}
]
}
]
} }
] ]
}, },
@@ -2636,7 +2536,7 @@
} }
] ]
}, },
"comment_group": { "comment_clause": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
@@ -2716,6 +2616,15 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
]
},
"comment_group": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "comment_clause"
}, },
{ {
"type": "SEQ", "type": "SEQ",
@@ -8171,7 +8080,7 @@
} }
] ]
}, },
"verbatim_group": { "verbatim_clause": {
"type": "SEQ", "type": "SEQ",
"members": [ "members": [
{ {
@@ -8234,6 +8143,15 @@
"type": "BLANK" "type": "BLANK"
} }
] ]
}
]
},
"verbatim_group": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "verbatim_clause"
}, },
{ {
"type": "SEQ", "type": "SEQ",
+187 -33
View File
@@ -327,7 +327,7 @@
} }
}, },
{ {
"type": "blocktranslate_group", "type": "blocktrans_clause",
"named": true, "named": true,
"fields": { "fields": {
"asvar": { "asvar": {
@@ -341,28 +341,12 @@
] ]
}, },
"tag": { "tag": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "blocktrans", "type": "blocktrans",
"named": false "named": false
},
{
"type": "blocktranslate",
"named": false
},
{
"type": "endblocktrans",
"named": false
},
{
"type": "endblocktranslate",
"named": false
},
{
"type": "plural",
"named": false
} }
] ]
}, },
@@ -389,6 +373,10 @@
"type": "filtered_value", "type": "filtered_value",
"named": true "named": true
}, },
{
"type": "plural_clause",
"named": true
},
{ {
"type": "template_variable", "type": "template_variable",
"named": true "named": true
@@ -396,6 +384,98 @@
] ]
} }
}, },
{
"type": "blocktranslate_clause",
"named": true,
"fields": {
"asvar": {
"multiple": true,
"required": false,
"types": [
{
"type": "identifier",
"named": true
}
]
},
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "blocktranslate",
"named": false
}
]
},
"variable": {
"multiple": true,
"required": false,
"types": [
{
"type": "identifier",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "content",
"named": true
},
{
"type": "filtered_value",
"named": true
},
{
"type": "plural_clause",
"named": true
},
{
"type": "template_variable",
"named": true
}
]
}
},
{
"type": "blocktranslate_group",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "endblocktrans",
"named": false
},
{
"type": "endblocktranslate",
"named": false
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "blocktrans_clause",
"named": true
},
{
"type": "blocktranslate_clause",
"named": true
}
]
}
},
{ {
"type": "boolean", "type": "boolean",
"named": true, "named": true,
@@ -466,20 +546,16 @@
} }
}, },
{ {
"type": "comment_group", "type": "comment_clause",
"named": true, "named": true,
"fields": { "fields": {
"tag": { "tag": {
"multiple": true, "multiple": false,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "comment", "type": "comment",
"named": false "named": false
},
{
"type": "endcomment",
"named": false
} }
] ]
} }
@@ -499,6 +575,32 @@
] ]
} }
}, },
{
"type": "comment_group",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "endcomment",
"named": false
}
]
}
},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "comment_clause",
"named": true
}
]
}
},
{ {
"type": "csp_nonce_attr", "type": "csp_nonce_attr",
"named": true, "named": true,
@@ -2009,6 +2111,36 @@
] ]
} }
}, },
{
"type": "plural_clause",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "plural",
"named": false
}
]
}
},
"children": {
"multiple": true,
"required": false,
"types": [
{
"type": "content",
"named": true
},
{
"type": "template_variable",
"named": true
}
]
}
},
{ {
"type": "predicate", "type": "predicate",
"named": true, "named": true,
@@ -2472,19 +2604,45 @@
} }
}, },
{ {
"type": "verbatim_group", "type": "verbatim_clause",
"named": true, "named": true,
"fields": { "fields": {
"tag": { "tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "verbatim",
"named": false
}
]
}
},
"children": {
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "endverbatim", "type": "push_verbatim",
"named": false "named": true
}, },
{ {
"type": "verbatim", "type": "verbatim_content",
"named": true
}
]
}
},
{
"type": "verbatim_group",
"named": true,
"fields": {
"tag": {
"multiple": false,
"required": true,
"types": [
{
"type": "endverbatim",
"named": false "named": false
} }
] ]
@@ -2499,11 +2657,7 @@
"named": true "named": true
}, },
{ {
"type": "push_verbatim", "type": "verbatim_clause",
"named": true
},
{
"type": "verbatim_content",
"named": true "named": true
} }
] ]
+24597 -55708
View File
File diff suppressed because it is too large. Load diff
+95 -14
View File
@@ -9,7 +9,8 @@ Blocktrans
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(content)) (blocktrans_clause
(content)))
(content)) (content))
================== ==================
@@ -23,7 +24,8 @@ Blocktranslate
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(content)) (blocktranslate_clause
(content)))
(content)) (content))
================== ==================
@@ -36,7 +38,8 @@ Blocktrans Empty
(template (template
(content) (content)
(blocktranslate_group) (blocktranslate_group
(blocktrans_clause))
(content)) (content))
================== ==================
@@ -50,12 +53,13 @@ Blocktrans With A Placeholder
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
(content) (content)
(template_variable (template_variable
(filtered_value (filtered_value
(value (value
(variable_attribute (variable_attribute
(identifier)))))) (identifier)))))))
(content)) (content))
================== ==================
@@ -69,7 +73,8 @@ Blocktrans Trimmed
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(content)) (blocktrans_clause
(content)))
(content)) (content))
================== ==================
@@ -83,12 +88,13 @@ Blocktrans With
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
variable: (identifier) variable: (identifier)
(filtered_value (filtered_value
(value (value
(variable_attribute (variable_attribute
(identifier)))) (identifier))))
(content)) (content)))
(content)) (content))
================== ==================
@@ -102,6 +108,7 @@ Blocktrans With Several Bindings
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
variable: (identifier) variable: (identifier)
(filtered_value (filtered_value
(value (value
@@ -112,7 +119,7 @@ Blocktrans With Several Bindings
(value (value
(variable_attribute (variable_attribute
(identifier)))) (identifier))))
(content)) (content)))
(content)) (content))
================== ==================
@@ -126,6 +133,7 @@ Blocktrans With A Filtered Binding
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
variable: (identifier) variable: (identifier)
(filtered_value (filtered_value
(value (value
@@ -133,7 +141,7 @@ Blocktrans With A Filtered Binding
(identifier))) (identifier)))
(filter_expression (filter_expression
(filter))) (filter)))
(content)) (content)))
(content)) (content))
================== ==================
@@ -147,11 +155,12 @@ Blocktrans With Context
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
(filtered_value (filtered_value
(value (value
(literal (literal
(string)))) (string))))
(content)) (content)))
(content)) (content))
================== ==================
@@ -165,8 +174,9 @@ Blocktrans With Asvar
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
asvar: (identifier) asvar: (identifier)
(content)) (content)))
(content)) (content))
================== ==================
@@ -180,13 +190,57 @@ Blocktrans With Count And Plural
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
variable: (identifier) variable: (identifier)
(filtered_value (filtered_value
(value (value
(variable_attribute (variable_attribute
(identifier)))) (identifier))))
(content) (content)
(plural_clause
(content))))
(content)) (content))
==================
Blocktrans With An Empty Singular
==================
{% blocktrans count n=x %}{% plural %}many{% endblocktrans %}
---
(template
(content)
(blocktranslate_group
(blocktrans_clause
variable: (identifier)
(filtered_value
(value
(variable_attribute
(identifier))))
(plural_clause
(content))))
(content))
==================
Blocktranslate With An Empty Plural
==================
{% blocktranslate count n=x %}one{% plural %}{% endblocktranslate %}
---
(template
(content)
(blocktranslate_group
(blocktranslate_clause
variable: (identifier)
(filtered_value
(value
(variable_attribute
(identifier))))
(content)
(plural_clause)))
(content)) (content))
================== ==================
@@ -200,6 +254,7 @@ Blocktrans With Every Option
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
variable: (identifier) variable: (identifier)
(filtered_value (filtered_value
(value (value
@@ -216,7 +271,8 @@ Blocktrans With Every Option
(string)))) (string))))
asvar: (identifier) asvar: (identifier)
(content) (content)
(content)) (plural_clause
(content))))
(content)) (content))
================== ==================
@@ -230,8 +286,9 @@ Blocktrans With Its Options Reordered
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(blocktrans_clause
asvar: (identifier) asvar: (identifier)
(content)) (content)))
(content)) (content))
================== ==================
@@ -244,6 +301,7 @@ Blocktrans Closed By The Other Spelling
--- ---
================== ==================
Blocktranslate Closed By The Other Spelling Blocktranslate Closed By The Other Spelling
:error :error
@@ -254,6 +312,7 @@ Blocktranslate Closed By The Other Spelling
--- ---
================== ==================
Blocktrans With Count And No Plural Blocktrans With Count And No Plural
:error :error
@@ -264,6 +323,7 @@ Blocktrans With Count And No Plural
--- ---
================== ==================
Blocktrans With Plural And No Count Blocktrans With Plural And No Count
:error :error
@@ -274,6 +334,7 @@ Blocktrans With Plural And No Count
--- ---
================== ==================
Blocktrans Counting Two Bindings Blocktrans Counting Two Bindings
:error :error
@@ -284,6 +345,7 @@ Blocktrans Counting Two Bindings
--- ---
================== ==================
Blocktrans With Nothing To Bind Blocktrans With Nothing To Bind
:error :error
@@ -294,6 +356,7 @@ Blocktrans With Nothing To Bind
--- ---
================== ==================
Blocktrans With An Unknown Option Blocktrans With An Unknown Option
:error :error
@@ -304,6 +367,7 @@ Blocktrans With An Unknown Option
--- ---
================== ==================
Blocktrans With Asvar And No Name Blocktrans With Asvar And No Name
:error :error
@@ -314,6 +378,7 @@ Blocktrans With Asvar And No Name
--- ---
================== ==================
Blocktrans Holding A Tag Blocktrans Holding A Tag
:error :error
@@ -324,6 +389,7 @@ Blocktrans Holding A Tag
--- ---
================== ==================
Blocktrans Holding A Comment Blocktrans Holding A Comment
:error :error
@@ -334,6 +400,7 @@ Blocktrans Holding A Comment
--- ---
================== ==================
Blocktrans Holding Another Blocktrans Blocktrans Holding Another Blocktrans
:error :error
@@ -344,6 +411,7 @@ Blocktrans Holding Another Blocktrans
--- ---
================== ==================
Blocktrans With Two Plurals Blocktrans With Two Plurals
:error :error
@@ -354,6 +422,7 @@ Blocktrans With Two Plurals
--- ---
================== ==================
Blocktrans With An Argument On Plural Blocktrans With An Argument On Plural
:error :error
@@ -363,6 +432,8 @@ Blocktrans With An Argument On Plural
--- ---
================== ==================
Blocktrans With Trimmed Twice Blocktrans With Trimmed Twice
:error :error
@@ -373,6 +444,7 @@ Blocktrans With Trimmed Twice
--- ---
================== ==================
Blocktrans With With Twice Blocktrans With With Twice
:error :error
@@ -383,6 +455,7 @@ Blocktrans With With Twice
--- ---
================== ==================
Blocktrans With Context Twice Blocktrans With Context Twice
:error :error
@@ -393,6 +466,7 @@ Blocktrans With Context Twice
--- ---
================== ==================
Blocktrans With Asvar Twice Blocktrans With Asvar Twice
:error :error
@@ -403,6 +477,7 @@ Blocktrans With Asvar Twice
--- ---
================== ==================
Blocktrans With Count Twice Blocktrans With Count Twice
:error :error
@@ -413,6 +488,7 @@ Blocktrans With Count Twice
--- ---
================== ==================
Blocktranslate With Trimmed Twice Blocktranslate With Trimmed Twice
:error :error
@@ -423,6 +499,7 @@ Blocktranslate With Trimmed Twice
--- ---
================== ==================
Blocktrans Repeating An Option Of The Tag Before It Blocktrans Repeating An Option Of The Tag Before It
================== ==================
@@ -434,9 +511,11 @@ Blocktrans Repeating An Option Of The Tag Before It
(template (template
(content) (content)
(blocktranslate_group (blocktranslate_group
(content)) (blocktrans_clause
(content)))
(blocktranslate_group (blocktranslate_group
(content)) (blocktrans_clause
(content)))
(content)) (content))
================== ==================
@@ -447,3 +526,5 @@ Blocktrans With A Binding Twice
{% blocktrans with a=1 a=2 %}x{% endblocktrans %} {% blocktrans with a=1 a=2 %}x{% endblocktrans %}
--- ---
+8 -4
View File
@@ -11,7 +11,8 @@ This is ignored
(template (template
(content) (content)
(comment_group (comment_group
(comment_content)) (comment_clause
(comment_content)))
(content)) (content))
================== ==================
@@ -24,7 +25,8 @@ Comment Empty
(template (template
(content) (content)
(comment_group) (comment_group
(comment_clause))
(content)) (content))
================== ==================
@@ -40,8 +42,9 @@ This is ignored
(template (template
(content) (content)
(comment_group (comment_group
(comment_clause
(string) (string)
(comment_content)) (comment_content)))
(content)) (content))
================== ==================
@@ -57,5 +60,6 @@ Contains {% if x %} tag-like text
(template (template
(content) (content)
(comment_group (comment_group
(comment_content)) (comment_clause
(comment_content)))
(content)) (content))
+10 -5
View File
@@ -9,8 +9,9 @@ Verbatim Basic
(template (template
(content) (content)
(verbatim_group (verbatim_group
(verbatim_clause
(push_verbatim) (push_verbatim)
(verbatim_content) (verbatim_content))
(pop_verbatim)) (pop_verbatim))
(content)) (content))
@@ -25,7 +26,8 @@ Verbatim Empty
(template (template
(content) (content)
(verbatim_group (verbatim_group
(push_verbatim) (verbatim_clause
(push_verbatim))
(pop_verbatim)) (pop_verbatim))
(content)) (content))
@@ -43,8 +45,9 @@ Verbatim Ignores Tags
(template (template
(content) (content)
(verbatim_group (verbatim_group
(verbatim_clause
(push_verbatim) (push_verbatim)
(verbatim_content) (verbatim_content))
(pop_verbatim)) (pop_verbatim))
(content)) (content))
@@ -59,8 +62,9 @@ Verbatim With Name
(template (template
(content) (content)
(verbatim_group (verbatim_group
(verbatim_clause
(push_verbatim) (push_verbatim)
(verbatim_content) (verbatim_content))
(pop_verbatim)) (pop_verbatim))
(content)) (content))
@@ -77,7 +81,8 @@ Avoid template rendering via the {% verbatim %}{% endverbatim %} block.
(template (template
(content) (content)
(verbatim_group (verbatim_group
(verbatim_clause
(push_verbatim) (push_verbatim)
(verbatim_content) (verbatim_content))
(pop_verbatim)) (pop_verbatim))
(content)) (content))