[antlr-interest] Strange behaviour - pls help.

Alvaro Coronel alvarocoronel67 at yahoo.com
Mon Mar 15 05:26:16 PDT 2010


Here's a problem I am having and can't figure out: I am trying to parse a hexadecimal string and zeroes

I build a very small example to highlight what the problem is.

Suppose an elemental log file for your check account. It just has credits and debits. Debits are identified by a prelude of '0001' and credits by '0002' Then comes the amount, up to $ 65535.


We make a modest start with a $100 credit and a $50 debit. So our log is '0001006400020030'

But the input window shows 0001064000103, some zeroes are missing - which of course is not what we want.

If we try with a $ 4369 deposit, the log is 0001111100020030.

Now the input window shows 0001111100010030. The credit is not altered, the debit is still losing zeroes.

My question is ¿Why do the zeroes get this "special treatment"? ¿How can I avoid it or work around it?


I would really appreciate either an explanation or some pointers to learn what is wrong here. I don't mind studying and learning, but need some help because I haven't been able to figure it out or to find an explanation.

Thank you very much in advance, your help will be greatly appreciated
Álvaro.




P.S. I know this particular example can be easily solved using regular expressions. I just built this toy example to show how zeroes disappear from the input. I don't want to escape them with '\' symbols.


      


More information about the antlr-interest mailing list