[antlr-interest] ANTLR 2.7 problem with asm statements in C/C++

Wigg, J D wiggjd at lsbu.ac.uk
Wed Jun 20 06:13:16 PDT 2007


Thanks Ralph Goergen for suggesting I might be able to incorporate my
asm processing as part of my ID production in the lexer (in order to
implement the total extraction of asm statements in the lexer as
though they were comments) in order to be able to suppress the
nondeterminism warning in the lexer.
 
I tried what you suggested but kept getting dumps when trying to run
the parser. To cut a long, tedious and boring story short ANTLR
accepted the following (AND doesn't give me a nondeterminism warning)
but the parser runs (incorrectly, of course),
 
ID
 options {testLiterals = true;}
 :
  ("asm"|"_asm"|"__asm")=>
  ("asm"|"_asm"|"__asm")
 |
  ('a'..'z'|'A'..'Z'|'_')
  ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
 ;

So far so good, but although ANTLR accepts the following (adding
either LPAREN or '('  ), the parser dumps and does no processing
whatsoever.
 
ID
 options {testLiterals = true;}
 :
  ("asm"|"_asm"|"__asm")=>
  ("asm"|"_asm"|"__asm") LPAREN // or '('
 |
  ('a'..'z'|'A'..'Z'|'_')
  ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
 ;

I sometimes wish ANTLR could be more consistent in its behaviour. It's
a great system but lets itself down imho by not always performing in a
consistent, understandable and intuitive fashion. You have to be an
expert. Just look at the number of questions we get on the
antlr-interest list.
 
What surprises me is that although I have aired this problem here
three times before and some kind people have responded on (and off)
the list with ideas and suggestions, no ANTLR guru has been able to
give a categorical reply, do this or that, or even the proverbial
RTFM, to such a simple basic problem. 
 
To be honest, this particular problem is not too bad. I can get it to
work properly but I still cannot suppress the nondeterminism warning
in the lexer. But these dumps are the last straw.
 
For your further information I am generating the parser in C++.
 
Previous messages have appeared in Vol 31, Issues 47, 51, and 76.
 
Thanks,
 
David Wigg



--
Copyright in this email and in any attachments belongs to London South Bank University.  This email, and its attachments if any, may be confidential or legally privileged and is intended to be seen only by the person to whom it is addressed.  If you are not the intended recipient, please note the following: (1) You should take immediate action to notify the sender and delete the original email and all copies from your computer systems; (2) You should not read copy or use the contents of the email nor disclose it or its existence to anyone else.

The views expressed herein are those of the author(s) and should not be taken as those of London South Bank University, unless this is specifically stated.

London South Bank University is a company limited by guarantee registered in England and Wales.  The following details apply to London South Bank University: Company number - 00986761; Registered office and trading address - 103 Borough Road London SE1 0AA; VAT number - 778 1116 17; Email address - lsbuinfo at lsbu.ac.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070620/52b091c8/attachment.html 


More information about the antlr-interest mailing list