Skip to content

Commit

Permalink
feat!: remove glimmer template tags
Browse files Browse the repository at this point in the history
There is now a glimmer parser that's been out for a while now, glimmer
parsers should be using this.
  • Loading branch information
amaanq committed Oct 26, 2024
1 parent c4ce9dc commit a2ef079
Show file tree
Hide file tree
Showing 7 changed files with 49,853 additions and 52,135 deletions.
32 changes: 4 additions & 28 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ module.exports = grammar({

expression: $ => choice(
$.primary_expression,
$.glimmer_template,
$._jsx_element,
$.assignment_expression,
$.augmented_assignment_expression,
Expand Down Expand Up @@ -586,24 +585,6 @@ module.exports = grammar({
']',
),

glimmer_template: $ => choice(
seq(
field('open_tag', $.glimmer_opening_tag),
field('content', repeat($._glimmer_template_content)),
field('close_tag', $.glimmer_closing_tag),
),
// empty template has no content
// <template></template>
seq(
field('open_tag', $.glimmer_opening_tag),
field('close_tag', $.glimmer_closing_tag),
),
),

_glimmer_template_content: _ => /.{1,}/,
glimmer_opening_tag: _ => '<template>',
glimmer_closing_tag: _ => '</template>',

_jsx_element: $ => choice($.jsx_element, $.jsx_self_closing_element),

jsx_element: $ => seq(
Expand Down Expand Up @@ -1086,17 +1067,15 @@ module.exports = grammar({
),

identifier: _ => {
// eslint-disable-next-line max-len
const alpha = /[^\x00-\x1F\s\p{Zs}0-9:;`"'@#.,|^&<=>+\-*/\\%?!~()\[\]{}\uFEFF\u2060\u200B\u2028\u2029]|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\}/;
// eslint-disable-next-line max-len

const alphanumeric = /[^\x00-\x1F\s\p{Zs}:;`"'@#.,|^&<=>+\-*/\\%?!~()\[\]{}\uFEFF\u2060\u200B\u2028\u2029]|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\}/;
return token(seq(alpha, repeat(alphanumeric)));
},

private_property_identifier: _ => {
// eslint-disable-next-line max-len
const alpha = /[^\x00-\x1F\s\p{Zs}0-9:;`"'@#.,|^&<=>+\-*/\\%?!~()\[\]{}\uFEFF\u2060\u200B\u2028\u2029]|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\}/;
// eslint-disable-next-line max-len

const alphanumeric = /[^\x00-\x1F\s\p{Zs}:;`"'@#.,|^&<=>+\-*/\\%?!~()\[\]{}\uFEFF\u2060\u200B\u2028\u2029]|\\u[0-9a-fA-F]{4}|\\u\{[0-9a-fA-F]+\}/;
return token(seq('#', alpha, repeat(alphanumeric)));
},
Expand Down Expand Up @@ -1152,7 +1131,6 @@ module.exports = grammar({
seq(field('member', $.method_definition), optional(';')),
seq(field('member', $.field_definition), $._semicolon),
field('member', $.class_static_block),
field('template', $.glimmer_template),
';',
)),
'}',
Expand Down Expand Up @@ -1253,8 +1231,7 @@ module.exports = grammar({
*
* @param {Rule} rule
*
* @return {SeqRule}
*
* @returns {SeqRule}
*/
function commaSep1(rule) {
return seq(rule, repeat(seq(',', rule)));
Expand All @@ -1265,8 +1242,7 @@ function commaSep1(rule) {
*
* @param {Rule} rule
*
* @return {ChoiceRule}
*
* @returns {ChoiceRule}
*/
function commaSep(rule) {
return optional(commaSep1(rule));
Expand Down
2 changes: 0 additions & 2 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

; Special identifiers
;--------------------
(glimmer_opening_tag) @tag.builtin
(glimmer_closing_tag) @tag.builtin

((identifier) @constructor
(#match? @constructor "^[A-Z]"))
Expand Down
4 changes: 0 additions & 4 deletions queries/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,3 @@
(#eq? @_name "hbs"))
arguments: ((template_string) @glimmer
(#offset! @glimmer 0 1 0 -1)))

; Ember Unified <template> syntax
; e.g.: <template><SomeComponent @arg={{double @value}} /></template>
((glimmer_template) @glimmer)
82 changes: 0 additions & 82 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 0 additions & 48 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a2ef079

Please sign in to comment.