ableC icon indicating copy to clipboard operation
ableC copied to clipboard

Minor syntax extensibility enhancement

Open tedinski opened this issue 7 years ago • 2 comments

I was trying a small experiment, and please note I haven't thought this all the way through, that looks like this:

marking_terminal {
  custom_extension_syntax here;
  Declaration_c;
  etc etc;
}

Basically, extension syntax that allows its own declarations syntax to be along side plain C host declarations. This doesn't work, but only just.

I think we could make it work by moving the semicolon:

closed nonterminal Declaration_c with location, ast<ast:Decl>;
concrete productions top::Declaration_c
| ds::DeclarationSpecifiers_c  idcl::InitDeclaratorList_c  ';'
| ds::DeclarationSpecifiers_c  ';'


closed nonterminal ExternalDeclaration_c with location, ast<ast:Decl>; 
concrete productions top::ExternalDeclaration_c
| d::Declaration_c 
| d::FunctionDefinition_c 

If we put that semi-colon outside of Declaration_c (and so adding it wherever that nonterminal is used, like in ExternalDeclaration_c above), I think it works fine. Basically, the problem is right now we're spilling into the follow set of Declaration_c, but if we move the semicolon out, we avoid that. I don't think any of the other MDA restrictions would upset this scheme.

Any thoughts?

tedinski avatar Aug 21 '18 22:08 tedinski

Hmm, seems like a reasonable thing to want to do. I am fine with this change, although this will probably break a few of the tutorials and extensions.

krame505 avatar Aug 21 '18 22:08 krame505

Another thing to maybe do, if this works, is write up a very short bit of documentation for melt-website about "things to do to make syntax more extensible under the MDA." I think we've only ever written about this stuff in papers, and this sort of thing might be another item to add to the list. I don't recall having to do something like this before.

tedinski avatar Aug 21 '18 23:08 tedinski