JS wrote:
Excellent information. That's exactly what I was hoping that I could
consume the input like that.

One more question: What if this binary field happens in the middle of
UTF16 stream?

  
UTF16, or UCS2?

However, you should be able to deal easily with that unless it violates the 16 bit partitions in some way. As in, it is 16 bit characters, but then you can get 3 binary bytes that are not padded to a 16 bit boundary. It would be too late to stop the encoding from screwing it all up by the time you read it from a file. Perhaps you can read it yourself with no encoding. Also, if you tried to read it in with the encoding active and the binary data looked like surrogate pairs and so on, then you might be in a bind.
Actually, I can provide my own input stream to ANTLR, right? So, I
could provide an input stream that can provide either char or bytes,
  
Yes, just inherit from ANTLR's string stream and override the methods of interest, probably LA and consume() at least. Just be careful that you read the input in raw form into a byte array of some sort if coming from a file. Then you LA and consume methods can just track which is the next byte in the array and you can add a consumeByte() method. LA then constructs a character from the next two bytes in the array. Your offsets will need to be in bytes and not characters, so you will need to override the substring type methods on the input stream and so on. But a custom input stream is what you are going to need here.

That's a broken format if it mixes encodings like that, but what can you do ;-).

Jim
    

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
  


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to