0

the Antlr site is not clear on the subject of compiling a grammar for C++, it says that the tool will generate C code compatible with C++, what dose it mean? will I be able to compile this code with VS 2008 ?

Eli
  • 6,353
  • 9
  • 30
  • 25

4 Answers4

1

VS 2008 has both C and C++ compiler (and C++ compiler can compile C code, this is what they meant), I don't think you'll have any problems.

They say: "C target as of release 3.1 is C++ compatible, compile .c files as C++. C+ classes will be provided as a separate library later in 2008."

Meaning it's C++ compatible.

Nikola Smiljanić
  • 26,745
  • 6
  • 48
  • 60
1

C is mostly a subset of C++. But the generated C code should not go off the C++ beaten path, so will should be valid C++.

Visual Studio has a C/C++ compiler, as you are compiling the generated parser, you do not need to worry about the C/C++ distinction. Just compile the code as C++.

Community
  • 1
  • 1
Simeon Pilgrim
  • 22,906
  • 3
  • 32
  • 45
1

The phrase "C code compatible with C++" means that the code generation targets the common subset of C and C++. Hence, it does not use the token class which has different meanings in C and C++, etctera. But it can use int and foo, where C and C++ agree.

As a result, the code generated can be compiled by both C and C++ compilers. Visual Studio contains both (via /TC and /TP flags) so you could use either mode.

MSalters
  • 173,980
  • 10
  • 155
  • 350
1

I have uploaded a C++ Target for ANTLR. check out the ANTLR wiki under Runtime Libraries - C++ Target

http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826

Gokul
  • 893
  • 11
  • 27