Skip to content

Commit

Permalink
How to resolve conflicts?
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Aug 7, 2024
1 parent a3dc38c commit 6bdeb57
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 31 deletions.
43 changes: 23 additions & 20 deletions common/define-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ module.exports = function defineGrammar(dialect) {
]).concat(
dialect === 'typescript' ? [
[$.primary_type, $.type_parameter],
] : [
] : dialect === 'tsx' ? [
[$.jsx_opening_element, $.type_parameter],
[$.jsx_namespace_name, $.primary_type],
],
] : dialect === 'gts' ? [
[$.glimmer_template, $.primary_type, $.type_parameter],
] : [],
),

inline: ($, previous) => previous
Expand Down Expand Up @@ -222,7 +224,7 @@ module.exports = function defineGrammar(dialect) {
choices.push($.type_assertion);
choices.push(...previous.members.filter((member) => {
return member.name !== '_jsx_element' && member.name !== 'glimmer_template';
}
},
));
} else if (dialect === 'gts') {
choices.push($.type_assertion);
Expand All @@ -240,23 +242,24 @@ module.exports = function defineGrammar(dialect) {
return choice(...choices);
},

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>',
// This rule is only referenced by expression when the dialect is 'gts'
// 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_start_opening_element: $ => seq(
'<',
Expand Down
31 changes: 20 additions & 11 deletions gts/src/grammar.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "tsx",
"inherits": "javascript",
"name": "gts",
"word": "identifier",
"rules": {
"program": {
Expand Down Expand Up @@ -2017,15 +2016,19 @@
},
{
"type": "SYMBOL",
"name": "primary_expression"
"name": "glimmer_template"
},
{
"type": "SYMBOL",
"name": "glimmer_template"
"name": "type_assertion"
},
{
"type": "SYMBOL",
"name": "_jsx_element"
"name": "primary_expression"
},
{
"type": "SYMBOL",
"name": "glimmer_template"
},
{
"type": "SYMBOL",
Expand Down Expand Up @@ -6583,6 +6586,14 @@
"content": {
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "template",
"content": {
"type": "SYMBOL",
"name": "glimmer_template"
}
},
{
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -11296,12 +11307,10 @@
"template_string"
],
[
"jsx_opening_element",
"type_parameter"
],
[
"jsx_namespace_name",
"primary_type"
"glimmer_template",
"primary_type",
"type_parameter",
"glimmer_template"
]
],
"precedences": [
Expand Down

0 comments on commit 6bdeb57

Please sign in to comment.