Re: The Array type

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.documentation.synopsis
Message-ID <[email protected]>
Hi Luke,

I'll answer the first part of your question in a separate mail
(not today, mind you).

Luke Petre wrote:

> I'm also very curious where the //.< syntax is handled.  I've looked 
> everywhere and can't really get my head around the previous comment 
> feature.

that's done by a 'CommentProcessor', specifically the python module
Synopsis.Processors.Comments.Previous.

The way it works is that the parser attaches all preceeding comments
verbatim to a given declaration (in fact, the declaration following
the comment, if there is one), and then a couple of (python)
processors is run over them.
The first is 'Synopsis.Processors.Comments.SSDComments, filtering out
those comments starting with '//.', and stripping that prefix.
Then 'Synopsis.Processors.Comments.Previous' is used to find the ones
that start with '<', reattaching them to the previous declaration.
Thus, you can write

struct Foo
{
   int a; //.< doc for 'a'
   int b; //.< doc for 'b'
};

which will generate an AST like this:

<Foo>
   +-----<a>
   +-----<b>--< //.< doc for 'a' >
   +-----<EOS>--< //.< doc for 'b' >

Note that the 'a' comment is attached to 'b' (as it preceeds it, not 'a'),
and there is a trailing comment, so we inject an 'EOS' (End Of Scope) node.

After running the comment processors, the AST structure changes, as well
as the content of the comments:

<Foo>
   +-----<a>--< doc for 'a' >
   +-----<b>--< doc for 'b' >
   +-----<EOS>

That's it. Now I should take the above and drop it into the tutorial :-)

> Keep up the excellent work!

Thanks. In fact, I'm working on the C++ parser right now, to be able to
expose a much more rich AST to python to allow real code inspection and
following that code generation.
Drop in if you have ideas or even want to help :-)

Regards,
		Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.