[antlr-interest] ANTLR Parsing Negation

colin gray cgswtsu78 at gmail.com
Fri Jan 20 10:42:07 PST 2012


Hello,

I'm using ANTLR 3.4 and I have the below rule in my .g file.  I want to
match text that has *select* or *SELECT* but excludes *select count(*)* and
*SELECT COUNT(*)*.  So if the text was select count(*) from tablename where
x=2 it would not create a new SelectQueryInfo.  I want to create a
different object if count(*) exists in the text.  Any ideas?

    selectQuery returns [Info q]
        : ('select' | 'SELECT') columns
          ('from' | 'FROM') table
          (('where' | 'WHERE') filter_clause)?
          { $q = new SelectQueryInfo($columns.a, $table.e,
$filter_clause.e); }


Thanks,

CG


More information about the antlr-interest mailing list