Re: Feedback on using Synopsis for source-to-source C++ transformation
Stefan Seefeld <[email protected]> Fri, 09 Jan 2009 22:44:20 -0500
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Message-ID | <[email protected]> |
Francis,
thanks for your interest into Synopsis, and thanks for sending me
feedback. That's very much appreciated !
(I would suggest we continue this discussion on the mailing list,
though, hoping that some others may find this useful and have some
thoughts to share.)
francis maes wrote:
>
> My aim is to transform extended C++ including into standard C++. The
> extended C++ includes new statements and expressions that deal with
> machine-learning.
>
That's interesting. Curiously, though, I'v been slowly removing support
for 'extended C++' from Synopsis, as I expect alternative ways to
annotate C++ code (and script synopsis) to be better approaches. May be
we can discuss that a bit.
> The files Input.cr++ and Output.hpp show an example of my
> transformation. The new keywords are "crAlgorithm",
> "featureGenerator", "featureScope", "featureSense", "choose", "reward"
> and "actionValue".
>
Have you considered the possibility to store such annotation in separate
files with which you would instruct Synopsis how to transform the source
code ? Changing the parser / frontend isn't particularly flexible...
> In order to fit my needs, I performed some modifications to the code
> of synopsis (release 0.11).
>
> * New baseclass "RewriteVisitor" whose default implementation clones a
> PTree (file RewriteVisitor.h). I use this base class for all the
> visitors that perform source-to-source transformation.
>
Can you describe in what way the existing Visitor base class isn't
generic enough for your needs ?
> * A new PrettyPrinter class (file PrettyPrintVisitor.h). This class
> is similar to PTree::Writer, but it includes several hand-made
> formatting rules (that match with my coding style..). This class is
> unfinished yet.
>
OK.
> * A set of utility functions to create PTree nodes (file
> CreatePTree.h). These utility functions simply the work of generating
> new PTree nodes.
>
Right. (There were similar functions in prior versions of Synopsis, but
I removed them for a number of reasons. (The main reason was
incompatible licensing, i.e. copyright from Xerox.)
But I agree a new set of PTree::Node factory functions is needed for
true source-to-source translation.
> * New entry points in the Parser. In order to extend the grammar, I
> first started to explore the features related to OpenC++ in the
> parser. As these features seemed to be half-dead, I finally added new
> entry points to "hack" the parser (file Parser.hh and Parser.cc): see
> parse_user_statement() and parse_user_postfix_expr(). See file
> CRAlgoParser.h for an example of use.
>
I will look into those when I get a chance. I'm curious how generic /
flexible these additions are. In general I believe it to be better not
to modify the language itself, but instead provide annotations (that
could be stored in C++ comments, or in completely separate annotation /
config files) that allow Synopsis to transform the Parse Tree once it is
created, instead of handle such extensions in the parser.
> * New "user" PTree::Node classes. I added the classes
> UserStatementExpr and UserStatement into the PTree hierarchy and into
> PTree::Visitor.
> * CMake configuration file. In order to integrate Synopsis in my
> project I created a CMake configuration file. This configuration file
> is far from dealing with the whole Synopsis project. For the moment, I
> only deal with the subset "src/Synopsis, src/Synopsis/PTree,
> src/Synopsis/SymbolLookup and src/Synopsis/TypeAnalysis".
>
> BugReport:
> * I have troubles for parsing a constructor whose implementation is inlined.
> For example:
>
May I ask you to file this in the bug tracker at
http://synopsis.fresco.org/issues/bug ? I'll look into it soon.
Many thanks,
Stefan
--
...ich hab' noch einen Koffer in Berlin...