Sreenivasa Viswanadha | 21 Feb 19:28 2011
Picon

JavaCC can now generate C++!

Hi All,

I'm very happy to let you all know I just enhanced javacc to generate 
lexers and parsers in C++. Not jjtree yet, but just the parsing part is 
done. It was surprisingly easy to do. Of course, I did not do the 
refactoring for general support of other languages but just made a few 
tweaks here and there (< 100 places) to get it to generate lexers and 
parsers in C++ that look almost the same as the java grammars. But I 
think we can now start with this and do better refactoring since we have 
two languages to keep us honest. Anyway, I'm glad I finally did 
something in JavaCC after more than 10 years!

I think this shows the power of simplicity. When Sriram and I first 
built JavaCC way back in 1996, we were thinking of doing C++ but we 
never needed to do it. But we did keep the code looking like C as much 
as possible. That made it really easy for me to do this C++ support in a 
matter of days. In fact, I think we can even do C very easily by juts 
not generating the enclosing class!

I want to check it in directly into the trunk itself as I want this to 
eventually go out officially as JavaCC 6.0. If I don't hear any 
objections by later this evening, I'll check it in,

There are still some design issues with the non-Java support.

1. The whole PARSER_BEGIN/PARSER_END thing is too much java specific. So 
I temporarily changed it to copy the contents of this section directly 
into the parser class. So no looking for the 'class' keyword anymore.
2. Actions are just copied verbatim into the generated parser. I think 
this is OK.
(Continue reading)

Mazas Marc | 22 Feb 09:32 2011

RE: JavaCC can now generate C++!


Hi

May I make a few suggestions ?

Generating for 2+ languages could be the right moment for using a template engine and templates for the
currently hard coded code  ; Freecc used this approach, using Freemarker, and the (freecc engine) code is
clearer than the javacc engine code because the different phases are isolated.
Some of the JavaCC Options would drop, as it would be only a matter of using another set of templates.
But moreover, what I would like is to enable the user to provide his own templates to fine tune the generated
code to his needs (eg : one could want to use a pool of Token objects instead of allocating / gcing tons of
them, or to use any other input object than the InputStream or Reader ones without having to convert them, ...).

The auxilliary classes (ParseException, XXXTokenManager, SimpleCharStrema, XXXConstants,
TokenMgrError) would be easier to cleanup / maintain.

Speaking of freecc, its "injection" feature is a nice feature (and different from "action") : I would not be
surprised if this could be of great help for other languages.

Marc MAZAS

-----Message d'origine-----
De : Sreenivasa Viswanadha [mailto:sreeni <at> viswanadha.net] 
Envoyé : lundi 21 février 2011 19:29
À : users <at> javacc.java.net; dev <at> javacc.java.net
Objet : JavaCC can now generate C++!

Hi All,

I'm very happy to let you all know I just enhanced javacc to generate lexers and parsers in C++. Not jjtree
(Continue reading)

Picon

Re: JavaCC can now generate C++!

Hi,

If I may add to this thread:

I wholeheartedly agree, but would suggest that you take it one (major) 
step further,
and try to get JavaCC into the Eclipse project umbrella.

This would give you natural access to the full Eclipse infrastructure
including such elements as OSGi provisioning, XPand template engine, 
better plugin support
(not that eclipse-javacc from Sourceforge is bad, but it is not quite 
"there" yet :-) ) etc.

Eclipse also has a relationship with many major languages including 
Java, C++ and others.

Also, it would marry two of my top-10 all-time favourite tools :-)

- Jan

schoubo reasoning v/Jan Schoubo 

www.schoubo-reasoning.dk
+45 2575 5180

Søvænget 2, Stilling
DK-8660 Skanderborg 

“Reality is that which, when you stop believing in it, doesn't go away.”
(Continue reading)

cz | 22 Feb 16:16 2011
Picon

Re: JavaCC can now generate C++!

Hello, 

Am Dienstag, den 22.02.2011, 10:48 +0100 schrieb Jan Schoubo (schoubo
reasoning):
> Hi,
> 
> If I may add to this thread:
> 
> I wholeheartedly agree, but would suggest that you take it one
(major) 
> step further,
> and try to get JavaCC into the Eclipse project umbrella.
> 

before starting a flame war on this, I do not see any reason
to use the Eclipse umbrella. I do not see any advantages for JavaCC to
tie it in the OSGi world which is not given by e.g. Freemarker or any
other more lean solution. 

My 2c, Carsten 

Farrukh Najmi | 22 Feb 16:59 2011

Re: JavaCC can now generate C++!


+1 on Carsten's comment.

-1 on "try to get JavaCC into the Eclipse project umbrella"

On 02/22/2011 10:16 AM, cz wrote:
> Hello,
>
> Am Dienstag, den 22.02.2011, 10:48 +0100 schrieb Jan Schoubo (schoubo
> reasoning):
>> Hi,
>>
>> If I may add to this thread:
>>
>> I wholeheartedly agree, but would suggest that you take it one
> (major)
>> step further,
>> and try to get JavaCC into the Eclipse project umbrella.
>>
> before starting a flame war on this, I do not see any reason
> to use the Eclipse umbrella. I do not see any advantages for JavaCC to
> tie it in the OSGi world which is not given by e.g. Freemarker or any
> other more lean solution.
>
> My 2c, Carsten
>
>

--

-- 
Regards,
(Continue reading)

Farrukh Najmi | 22 Feb 18:40 2011

Re: JavaCC can now generate C++!


+1 on Carsten's comment.

-1 on "try to get JavaCC into the Eclipse project umbrella" as there is 
no need to tie JavaCC to eclipse.

On 02/22/2011 10:16 AM, cz wrote:
> Hello,
>
> Am Dienstag, den 22.02.2011, 10:48 +0100 schrieb Jan Schoubo (schoubo
> reasoning):
>> Hi,
>>
>> If I may add to this thread:
>>
>> I wholeheartedly agree, but would suggest that you take it one
> (major)
>> step further,
>> and try to get JavaCC into the Eclipse project umbrella.
>>
> before starting a flame war on this, I do not see any reason
> to use the Eclipse umbrella. I do not see any advantages for JavaCC to
> tie it in the OSGi world which is not given by e.g. Freemarker or any
> other more lean solution.
>
> My 2c, Carsten
>
>

--

-- 
(Continue reading)

Tom Copeland | 22 Feb 18:38 2011

Re: JavaCC can now generate C++!


On Feb 21, 2011, at 1:28 PM, Sreenivasa Viswanadha wrote:

> Hi All,
> 
> I'm very happy to let you all know I just enhanced javacc to generate lexers and parsers in C++.

Awesome!

> I want to check it in directly into the trunk itself as I want this to eventually go out officially as JavaCC
6.0. If I don't hear any objections by later this evening, I'll check it in,

By all means!

Yours,

Tom

Gmane