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

Changed all the keywords to anonymous nodes #17

Merged
merged 5 commits into from
Jul 7, 2024

Conversation

jpt13653903
Copy link
Owner

@Chris44442, @superzanti,

I got annoyed with all the keywords that are explicit in the syntax tree, so I changed them all to anonymous nodes (i.e. strings, like the operators are at the moment).

But I need a second opinion... Is this a good idea? Should I merge this? Are there keywords (like all, for example, that are better left explicit?

@jpt13653903 jpt13653903 added the enhancement New feature or request label Jul 6, 2024
@jpt13653903 jpt13653903 self-assigned this Jul 6, 2024
@Chris44442
Copy link
Contributor

I have tried it with a few of my vhdl files, and looked through your tests. Looks good to me, makes the tree more concise.

I don't think these keywords need to be present in the tree. Most of them are implied anyway. In other languages the tree-sitter doesn't explicitly spell them out neither (at least the ones i have tried).

@jpt13653903
Copy link
Owner Author

The one I'm wondering about now is the architecture declaration followed by identifier and name. I think I should clarify that with field names (I agree that removing the keywords was a good choice, but now that part of the tree is not quite as readable).

Let me come up with something and then push to this PR... I'm thinking to use the italic parts in the formal grammar for the field names...

@jpt13653903
Copy link
Owner Author

I'm quite happy with the commit above. It certainly makes the highlights easier:

(_ view: (_) @type)
(_ type: (_) @type)
(_ library: (_) @namespace)
(_ package: (_) @namespace)
(_ entity: (_) @namespace)
(_ component: (_) @namespace)
(_ configuration: (_) @type.parameter)
(_ architecture: (_) @type.parameter)
(_ function: (_) @function)
(_ procedure: (_) @function.method)
(_ attribute: (_) @attribute)

(_ view: (name (_)) @type)
(_ type: (name (_)) @type)
(_ entity: (name (_)) @namespace)
(_ component: (name (_)) @namespace)
(_ configuration: (name (_)) @namespace)

An architecture now builds the following tree:

(design_file
  (design_unit
    (architecture_definition
      architecture: (identifier)
      entity: (name
        (identifier))
    (architecture_head
      ...
    (concurrent_block
      ...
    (end_architecture
      architecture: (identifier)))))

I'm going to merge to develop and then we can continue testing...

@jpt13653903 jpt13653903 merged commit a5e5085 into develop Jul 7, 2024
4 checks passed
@jpt13653903 jpt13653903 deleted the experiment/anonymous_keywords branch July 7, 2024 16:24
@superzanti
Copy link

I think this is a good idea - anonymous nodes can still be used in most tree-sitter extensions.
I'm fixing most of my scm files now, so I'll let you know if there are any keywords that would be better lefts as non-anonymous. I'll let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants