We are looking for an open source C++ parser other than g++ if possible. Clang would be great but its C++ support is still some way away and we need something that works or nearly works now. Does anyone have any experience with ANTLR for parsing C++ and for extending their C++ parser? Any other feedback on ANTLR in general would be welcome too. Thanks, --Vikram Associate Professor, Computer Science University of Illinois at Urbana-Champaign http://llvm.org/~vadve P.S. Sorry for the spam. I know this question is not directly LLVM related but it is peripherally related and this list is the best source I could think of for C++ parsing experience. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090711/8c5bb4a8/attachment.html>
Hi, I've not got any experience using ANTLR to parse C++, however, you will find that there only exists a C code generator for ANTLR and NOT a C++ one. Over the years numerous people have requested a C++ code generation template but alas there is still only a C one. Just a heads up. Granville 2009/7/11 Vikram S. Adve <vadve at cs.uiuc.edu>> We are looking for an open source C++ parser other than g++ if possible. > Clang would be great but its C++ support is still some way away and we need > something that works or nearly works now. Does anyone have any experience > with ANTLR for parsing C++ and for extending their C++ parser? Any other > feedback on ANTLR in general would be welcome too. Thanks, > > --Vikram > *Associate Professor, Computer Science* > *University of Illinois at Urbana-Champaign* > *http://llvm.org/~vadve <http://llvm.org/%7Evadve>* > > *P.S. Sorry for the spam. I know this question is not directly LLVM > related but it is peripherally related and this list is the best source I > could think of for C++ parsing experience.* > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090711/77a62b4d/attachment.html>
That sounds like a problem. Just so I understand, do you mean there isn't the run-time support etc. to write back ends for the C++ language, or that the compiler IR is also somehow insufficient to write a code generator? --Vikram Associate Professor, Computer Science University of Illinois at Urbana-Champaign http://llvm.org/~vadve On Jul 11, 2009, at 3:00 PM, Granville Barnett wrote:> Hi, > > I've not got any experience using ANTLR to parse C++, however, you > will find that there only exists a C code generator for ANTLR and > NOT a C++ one. Over the years numerous people have requested a C++ > code generation template but alas there is still only a C one. Just > a heads up. > > Granville > > > 2009/7/11 Vikram S. Adve <vadve at cs.uiuc.edu> > We are looking for an open source C++ parser other than g++ if > possible. Clang would be great but its C++ support is still some > way away and we need something that works or nearly works now. Does > anyone have any experience with ANTLR for parsing C++ and for > extending their C++ parser? Any other feedback on ANTLR in general > would be welcome too. Thanks, > > --Vikram > Associate Professor, Computer Science > University of Illinois at Urbana-Champaign > http://llvm.org/~vadve > > P.S. Sorry for the spam. I know this question is not directly LLVM > related but it is peripherally related and this list is the best > source I could think of for C++ parsing experience. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > <ATT00001.txt>-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090711/9e99004f/attachment.html>
On Jul 11, 2009, at 12:40 PM, Vikram S. Adve wrote:> We are looking for an open source C++ parser other than g++ if > possible. Clang would be great but its C++ support is still some > way away and we need something that works or nearly works now. Does > anyone have any experience with ANTLR for parsing C++ and for > extending their C++ parser? Any other feedback on ANTLR in general > would be welcome too. Thanks,You need a lot more than a traditional parser to parse c++, you have to do full template instantiation, partial template specialization etc just to be able to correctly parse it. The "best answer" if you need something ASAP is to use Elsa. -Chris
Chris, I'm not sure how good this is, but there does exist a C++ grammar for ANTLR that is pretty actively maintained by Sun Microsystems - http://hg.netbeans.org/main/file/tip/cnd.modelimpl/src/org/netbeans/modules/cnd/modelimpl/parser/cppparser.g Granville 2009/7/11 Chris Lattner <clattner at apple.com>> > On Jul 11, 2009, at 12:40 PM, Vikram S. Adve wrote: > > > We are looking for an open source C++ parser other than g++ if > > possible. Clang would be great but its C++ support is still some > > way away and we need something that works or nearly works now. Does > > anyone have any experience with ANTLR for parsing C++ and for > > extending their C++ parser? Any other feedback on ANTLR in general > > would be welcome too. Thanks, > > You need a lot more than a traditional parser to parse c++, you have > to do full template instantiation, partial template specialization etc > just to be able to correctly parse it. The "best answer" if you need > something ASAP is to use Elsa. > > -Chris > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090711/77562be7/attachment.html>
Right, I understand that. I was hoping there was such an implementation using ANTLR since it looks like a fairly mature project. I'm not sure how stable or mature Elsa is (but comments to clarify that would be appreciated.). E.g., a quick scan of their Web page shows the comment that they only have a partial type checker. It also says their template instantiation is incomplete. --Vikram Associate Professor, Computer Science University of Illinois at Urbana-Champaign http://llvm.org/~vadve On Jul 11, 2009, at 3:23 PM, Chris Lattner wrote:> > On Jul 11, 2009, at 12:40 PM, Vikram S. Adve wrote: > >> We are looking for an open source C++ parser other than g++ if >> possible. Clang would be great but its C++ support is still some >> way away and we need something that works or nearly works now. Does >> anyone have any experience with ANTLR for parsing C++ and for >> extending their C++ parser? Any other feedback on ANTLR in general >> would be welcome too. Thanks, > > You need a lot more than a traditional parser to parse c++, you have > to do full template instantiation, partial template specialization etc > just to be able to correctly parse it. The "best answer" if you need > something ASAP is to use Elsa. > > -Chris > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090711/1d81c660/attachment.html>
For a LL(1) parser, it might be a little bit difficult to parse complex grammar like C++, but it might work. ANTLR worked great when other codes were written in Java, but it was a little bit painful when using other languages like python. I worked on it two years ago. I guess they might have some improvement now. Haohui On 07/11/2009 02:40 PM, Vikram S. Adve wrote:> We are looking for an open source C++ parser other than g++ if > possible. Clang would be great but its C++ support is still some way > away and we need something that works or nearly works now. Does > anyone have any experience with ANTLR for parsing C++ and for > extending their C++ parser? Any other feedback on ANTLR in general > would be welcome too. Thanks, > > --Vikram > /Associate Professor, Computer Science/ > /University of Illinois at Urbana-Champaign/ > /http://llvm.org/~vadve <http://llvm.org/%7Evadve>/ > > /P.S. Sorry for the spam. I know this question is not directly LLVM > related but it is peripherally related and this list is the best > source I could think of for C++ parsing experience./ > ------------------------------------------------------------------------ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090711/142828b4/attachment.html>
> > For a LL(1) parser, it might be a little bit difficult to parse complex > grammar like C++, but it might work. >ANTLR is an LL(*) parser, i.e. it will resolve parsing ambiguities by looking ahead as many tokens required in order to choose the correct alternative. Of course, you can fix the lookahead for ANTLR within the preamble of the grammar. As I mentioned earlier I think the C++ grammar I linked to is *pretty* good, but then Vikram wants something more end-to-end based on his response to my comment. Granville 2009/7/11 Mai, Haohui <haohui.mai at gmail.com>> For a LL(1) parser, it might be a little bit difficult to parse complex > grammar like C++, but it might work. > > ANTLR worked great when other codes were written in Java, but it was a > little bit painful when using other languages like python. > > I worked on it two years ago. I guess they might have some improvement now. > > Haohui > > > On 07/11/2009 02:40 PM, Vikram S. Adve wrote: > > We are looking for an open source C++ parser other than g++ if possible. > Clang would be great but its C++ support is still some way away and we need > something that works or nearly works now. Does anyone have any experience > with ANTLR for parsing C++ and for extending their C++ parser? Any other > feedback on ANTLR in general would be welcome too. Thanks, > > --Vikram > *Associate Professor, Computer Science* > *University of Illinois at Urbana-Champaign* > *http://llvm.org/~vadve <http://llvm.org/%7Evadve>* > > *P.S. Sorry for the spam. I know this question is not directly LLVM > related but it is peripherally related and this list is the best source I > could think of for C++ parsing experience.* > > ------------------------------ > > _______________________________________________ > LLVM Developers mailing listLLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090712/282d80ec/attachment.html>
Granville Barnett wrote:> Hi, > > I've not got any experience using ANTLR to parse C++, however, you will > find that there only exists a C code generator for ANTLR and NOT a C++ > one. Over the years numerous people have requested a C++ code generation > template but alas there is still only a C one. Just a heads up.ANTLR v3 yes, but ANTLR 2.7.7 supports C++ code generation directly. You just don't get all the nifty features and support tools that are written for v3.> Granville-- Kevin J. Cummings kjchome at rcn.com cummings at kjchome.homeip.net cummings at kjc386.framingham.ma.us Registered Linux User #1232 (http://counter.li.org)
I've done extensive research on the subject and if you want to parse ALL of C++, there are only two options, g++ or the Edison Design Group C++ front-end. Both of these have projects designed to make this easier LLVM (as you know) and Rose (http://www.rosecompiler.org/), which works with the EDG compiler. AspectC++, OpenC++, Antler, TLX, all work with only a portion of the grammer. On Sat, Jul 11, 2009 at 10:40 PM, Vikram S. Adve <vadve at cs.uiuc.edu> wrote:> We are looking for an open source C++ parser other than g++ if possible. > Clang would be great but its C++ support is still some way away and we need > something that works or nearly works now. Does anyone have any experience > with ANTLR for parsing C++ and for extending their C++ parser? Any other > feedback on ANTLR in general would be welcome too. Thanks, > > --Vikram > *Associate Professor, Computer Science* > *University of Illinois at Urbana-Champaign* > *http://llvm.org/~vadve <http://llvm.org/%7Evadve>* > > *P.S. Sorry for the spam. I know this question is not directly LLVM > related but it is peripherally related and this list is the best source I > could think of for C++ parsing experience.* > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090712/9d4ef4bc/attachment.html>
Thanks to everyone who has responded to my questions about a C++ parser. My original impression matched what David wrote below, which is that only g++ and EDG have complete, standards-compliant C++ front ends. Unfortunately, both licenses are less than ideal from our POV. Also, we need both a front-end and a code generator. On the other hand, we don't need full compliance *today* -- something that is close 3 months from today and nearly fully compliant in 6-9 months would work for us -- so we are going to take a closer look at the plans for clang. --Vikram Associate Professor, Computer Science University of Illinois at Urbana-Champaign http://llvm.org/~vadve On Jul 12, 2009, at 2:09 AM, David Minor wrote:> I've done extensive research on the subject and if you want to parse > ALL of C++, there are only two options, g++ or the Edison Design > Group C++ front-end. Both of these have projects designed to make > this easier LLVM (as you know) and Rose (http:// > www.rosecompiler.org/), which works with the EDG compiler. AspectC+ > +, OpenC++, Antler, TLX, all work with only a portion of the grammer. > > On Sat, Jul 11, 2009 at 10:40 PM, Vikram S. Adve <vadve at cs.uiuc.edu> > wrote: > We are looking for an open source C++ parser other than g++ if > possible. Clang would be great but its C++ support is still some > way away and we need something that works or nearly works now. Does > anyone have any experience with ANTLR for parsing C++ and for > extending their C++ parser? Any other feedback on ANTLR in general > would be welcome too. Thanks, > > --Vikram > Associate Professor, Computer Science > University of Illinois at Urbana-Champaign > http://llvm.org/~vadve > > P.S. Sorry for the spam. I know this question is not directly LLVM > related but it is peripherally related and this list is the best > source I could think of for C++ parsing experience. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > <ATT00001.txt>