Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ noJSX(JavaScript);
*/
module.exports = grammar(JavaScript, {
name: "glimmer_javascript",

externals: ($, previous) => previous.concat([$.raw_text]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does externals work? I should have asked this on the other PR -- but I mostly trust the tests to keep anything from regressing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood what it meant! I think it means it gets that variable from an external parser. I based this on Vue and Svelte, and I’m pretty sure they have external parsers. Will create PRs to remove it!


rules: {
/**
* TODO: add support for attributes
Expand All @@ -59,23 +62,13 @@ module.exports = grammar(JavaScript, {
* https://github.com/emberjs/rfcs/
*/
glimmer_template: ($) =>
choice(
seq(
field("open_tag", $.glimmer_opening_tag),
// field("content", $.glimmer_template_content),
field("content", repeat($._glimmer_template_content)),
optional(alias(repeat($._glimmer_template_content), $.raw_text)),
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_template_content: ($) => repeat1($._glimmer_template_content),
glimmer_opening_tag: (_) => "<template>",
glimmer_closing_tag: (_) => "</template>",

Expand Down
63 changes: 25 additions & 38 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2395,60 +2395,43 @@
]
},
"glimmer_template": {
"type": "CHOICE",
"type": "SEQ",
"members": [
{
"type": "SEQ",
"type": "FIELD",
"name": "open_tag",
"content": {
"type": "SYMBOL",
"name": "glimmer_opening_tag"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "open_tag",
"content": {
"type": "SYMBOL",
"name": "glimmer_opening_tag"
}
},
{
"type": "FIELD",
"name": "content",
"type": "ALIAS",
"content": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_glimmer_template_content"
}
}
},
"named": true,
"value": "raw_text"
},
{
"type": "FIELD",
"name": "close_tag",
"content": {
"type": "SYMBOL",
"name": "glimmer_closing_tag"
}
"type": "BLANK"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "open_tag",
"content": {
"type": "SYMBOL",
"name": "glimmer_opening_tag"
}
},
{
"type": "FIELD",
"name": "close_tag",
"content": {
"type": "SYMBOL",
"name": "glimmer_closing_tag"
}
}
]
"type": "FIELD",
"name": "close_tag",
"content": {
"type": "SYMBOL",
"name": "glimmer_closing_tag"
}
}
]
},
Expand Down Expand Up @@ -6533,6 +6516,10 @@
{
"type": "SYMBOL",
"name": "jsx_text"
},
{
"type": "SYMBOL",
"name": "raw_text"
}
],
"inline": [
Expand Down
15 changes: 15 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,16 @@
}
]
}
},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "raw_text",
"named": true
}
]
}
},
{
Expand Down Expand Up @@ -2242,6 +2252,11 @@
]
}
},
{
"type": "raw_text",
"named": true,
"fields": {}
},
{
"type": "regex",
"named": true,
Expand Down
Loading
Loading