[antlr-interest] Quoted Strings in ANTLR 3.0.1 and 3.1.1

Sam Harwell sharwell at pixelminegames.com
Thu Oct 23 11:15:05 PDT 2008


All of your test cases below work correctly in ANTLRworks 1.2 using
ANTLR 3.1 (not 3.1.1). Here is the complete grammar (no synpred on the
'') and input I used for testing.

grammar TestQuotedString;

value
	:	(	QUOTED_STRING
		|	NUMBER
		)*
		EOF
	;

QUOTED_STRING
	:	'\'' ( '\'\'' | ~('\'') )* '\''
	;

NUMBER
	:	('+' | '-')?
		('0'..'9')+
		('.' ('0'..'9')+)?
	;

Input string was:
'''a'0'''a'''0'''a''b'''0'a'''0'a''b'0'a''b''c'0''0''''0''''''0'''a''b'

What target are you using? Is there any way you can test 3.1 to see if
the problematic change occurred between 3.1 and 3.1.1? It limits the
scope. :)

Sam

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Fromm, Stefan
Sent: Thursday, October 23, 2008 12:52 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Quoted Strings in ANTLR 3.0.1 and 3.1.1

Hello Gavin,

EOF at the end of my top-level rule eliminated the error with accepting
''a''. Thank you for that tip. 

> QUOTED_STRING
>    : '\''
>      ( ('\'\'') => '\'\''
>      | ~'\''
>      )*
>      '\''
>    ;

did not work either. But now I'm not able to parse correctly:

'''a'
'''a'''
'''a''b'''

'a'''         
'a''b'
'a''b''c'

with ANTLR 3.1.1. 

''
''''
''''''
'''a''b'

are parsed correctly.

ANTLR 3.0.1 is working now with all test cases. I'll stick to that older
version for now. But still I'm curious what has changed from 3.0 to 3.1
that suddenly it stops working.

Best regards
Stefan


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-addr
ess



More information about the antlr-interest mailing list