[antlr-interest] Strange behaviour - pls help.

Alvaro Coronel alvarocoronel67 at yahoo.com
Mon Mar 15 19:01:48 PDT 2010


Hello John.

Don't be sorry about the threading. One just replies and the message goes to the originator, not to the list. Quite odd, considering the expected mechanics of interest lists, but must not be easy to fix since it was requested in 2005 and hasn't changed yet. See http://www.antlr.org/pipermail/antlr-interest/2005-May/012128.html

Thank you very much indeed for your prompt answer. You are right, it was 0002 and it was only $48 dollars. Sorry about that, but as you said it doesn't really matter - just tokens not $$.


The "input window" I referred to shows when you use the debugger tab in ANTLRWorks.

The example you sent me worked as you said. I guess I was having trouble running ANTLRWorks then?

Best regards and thanks again,
Álvaro




________________________________
From: John B. Brodie <jbb at acm.org>
To: antlr-interest <antlr-interest at antlr.org>
Cc: alvarocoronel67 at yahoo.com
Sent: Mon, March 15, 2010 10:04:40 PM
Subject: re: Strange behaviour - pls help.

Greetings!

(very sorry, I have broken the mail list threading. I deleted the
original message and then now decided to reply. Sorry. I could not find
a way to reply from the archive. Sorry)

Original message:

> 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'

__________________________________________________^^^___________________________________^^^^

$48 debit right? anyway, does not really matter i think.

> 
> But the input window shows 0001064000103, some zeroes are missing - which of course is not what we want.
____________________________________^^^^ huh? 0002 right?

I assume by `input window` you mean some interaction dialog from within ANTLRWorks? if so, maybe the
problem is with ANTLRWorks? and not the generated parser/lexer?

> 
> 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.
_____________________________________^^^^ huh? ... and where is the loss of zeroes?

if this is really what you are seeing, I suggest that there is some issue outside of the ANTLR generated parser
and lexer, because the Tool generated code does not display any "input window" dialog.

> 
> 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.
....remainder snipped....

Have you tried running your generated code from the command line? As indicated above I think your problem is
outside of any ANTLR generated parser/lexer.

To prove that, please find attached a grammar that just works when Tool'd, compiled, and executed from the
command line. The linux command line I used is: java org.antlr.Tool Test.g ; javac *.java ; java TestParser

Hope this helps....
   -jbb



      


More information about the antlr-interest mailing list