1

The C runtime distribution of ANTLR 3.2 used to have a function declared as

ANTLR3_API pANTLR3_INPUT_STREAM antlr3NewAsciiStringCopyStream
    (pANTLR3_UINT8 inString, ANTLR3_UINT32 size, pANTLR3_UINT8 name);

in include/antlr3defs.h. There were also a few similar functions, such as antlr3NewAsciiStringInPlaceStream, antlr3NewUCS2StringInPlaceStream and so forth.

But in the 3.4 version these functions seem to have gone. They are neither declared in any of the .h files, nor are definitions compiled into the library.

I checked the release notes for 3.3 and 3.4 and the FAQ, but I couldn't find any mention of this. On the contrary, the FAQ recommends (see [2] below):

How to get a pANTLR3_INPUT_STREAM from a std::string (or char* variable)?
Functions

[1]pANTLR3_INPUT_STREAM
[2]antlr3NewAsciiStringCopyStream
([3]pANTLR3_UINT8 inString, [4]ANTLR3_UINT32 size, [5]pANTLR3_UINT8 name)

Create an ASCII string stream as input to ANTLR 3, copying the input string.

I have legacy code that uses ANTLR 3 and this function, and I can't easily switch to ANTLR 4. I could continue using the 3.2 version or one of the other functions listed above, but it would be good to know what happened, and how to best handle this.

jogojapan
  • 68,383
  • 11
  • 101
  • 131
  • This ANTLR3.4C [example](http://stackoverflow.com/questions/8537214/a-simple-antlr-3-4-example-for-c-target-runtime) with a `const char *` buffer may help –  Jan 30 '13 at 17:54

1 Answers1

2

I came across this problem just recently too. Seemingly, you can use the following function to get the same functionality:

pANTLR3_INPUT_STREAM antlr3StringStreamNew (pANTLR3_UINT8 data, ANTLR3_UINT32 encoding, ANTLR3_UINT32 size, pANTLR3_UINT8 name);

For encoding, you'd use ANTLR3_ENC_8BIT (or otherwise)

Tom.

Tom Spink
  • 46
  • 3
  • I'll take a closer look at this in a few days -- but thanks for now (+1). I might not accept the answer in a while, as I am still hoping for some background explanation, but in any case the function you propose seems to be the correct alternative. – jogojapan Jan 30 '13 at 21:39