Any news progress about C/C++ target for ANTLRv4 ?

2,500 views
Skip to first unread message

Ruslan Zasukhin

unread,
Mar 10, 2014, 7:42:55 AM3/10/14
to antlr-di...@googlegroups.com
Hi All,

Have gone may month...

Any news?
GIT URL where somebody or team works on C++ target?



--
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]



Terence Parr

unread,
Mar 10, 2014, 2:40:03 PM3/10/14
to antlr-di...@googlegroups.com
Hi. The word is "going well/work in progress” :)
Ter
> --
> You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ruslan Zasukhin

unread,
Mar 12, 2014, 6:54:18 PM3/12/14
to antlr-di...@googlegroups.com
On 3/10/14, 8:40 PM, "Terence Parr" <pa...@cs.usfca.edu> wrote:

Hi Ter,

Very good.

So it is not public available GIT?

Why not? We could see something on early stage.

Kind of Code Review
They say - it is a good idea :)

Terence Parr

unread,
Mar 12, 2014, 9:01:18 PM3/12/14
to antlr-di...@googlegroups.com
He wants to operate in stealth mode so people don't bug him ;)
T


--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dictation in use. Please excuse homophones, malapropisms, and nonsense. 

Warren Stringer

unread,
Mar 27, 2014, 4:48:27 PM3/27/14
to antlr-di...@googlegroups.com
Ok, so we'll bug you, instead ;)

Really looking forward to diving into V4 C++. 

Right now, I'm working full time on a V3 C runtime that is around 700 lines with lots of semantic predicate. The result is a 10MB parse.c file, which is slow to compile and excruciatingly slow to debug. But, it runs really fast. So, many thanks to Jim Idle.

If someone wants to give me a guestimate offline, I would really appreciated it! 

BTW, I wrote my own LL(k) parser generator, a few years ago, in Python, with a C++ runtime. Didn't release it because, I didn't want to be bugged either.

w

Mike Lischke

unread,
Mar 28, 2014, 3:05:41 AM3/28/14
to antlr-di...@googlegroups.com

Hey Warren,

Right now, I'm working full time on a V3 C runtime that is around 700 lines with lots of semantic predicate.

Predicates in the C runtime? Did you mean your grammar?

The result is a 10MB parse.c file, which is slow to compile and excruciatingly slow to debug. But, it runs really fast. So, many thanks to Jim Idle.

This is small. My lexer c file is 39MB in size. And I also had a lot of trouble when I loaded it into an IDE or even tried to debug it (XCode, I'm looking especially at you).

[offtopic]
With the new Visual 2013 release things have changed dramatically. This IDE loads the file as if it was just 1MB in size, reacts quickly wherever you are in the file and can debug with it as with any other source file (the 64K line limit for break points has fallen too). I was really impressed when I saw this in action the first time (not to mention the codemap which helps a lot in files like that which consists mainly of tables/arrays).
[/offtopic]


Terence Parr

unread,
Mar 29, 2014, 1:44:23 PM3/29/14
to antlr-di...@googlegroups.com
Yeah, afraid I can't even give you an estimate on C++ delivery time. sorry.  Cool that you build your own parser generator. It's fun, isn't it?

T

Ruslan Zasukhin

unread,
Mar 31, 2014, 12:25:11 PM3/31/14
to antlr-di...@googlegroups.com
On 3/29/14, 7:44 PM, "Terence Parr" <pa...@cs.usfca.edu> wrote:

> Yeah, afraid I can't even give you an estimate on C++ delivery time. sorry.
>  Cool that you build your own parser generator. It's fun, isn't it?

Hi Terrence,


Let me once again give a point.

Don't you think, that it is a good TAGET to implement
auto-generation of
Java / C++ / C# /

Runtimes for ANTLR ?


* We should not depend on wish of somebody to implement such runtime.

* It is really possible.

* How? You self have GENERATOR of code in your own ANTLR...

or may be TRANSLATOR.
Java -> C++
Java -> C#



* C++ or C# do not have such classes as Java have?
may be simply write thin-classes-wrappers
which have same names and funcs as Java java?

In this case C++/C# code can looks 100% same...


Hmm, may be even translator is not needed.
Or very simple one ...



* once again -- ALL This MANUAL solutions die very fast.
We need something AUTO-generated!

Terence Parr

unread,
Mar 31, 2014, 2:37:00 PM3/31/14
to antlr-di...@googlegroups.com


Don't you think, that it is a good TAGET to implement
 auto-generation of
            Java / C++ / C# /

 That would be nice but I don't see a perfect translator for C++ from Java. Also the implementation would likely be so suboptimal in the target language that the runtime would be way too slow to be useful. optimize data structures are critical for performance of the parser.
 

Runtimes for ANTLR ?


* We should not depend on wish of somebody to implement such runtime.

* It is really possible.

* How? You self have GENERATOR of code in your own ANTLR...

 or may be TRANSLATOR.
        Java -> C++
        Java -> C# 


* C++ or C# do not have such classes as Java have?
    may be simply write thin-classes-wrappers
    which have same names and funcs as Java java?

 The runtime is not generated by ANTLR itself. It is a Java library. That either has to be translated and then tweaked or simply re-implemented in the new language.

 All of these solutions are suboptimal.
 

In this case C++/C# code  can looks 100% same...


Hmm, may be even translator is not needed.
Or very simple one ...



* once again -- ALL This MANUAL solutions die very fast.
    We need something AUTO-generated!


 agreed but I don't see how this is possible at this time.

Ruslan Zasukhin

unread,
Apr 1, 2014, 7:14:10 AM4/1/14
to antlr-di...@googlegroups.com
On 3/31/14, 8:37 PM, "Terence Parr" <pa...@cs.usfca.edu> wrote:

>  That would be nice but I don't see a perfect translator for C++ from Java.
> Also the implementation would likely be so suboptimal in the target language
> that the runtime would be way too slow to be useful. optimize data structures
> are critical for performance of the parser.

Excuse me,

As they say, better to have CORRECT and SLOW algorithm,
then fast and wrong.

In our case, we for years !!! Do not have any...

So better to have ANY slower existed than
"best possible NOT EXISTED" C++ solution

Agree? :-)



Once again idea:
C++ is very flexible.
It is possible make set of classes, which will looks as Java classes


Translator may need only replace dots,
f.foo() to f->foo()

All rest is quite similar can be ...

Sam Harwell

unread,
Apr 1, 2014, 7:05:50 AM4/1/14
to antlr-di...@googlegroups.com
Hi Ruslan,

I am not aware of an automated tool capable of producing a translation of the ANTLR 4 runtime in another target language without *extensive* modification (not even one that's slow). No one currently working on ANTLR believes your proposed solution would produce the result you claim, which means we're unlikely to spend time trying to make it work. The only way this would happen is if someone who believes it could work (like you) actually spends the time proving that it really does work, and create a new language target as a result.

I'm not trying to discourage you, but this is simply the facts of the situation. It could happen, but only if you make it happen.

Sam

Ruslan Zasukhin

unread,
Apr 1, 2014, 11:26:48 AM4/1/14
to antlr-di...@googlegroups.com
On 4/1/14, 1:05 PM, "Sam Harwell" <s...@tunnelvisionlabs.com> wrote:

> Hi Ruslan,
>
> I am not aware of an automated tool capable of producing a translation of the
> ANTLR 4 runtime in another target language without *extensive* modification
> (not even one that's slow). No one currently working on ANTLR believes your
> proposed solution would produce the result you claim, which means we're
> unlikely to spend time trying to make it work. The only way this would happen
> is if someone who believes it could work (like you) actually spends the time
> proving that it really does work, and create a new language target as a
> result.
>
> I'm not trying to discourage you, but this is simply the facts of the
> situation. It could happen, but only if you make it happen.

Ok Sam,

Just two times, for two projects we did this here.

1) We generate stub/proxy sources of Vserver + Vclient,
After parsing of c++ interfaces.

2) We have parse headers of third party big c++ graphic library,
then generate corresponded sources + even wiki docs.


Results are more than cool.
This is why I suggest think about this way :-)


But if you do not see way, then of course no way.

Warren Stringer

unread,
Apr 7, 2014, 8:36:33 PM4/7/14
to antlr-di...@googlegroups.com, mike.l...@googlemail.com
Hi Mike, 

Yep actions in the grammar. 

39M seems like a good size. I somehow generated a parser that big and wound up crashing Xcode while debugging. Compiling is fast, generating watch symbols is slow. Managed to pare it down to 9MB. 

Warren Stringer

unread,
Apr 7, 2014, 8:52:45 PM4/7/14
to antlr-di...@googlegroups.com
Am going with the Antlr 3 +  C runtime for our next release. Still struggling a bit with greedy lexers.  

Heh, yeah, was thinking of redoing my parser generator, but then I'd have to write a book to document it. After that I'd want to rewrite it (again). 

That being said, am looking forward to playing with the C++ runtime for a gestural flow language. 

w

miku...@math.tu-berlin.de

unread,
Apr 22, 2014, 7:52:54 PM4/22/14
to antlr-di...@googlegroups.com
Hello guys,

so no one would put effort into an automated tool to translate ANTLR4 runtimes...

but did I get it right that people are really working on a ANTLR4 C++ target like Gokulakannan's C++ target for ANTLR3?

Moreover, is there any ANTLR3 Uber JAR  antlr-3.4-with-cpp.jar still available? I have only found dozens of dead links after desperately translating my ANTLR4 JAVA project to ANTLR3 C++ and trying to compile it.

Thank you for clarification!

Patryk

Chris McMaiersen

unread,
Apr 23, 2014, 4:59:45 AM4/23/14
to antlr-di...@googlegroups.com
Hi Patryk,


Am Mittwoch, 23. April 2014 01:52:54 UTC+2 schrieb miku...@math.tu-berlin.de:
but did I get it right that people are really working on a ANTLR4 C++ target like Gokulakannan's C++ target for ANTLR3?
I had the same question a couple of months ago, AFAIR I was told that it's not high priority (compared to other language targets). 

Moreover, is there any ANTLR3 Uber JAR  antlr-3.4-with-cpp.jar still available? I have only found dozens of dead links after desperately translating my ANTLR4 JAVA project to ANTLR3 C++ and trying to compile it.
I have the binary still on my machine, I can mail it to you if that helps. But be warned, AFAIR the C++ target doesn't support AST generation, which was one of the reasons I had to stick to the C interface of ANTLR3.
 
Thank you for clarification!

Patryk
 Chris

Patryk Mikulski

unread,
Apr 25, 2014, 10:59:45 AM4/25/14
to antlr-di...@googlegroups.com
Hi Chris,

thank you for your response to my questions!

I really appreciate your offer to send me the file :) Please, feel free to contact me at the email provided here.

However, admittedly I also have problems compiling the C target. There are multiple ways to link the header files shown on several problem solving websites and none of them works for me. Do you have a simple but complete example of the C target in a C++ application?

I started using ANTLR4 studying the reference book and found the listener and visitor methods very useful. Sadly, I have to switch to C++ and therefore to ANTLR3.

Sorry for running off the topic.

So I am cheering for an ANTLR4 C++ target :) Maybe donations could compensate the effort?

Chris McMaiersen

unread,
Apr 27, 2014, 10:15:15 AM4/27/14
to antlr-di...@googlegroups.com
Hi Patryk,


Am Freitag, 25. April 2014 16:59:45 UTC+2 schrieb Patryk Mikulski:
thank you for your response to my questions!
You're welcome!
 
I really appreciate your offer to send me the file :) Please, feel free to contact me at the email provided here.
Ok, I'll send you the file.
 
However, admittedly I also have problems compiling the C target. There are multiple ways to link the header files shown on several problem solving websites and none of them works for me. Do you have a simple but complete example of the C target in a C++ application?
I do have some fairly simple testcode because I needed to evaluate if I can use the C binding for the implementation part of my master's thesis, I'll also mail it to you or post it online somewhere... 
 
I started using ANTLR4 studying the reference book and found the listener and visitor methods very useful. Sadly, I have to switch to C++ and therefore to ANTLR3.
I agree, I really like the listener approach in ANTLR4!

So I am cheering for an ANTLR4 C++ target :) Maybe donations could compensate the effort?
+1

Ben Haller

unread,
Mar 29, 2015, 10:48:42 AM3/29/15
to antlr-di...@googlegroups.com
Hmm, and another year has gone by.  :-<  I realize that "are we there yet? are we there yet?" gets annoying, but since it has been a year, perhaps it is fair to ask how things are going.  Is progress being made, but slowly?  Or is the C++ target dead in the water at this point?  I thought I was going to be able to use the C++ target in antlr3, but it turns out that that target is incomplete and can't generate an AST, so I'm back to square one and would really like to see C++ gen from antlr4.

I am very new to antlr, and to parsing in general, but if there are still people working on this C++ generation problem, I would be willing to help.  I am assuming the work involves only C++ programming; I don't know Java, although I can fake it to a limited extent.  If there's somebody out there who wants some volunteer time from me (say, 10 hours/week on average) and can guide me through my initial cluelessness a bit, let me know.  I would be happy to put in some work to make this happen.

In any case, it would be helpful to know whether C++ support is, at this point, just around the corner or stalled or what.  If it is totally stalled, then I need to figure out a new plan for the parsing problem I'm trying to solve...

Cheers,
-B.

Dan McLaughlin

unread,
Mar 29, 2015, 8:49:54 PM3/29/15
to antlr-di...@googlegroups.com
If you read the updates on this group you would know where we are. Or, instead of complaining, you could contribute to the effort (smily face)

Ben Haller

unread,
Mar 29, 2015, 11:12:38 PM3/29/15
to antlr-di...@googlegroups.com
  Hi Dan.  Hmm, well, I read everything above, and the most recent post was from 4/27/2014, so I'm not sure how I'm supposed to know what has happened in the past year.  If there are other updates on other threads that I should have read, they did not come up in the search I did for topics; sorry about that!

  As for "instead of complaining, you could contribute to the effort", I would note two things: (1) I don't think I was complaining, just asking, and (2) if you read my post, I did in fact offer to contribute to the effort.

Cheers,
-B.

Jim Idle

unread,
Mar 30, 2015, 2:51:54 AM3/30/15
to antlr-di...@googlegroups.com
The C target in v3 works fine and is easy to integrate with c++




Ben Haller

unread,
Mar 30, 2015, 9:41:12 AM3/30/15
to antlr-di...@googlegroups.com
Thanks Jim.  There has been a bit of discussion about that possibility on another thread too: https://groups.google.com/forum/#!topic/antlr-discussion/mwasUcMsnZc.  I'll be looking into it!  :->

Cheers,
-B.

Levon Petrosian

unread,
Apr 1, 2015, 12:36:53 PM4/1/15
to antlr-di...@googlegroups.com
I would like to see what Terence thinks about this. If this is planned or lets see what happened. Could plan to have this at some point and when?

-Levon

Terence Parr

unread,
Apr 1, 2015, 12:50:05 PM4/1/15
to antlr-di...@googlegroups.com
Well, Dan has been working on the C++ target for over a year now so that is either good news or bad news depending on how you look at it. Could mean that it’s incredibly hard and it could mean that Dan is too busy with his day job. I suspect that a combination of being really hard and not having enough resources.

Others are free to start their own C++ target or help Dan.

Or, you can use version 3 and use the C target.

Ter

Levon Petrosian

unread,
Apr 1, 2015, 1:41:18 PM4/1/15
to antlr-di...@googlegroups.com
OK. So the C++ is not a prinicipal target for v4. Thanks for confirming.

-Levon

Dan McLaughlin

unread,
Apr 1, 2015, 1:58:20 PM4/1/15
to antlr-di...@googlegroups.com
Don't know what "principle target" is supposed to mean. Terence and Sam have been wonderfully supportive so far and it was initially funded by Terence, but it's not compiling yet. Certainly we all want a mainline C++ target. 

To followup to Ter's comment, the port isn't incredibly difficult in an intellectual sense, but it's tedious and there's an enormous number of bugs to get through. This is due to the machine translation, and is backwards from the way we all normally work. Unfortunately it's more difficult for us because of the huge time it takes to clean up all these errors. The number of bugs in the first compile was boggling, the compilers couldn't even handle it. So yes it's taken many man months so far with little reward for the work, including dedicated multi week vacations spent on the project. Additionally I've spent time managing new developers who ended up contributing nothing. Working on this project has been educational, I have a lot more respect for open source developers. I'll never, ever in the future ever complain about anything to an open source developer personally. Lesson learned. 

Anyhow good news is that VS2013 reports maybe 20-25 files left to do, but we're a little burnt out at the moment, and yes we do have regular jobs. I do have a vacation coming up and will devote time to the port. Presently, fresh blood at this point would make a huge difference and would get us over the hump. 

Dan

Levon Petrosian

unread,
Apr 1, 2015, 10:31:35 PM4/1/15
to antlr-di...@googlegroups.com
Dan,

I am a C++ guy and used antlr since version 2.6. Have several compilers/assemblers written with it and love it. But at that time C output was generated from the beginning. What I wanted to know is what should I be planning. Wait for C++ output for this version for the new tool or use version 3. 

Personally I would prefer to have C++ as the main target for performance. 

I wish I could help but do not want to promise knowing I will not be able to help much. So do not want to take your time. And my hat is off to Terence for the tool. There is no question here. As I said I used it for many many years and love it.  

-Levon 
Reply all
Reply to author
Forward
0 new messages