Help getting started

Hi all,

I'm interested in implementing a C++ syntax extension, described here: The
idea is that it would be a pure syntax extension for function
templates. With a little help from a C++ grammar expert, I have the
grammar productions written out already. What's not clear to me now,
though, is what approach to take in implementing it. One possibility is
to reimplement the code for parsing function templates, but that code
does a *lot* more than merely parsing. Another approach I can think of
is to modify the existing function template parsing code to handle this
alternate syntax in parallel, but that looks hard. Any advice

Thanks in advance,

When you're implementing a feature for the first time, it's typically easier to build up from nothing rather than splice the feature into existing parsing code. This way, you can slowly grow the syntax and semantics that you want to accept, and won't get nearly as many surprises ("wait, I meant to disallow that…"). Naturally, you should factor out common functionality along the way so you're not repeating code.

For the extension you're discussing, specifically, it looks like it's syntactically distinct enough that it should be relatively easy to identify based on the "[] unqualified-id" prefix when you're parsing one of your new function (templates). You'll want to synthesize template parameters and parameter/function declarators so that your new parsing code ends up calling a similar sequence of Sema actions to the "normal" code path.

  - Doug