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

Add visibility and opacity modifiers #17

Closed
J3RN opened this issue Feb 25, 2022 · 0 comments · Fixed by #18
Closed

Add visibility and opacity modifiers #17

J3RN opened this issue Feb 25, 2022 · 0 comments · Fixed by #18

Comments

@J3RN
Copy link
Member

J3RN commented Feb 25, 2022

Gleam features a pub modifier for constants, types, functions (internal and external), type definitions, and type aliases. Additionally, it also features an opaque modifier for type definitions and type aliases.

Presently, an construct with a modifier is represented as a different base AST node than the same construct without a modifier. For example:

const foo = "bar"

is represented as

(constant
 name: (identifier)
 value: (string
  (quoted_content)))

and the version with the public modifier:

pub const foo = "bar"

is represented as

(public_constant
 name: (identifier)
 value: (string
  (quoted_content)))

In the interest of usability, we should move to make constructs with and without a modifier share the same base AST node while the construct with the modifier should have an additional child node for the modifier.

e.g.

pub const foo = "bar"

should be represented as

(constant
 (visiblity_modifier)
 name: (identifier)
 value: (string
  (quoted_content)))

This behavior also exists in tree-sitter-rust.

@J3RN J3RN mentioned this issue Feb 26, 2022
@J3RN J3RN changed the title Add visibility and opaque modifiers Add visibility and opacity modifiers Feb 26, 2022
@J3RN J3RN closed this as completed in #18 Feb 28, 2022
J3RN pushed a commit that referenced this issue Feb 28, 2022
closes #17

This refactor brings this grammar more in line with tree-sitter-rust.
A function or type declaration may have a visibility modifier ("pub") and
type declarations may also have an opacity modifier ("opaque"). This ends
up reducing the number of named rules, which cleans up the queries a bit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant