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

Refactor concrete syntax to permit type expressions that disallow struct/enum/union declarations #107

Open
krame505 opened this issue May 2, 2018 · 0 comments

Comments

@krame505
Copy link
Member

krame505 commented May 2, 2018

This is primarily for melt-umn/ableC-closure#3, but could be useful for extensions in general.
In some places in C++ (e.g. lambdas) type expressions that aren't a struct/enum/union declaration are permitted to be followed by a {. Currently in ableC we don't segregate type expressions in this way, so it isn't possible for extensions to mimic such C++ syntax.
I propose that we split TypeSpecifier_c into 2 nonterminals:

  • DefTypeSpecifier_c contains only struct, enum and union definition (but not tag reference) type expressions. The follow set for this does not contain '{'
  • BasicTypeSpecifier_c contains everything else in TypeSpecifier_c. The follow set here would be seeded with '{'.

The TypeSpecifier_c nonterminal as-is would contain productions to both of these new nonterminals. We would introduce a new BasicSpecifierQualifierList_c mirroring SpecifierQualifierList_c, but instead with BasicTypeSpecifier_c, while SpecifierQualifierList_c would remain unchanged. Extensions wishing to use a type expression followed by '{' (such as closure) would then use BasicSpecifierQualifierList_c. Extensions defining new type expressions that end in braces (such as algebraic datatypes) would now define their productions on DefTypeSpecifier_c, while all other new type expressions (such as the closure type expression) would be defined on BasicTypeSpecifier_c.

Thoughts? If approved I might attempt this over the weekend.

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

No branches or pull requests

1 participant