db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Dudziak <to...@first.gmd.de>
Subject Re: Need Help with JDOQL Compiler/Interpreter
Date Mon, 03 May 2004 20:17:42 GMT
On Mon, 3 May 2004, Jakob Braeuchi wrote:

> hi thomas,
> looks like you are the antl guru i'm looking for.
> this is the post i made last october:
> hi all,
> while playing with oql i realized that we do not support functions !
>          OQLQuery query = odmg.newOQLQuery();
>          query.create("select anArticle from " +
>                  Article.class.getName() +
>                  " where upper(articleName) like \"A%\" ");
> the upper-function in the where clause causes antlr errors:
> line 1: unexpected token: upper
> line 1: unexpected token: )
> i tried to fix it by adding ( and ) to the valid characters for Identifier. but 
> breaks in and is_defined.
> after some hours of digging in oql-ojb.g i have to admit that i'm stuck.
> so please antlr-gurus have a look at it.

The problem here is that the OQL grammar used by OJB is quite old and
also does not support arbitrary functions (upper is not even in the
current grammar from the ODMG website though).
Well, the short answer is that I could fix it (in this particular case you
would probably add 'upper' to the identifier list in conversionExpr) but
it would be specific for upper because the functions that are supported in
OQL are hardcoded within the grammar. This is of course bad ;-) A better
solution would be to have the grammer unaware of the supported
functions: it only spits out the identifier and the type (unary,
binary). The function lookup is done in a 2nd pass (e.g. an AST walker
that generates the query).
BTW, A couple of weeks ago I had a conversation with Phil Warrick on the
dev list about adding support of the newest OQL grammar (including several
other functions).

I can have a look at it when the JDOQL grammar is done (they'll be similar
in structure) but it probably means a major restructuring of the OQL 
parser (single pass -> two passes).


To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message