[antlr-interest] C++ code generation

Ric Klaren klaren at cs.utwente.nl
Mon Apr 28 04:17:34 PDT 2003


Hi,

On Mon, Apr 28, 2003 at 04:04:03PM +0530, vivek bhaskar wrote:
> I am working on antlr 2.7.1, to generate C++ code. Actually i had started 
> with antlr 2.7.2, but even after repeated try, i was not able to produce 
> static lib for c++ given in antlr/lib/cpp, due to one consistent error in 
> code and thus shifted to 2.7.1.

2.7.1 is buggy YMMV. Check the archives for fixes for MSVC that were posted
after 2.7.2 release. When I get some time I plan to release or a devel
snapshot or see if we can get a official release with fixes for MSVC and
other stuff that popped up after 2.7.2 release.

> Here, i tried to generate C++ code, in which i call a function say,
> void  myfunction(string &mystruing)
> and use a global variable
> string myvar;
> 
> so i put both in header as
> header{
> #include ...
> 
> void  myfunction(string &mystruing);
> string myvar;
> }

The header section is not really the place to place a declaration like
that. Check out the docs:

http://www.antlr.org/doc/cpp-runtime.html#_template

Also could be that you omitted a std:: prefix somewhere, depending on your
compiler and it's settings. Also try looking at the generated code and see
if things are in the places where you expect them.

> so, my question is this:
> Is any body working on antlr, taking care of C++ features, as the current 
> versions, support antlr only for namesake?

I take care of C++ stuff mostly. Yet off late I'm having trouble finding
time. Development platform is the Gnu C++ compiler. Compilers I test on
before release are various gcc's and one or two Sun CC version, I don't
have access to more. MSVC I usually receive post mortem fixes for (after
release)

> Lastly:
> when in java parser i did,
> 
> left: r=right { use r}..it worked.
> 
> But when i tried same in parser, to generate C++, it gave error and
> thus i had only choice, to use tree parser. Can anbody illustrate this 
> problem?

If you illustrate what your problem exactly is I might be able to help. It
is really no help to post the working java code and not the non working C++
code. Rest assured that I use this stuff daily and it works.

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
  "I think we better split up."
  "Good idea. We can do more damage that way."
  --- Ghostbusters

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list