[antlr-interest] Question about preserving spaces in quoted strings

Penningroth, Mark mpenningroth at cincom.com
Thu Jul 2 13:14:28 PDT 2009


When I make it a lexer rule I have other issues with my grammar.  

These were working before:

Contents of file: C:\OLAP_TO_RELATIONAL\TestINP\bigcond.txt

SELECT "[Measures].[Unit Sales]" ,
   "[Store].[Store Name]_PROP_[Store Manager]",
   "[Store].[Store Name]_PROP_[Store Type]",
   "[Product].[Product Name]",
   "[Store].[Store Name]"
FROM "Store"
WHERE "[Measures].[Unit Sales]" > 10 AND
  "[Store].[Store Name]_PROP_[Store Type]" = "Supermarket" AND
  "[Store].[Store Name]_PROP_[Store Sqft]" > 30000


 End of file: C:\OLAP_TO_RELATIONAL\TestINP\bigcond.txt
line 1:7 no viable alternative at input '"[Measures].[Unit Sales]"'
line 2:3 no viable alternative at input '"[Store].[Store
Name]_PROP_[Store Manag
er]"'
line 3:3 no viable alternative at input '"[Store].[Store
Name]_PROP_[Store Type]
"'
line 4:3 no viable alternative at input '"[Product].[Product Name]"'
line 5:3 no viable alternative at input '"[Store].[Store Name]"'
line 6:5 no viable alternative at input '"Store"'

That is why I attempted to use a production rule.

I had tried lexer rule first.

I have other rules that may start with a double quote but do not allow
the same characters as DQTEXT.

I am still confused by the resulting tree of my original attempt.

(MDX_FUNC " a g g g g g g gggggggggggggggggggggggggx ")

was printed by ToStringTree(), but when I loop through all the children
hanging off the MDX_FUNC node, I only see 10 children (ie none of the
spaces).  The Children property must be filtering out the hidden
channel.

Thanks,
  For the suggestions


-----Original Message-----
From: Gavin Lambert [mailto:antlr at mirality.co.nz] 
Sent: Thursday, July 02, 2009 3:52 PM
To: Penningroth, Mark; John B. Brodie
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Question about preserving spaces in quoted
strings

At 07:27 3/07/2009, Penningroth, Mark wrote:
 >dqcon
 >	: '"'
 >	(  (~'"')=>
 >	   (   ('\\')=>'\\'.
 >	   | .
 >	   )
 >	)*
 >	'"';

Like you were already told, this should be a lexer rule:

DQTEXT
   : '"' ('\\' . | ~('\\' | '"'))* '"'
   ;



More information about the antlr-interest mailing list