[antlr-interest] How to handle blackslashes correctly?

Hiran Chaudhuri Hiran.Chaudhuri at web.de
Wed Jan 19 06:31:37 PST 2011


I will add the lexer part of my grammar. The rest is longish and probably not relevant here (I hope).

======8 8===========================


-----Ursprüngliche Nachricht-----
Von: "Pop Qvarnström"  
Gesendet: Jan 18, 2011 6:14:01 PM
An: "Hiran Chaudhuri"  
Betreff: Re: [antlr-interest] How to handle blackslashes correctly?

>Could you provide your grammar, or relevant parts of it?
>
>Cheers,
>Pop
>
>On Tue, Jan 18, 2011 at 5:10 PM, Hiran Chaudhuri  wrote:
>
>> Hello everybody.
>>
>> I've got input files with different meaning for backslashes. Therefore my
>> lexer does not really know how to generate the tokens and the parser does
>> not what I want it to do. Maybe someone can help me checking this?
>> A backslash before a linefeed means the linefeed is just whitespace,
>> whereas elsewhere it is not.
>> A backslash in some regions of the file is meant to be part of a file path
>> (Windows).
>> A backslash in some regions of the file is part of a regular expression.
>> I'm not interested in parsing that, so it shall be handled like a string
>> value.
>> A backslash before a quote inside a quoted string means the quote does not
>> terminate the string.
>>
>> I've created a grammar that can handle all cases from my point of view. Now
>> let's look at one fragment:
>>
>> BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
>>
>> This should be parsed as
>> Keyword BrowserMatch
>> value   \bMSIE
>> not     !
>> value   no-gzip!gzip-only-text/html
>> not     !
>> value   gzip-only-text/html
>>
>> but it is parsed as
>> Keyword BrowserMatch
>> unknown \b
>> value   MSIE
>> ...
>>
>> My expression for value allows backslash and the necessary letters, still
>> the parser thinks it should not recognize this value.
>> What can be the reason for that?
>>
>> Hiran
>> ___________________________________________________________
>> Empfehlen Sie WEB.DE DSL Ihren Freunden und Bekannten und wir
>> belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.web.de
>>
>> List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> Unsubscribe:
>> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>>
>
>List: http://www.antlr.org/mailman/listinfo/antlr-interest
>Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
___________________________________________________________
WEB.DE DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt mit 
gratis Handy-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2


More information about the antlr-interest mailing list