[antlr-interest] Re: syntax predicates

Hensley, Richard richard.hensley at mckesson.com
Thu Sep 12 16:53:46 PDT 2002


Thanks for the response, now I know I'm not going nuts. I'm using the
suggestion that you gave in an earlier e-mail for how to pick the blocks
I wanted out of a crowd, but I needed to detect syntax errors once I was
in my block. I started by using literals, however I found that did not
work because of the bug below. So, I went to an abbreviated rule that I
called identifyView that has the minimum tokens in it required to
identify the block I want to parse. This seems to be working good
because it meets my two requirements. 1. Skip the stuff I don't care
about 2. Detect syntax errors in the blocks I do care about.

My basic grammar ended up being: 

startRule 
        :       (       "create"! ((identifyView)=> createView)? 
                |       skipTokens! 
                )* EOF 
        ; 
        
identifyView 
        :       (ID)* "view" 
        ; 
        
createView 
        :       (ID!)* "view"^ ID^ "as" "select" columns "from" objects 
        ; 
        
skipTokens 
        :       ~("create") 
        ; 

Seems to work good. 

Thanks for all your help. 

Richard 


-----Original Message----- 
From: lgcraymer [ mailto:lgc at mail1.jpl.nasa.gov
<mailto:lgc at mail1.jpl.nasa.gov> ] 
Sent: Thursday, September 12, 2002 4:48 PM 
To: antlr-interest at yahoogroups.com 
Subject: [antlr-interest] Re: syntax predicates 


Yeah, there's a synpred bug in 2.7--synpreds only work if they 
reference a single rule or token.  I pointed this out to Ter a few 
months back, so it's probably on the "to be fixed" list. 

--Loring 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20020912/698c98fe/attachment.html


More information about the antlr-interest mailing list