Refactor concrete syntax to permit type expressions that disallow struct/enum/union declarations
This is primarily for https://github.com/melt-umn/ableC-closure/issues/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_ccontains only struct, enum and union definition (but not tag reference) type expressions. The follow set for this does not contain '{' -
BasicTypeSpecifier_ccontains everything else inTypeSpecifier_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.