Skip to content
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

Attach attributes to their associated node #70

Closed
wants to merge 2 commits into from
Closed
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
5 changes: 3 additions & 2 deletions grammar.js
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure this will give tree-sitter better hints for error recovery. Plus we lose the ability to highlight attributes on their own - it's not important when parsing a complete/correct gleam file but it's a case that will come up as-you-type and if you want to show a snippet for just an attribute, like:

```gleam
@external(erlang, "erlang", "integer_to_list")
```

in a github comment for example.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module.exports = grammar({
$.function,
$.type_definition,
$.type_alias,
$.attribute
),

/* Comments */
Expand Down Expand Up @@ -247,6 +246,7 @@ module.exports = grammar({
function: ($) =>
prec.right(
seq(
repeat($.attribute),
optional($.visibility_modifier),
"fn",
field("name", $.identifier),
Expand Down Expand Up @@ -431,7 +431,7 @@ module.exports = grammar({
choice($._discard_param, $._name_param),
optional($._type_annotation)
),
block: ($) => seq("{", $._statement_seq, "}"),
block: ($) => seq(repeat($.attribute), "{", $._statement_seq, "}"),
case: ($) =>
seq(
"case",
Expand Down Expand Up @@ -667,6 +667,7 @@ module.exports = grammar({
/* Custom type definitions */
type_definition: ($) =>
seq(
repeat($.attribute),
optional($.visibility_modifier),
optional($.opacity_modifier),
"type",
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"homepage": "https://github.com/J3RN/tree-sitter-gleam#readme",
"dependencies": {
"nan": "^2.15.0"
"nan": "^2.18.0"
Copy link
Author

@deriamis deriamis Sep 19, 2023

Choose a reason for hiding this comment

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

This addresses nodejs/nan#942, which causes npm install failures on some platforms.

},
"devDependencies": {
"prettier": "^2.5.1",
Expand Down
25 changes: 21 additions & 4 deletions src/grammar.json

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

22 changes: 13 additions & 9 deletions src/node-types.json

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

Loading
Loading