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

Improve AST structure for type parameters #5

Open
mads-hartmann opened this issue Feb 25, 2018 · 0 comments
Open

Improve AST structure for type parameters #5

mads-hartmann opened this issue Feb 25, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@mads-hartmann
Copy link
Contributor

From a discussion during #1 :

Now that I'm seeing how much structure there is to type parameters, I think we should tweak their
structure so that there is always a visible syntax node corresponding to each parameter (as opposed to the identifier and upper_bound node appearing as siblings within the type_parameters node).

==================
Type parameters
==================

class A[B, +C <: D, -E : F : G]

---

(compilation_unit
  (class_definition
    (identifier)
    (type_parameters
      (invariant_type_parameter (type_identifier))
      (covariant_type_parameter
        (type_identifier)
        (upper_bound (type_identifier)))
      (contravariant_type_parameter
        (type_identifier)
        (context_bound (type_identifier))
        (context_bound (type_identifier))))))

Does that make sense? We could have a hidden helper rule called _type_parameter that is shared between the three. In addition, we should add the _type_parameter to the inline section of the
grammar. That will avoid actually creating that node at runtime for performance reasons.

@susliko susliko added the enhancement New feature or request label Jun 9, 2023
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

No branches or pull requests

2 participants