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

Wigg, J D wiggjd at lsbu.ac.uk
Tue Jun 19 07:07:06 PDT 2007


Thanks Michael J for responding yet again to my problem of processing
asm statements in C/C++.
 
I tried finding the examples you mentioned in CSharpLexer.g but either
I didn't find the correct file or if I did find it I couldn't find
anything similar to my situation of trying to exclude asm statements
(in the lexer as if they were comments) without ending up with a
nondetermism warning (with ID).
 
Although I can get my definitions to work in the lexer (by placing
productions in the right order) it doesn't seem possible to suppress
any unwanted (unnecessary) nondetermism warning in the lexer.
 
I have already tried to deal with asm statements in the parser, but
whatever I do I come against some nondeterminism or other so I have
reluctantly come to the conclusion that it cannot be done cleanly if
at all in ANTLR. 
 
I think the main reason is that as I am not able to parse the asm
statements themselves I have to be able to accept any characters
either to the first RPAREN or to the first RCURLY (allowing Newlines
and hoping that asm statements don't contain parenthese or curly
brackets!).
 
Individual compilers have their own syntax. It seems to me that I
would have to be able to deal with any definition something like
these,
 
asm-definition
     asm ( string-literal ) ;               // C++ standard
     asm { any characters - including newlines }    // MSVC 6.0
     asm ( any characters - including newlines )    // Other compilers
     asm any characters up to newline                 // MSVC 6.0
 
Thanks. Is Version 3 any better in this respect?
 
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/20070619/c5f3e22d/attachment.html 


More information about the antlr-interest mailing list