Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Text based query parsing

Reply
Thread Tools

Text based query parsing

 
 
puzzlecracker
Guest
Posts: n/a
 
      01-09-2006
Hi group,

I am implementing a fairly simple and straightforward text-search (I
display each line that contains required pattern ) that supports
Boolean queries in the following format:

str1 AND str2 NOT str3 - where not is a unary operation thus the
following would be equivalent to str1 AND str ANDNOT str3 by default
unless a user specifies otherwise....


Additionally, It is left-associative;

I would also like to have parenthesis as well: (str1 AND (str2 OR
str3))


That is it....


Should I write a parser for that followed by walking the AST (abstract
syntax tree) - javacc or antlar? - or would java regular expressions
suffice? it should be fast, whereas java regex is known to be slow....


Any suggestions, examples, references would be highly appreciated.

Thx

 
Reply With Quote
 
 
 
 
Stefan Schulz
Guest
Posts: n/a
 
      01-09-2006
As soon as you have parenthesis, you will need a context free parser.
Regular expressions can not even check if the expression has
well-formed brackets (see pumping lemma)

 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      01-10-2006

"puzzlecracker" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi group,
>
> I am implementing a fairly simple and straightforward text-search (I
> display each line that contains required pattern ) that supports
> Boolean queries in the following format:
>

[...]
>
> I would also like to have parenthesis as well: (str1 AND (str2 OR
> str3))
>

[...]
>
> Should I write a parser for that followed by walking the AST (abstract
> syntax tree) - javacc or antlar? - or would java regular expressions
> suffice? it should be fast, whereas java regex is known to be slow....
>
> Any suggestions, examples, references would be highly appreciated.


Schulz is correct in saying regular expressions are not sufficiently
powerful. As for references, I recommend you post on comp.compilers to get
your design worked out if need be, and then comp.compilers.tools.javacc for
specific help on implementing your parser.

- Oliver


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SAX parsing problem, when element contains text like "[text]" Kai Schlamp Java 1 03-27-2008 08:36 PM
file system -based website vs query string based website Boris Twila ASP .Net 0 11-14-2006 07:50 PM
Assistance parsing text file using Text::CSV_XS Domenico Discepola Perl Misc 6 09-02-2004 03:55 PM
Anyone know of a small tag-based parser for parsing a text string in javascript? Mike Javascript 1 08-21-2004 09:55 AM
Question: Writing text file based TestBenches vs. Waveform file based simulation. BLF VHDL 4 08-07-2004 12:44 AM



Advertisments