-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GTS Dialect #308
GTS Dialect #308
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -215,22 +217,50 @@ module.exports = function defineGrammar(dialect) { | |
$.satisfies_expression, | ||
$.instantiation_expression, | ||
$.internal_module, | ||
$.glimmer_template, | ||
]; | ||
|
||
if (dialect === 'typescript') { | ||
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); | ||
choices.push(...previous.members.filter((member) => | ||
member.name !== '_jsx_element', | ||
)); | ||
} else if (dialect === 'tsx') { | ||
choices.push(...previous.members); | ||
choices.push(...previous.members.filter(member => { | ||
return member.name !== 'glimmer_template'; | ||
})); | ||
} else { | ||
throw new Error(`Unknown dialect ${dialect}`); | ||
} | ||
|
||
return choice(...choices); | ||
}, | ||
|
||
// 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( | ||
'<', | ||
optional( | ||
|
@@ -419,6 +449,7 @@ module.exports = function defineGrammar(dialect) { | |
class_body: $ => seq( | ||
'{', | ||
repeat(choice( | ||
field('template', $.glimmer_template), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only one of these may be present within the class_body |
||
seq( | ||
repeat(field('decorator', $.decorator)), | ||
$.method_definition, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const defineGrammar = require('../common/define-grammar'); | ||
|
||
module.exports = defineGrammar('gts'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"main": "../bindings/node/gts" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be provided by tree-sitter-javascript, yea?