Skip to main content
Jump to: navigation, search

Equinox/p2/Query Language for p2

< Equinox‎ | p2
Revision as of 10:09, 13 November 2009 by Thomas.tada.se (Talk | contribs) (New page: ===Background=== p2 has a query mechanism today that makes it very hard to create an implementation that is based on a database. It is also very hard to create an efficient client/server s...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Background

p2 has a query mechanism today that makes it very hard to create an implementation that is based on a database. It is also very hard to create an efficient client/server solution. The reason for this is that most of the queries are written as java code in a callback and there is often no good way to extract the semantics of the query.

We discussed this at length on the p2 meeting on November 9. This resulted in the bugzilla Create a QueryLanguage for p2. I've spend some time on this now and today I have a fully functional IQuery implementation.

The BNF

p2query : ('latest' | 'distinct')? orExpression ;

orExpression : andExpression ( '||' andExpression )* ;

andExpression : notExpression ( '&&' notExpression )* ;

notExpression
   : '!' notExpression
   | binaryExpression
   ;

op : '=' | '!=' | '>' | '>=' | '<' | '<=' | '~=' ;

binaryExpression : sideExpression op sideExpression ;

sideExpression : ('any' | 'all')? memberExpression ;

memberExpression : unaryExpression ( ( '.' ID ) | ( '[' memberExpression ']' ) )* ;

unaryExpression
   : '(' orExpression ')'
   | '[' memberExpression ( ',' memberExpression )* ']' // #array construct
   | '/' regexpPattern '/'
   | STRING
   | INT
   | parameter
   | 'self'
   | 'null'
   | 'true'
   | 'false'
   | ID // # implies self.identifier
   ;

   parameter
   : ':' INT
   ;

Back to the top