commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guy Dumais" <>
Subject RE: [jexl] limiting the expressions accepted by JEXL
Date Thu, 29 Sep 2011 18:20:16 GMT
Hi Henri,
Thanks for the detailed response.

My syntax is a small subset of the JEXL language.  It contains no
arithmetic and none of the JEXL built-in functions.  In summary, it is a
single statement to be evaluated as a boolean expression with method
calls and possibly array or map literals.  It would look something like:
(f(x) and g("string")) or h(r) //no pun intended :-)

Implementing my own parser to validate the expression prior to passing
to JEXL seems the best approach.  My syntax is also valid Jython which I
may decide to use at some point so keeping the parser independent of
JEXL seems like the best approach.


-----Original Message-----
From: henrib [] 
Sent: 29 septembre 2011 12:57
Subject: Re: [jexl] limiting the expressions accepted by JEXL

Hi Guy;

About limiting the valid expressions, i'm afraid this is a new usage
(AKAIK)... I so far thought the language to be minimalist. :-)
Would you need to only block operators (comparison / arithmetic),
(map/array) or even more (variable, new) etc?

On actually blocking / rejecting syntactically acceptable expressions,
first route that comes to mind would be to walk the tree (like the
does) after the parse and throw a JexlException on rejection. It means
overriding the JexlEngine (at least the 
JexlEngine.createScript(ASTJexlScript tree, String text) and no, there
is no
better route to validating the AST). This also implies "deep"
which might not be desirable . 

The other way would be to validate the syntax using a dedicated (home
/ javacc) parser and wrap Jexl under your own engine (considering the
as a valid subset of JEXL's).

In both cases, you'll have to maintain some code; if the language you
is very limited and a strict subset of JEXL, my gut feel is it might be
easier to javacc the grammar and front JEXL with it.

As a side note, JEXL expressions can be used as boolean conditions (i.e.
false and null are false, others are true); so you may already use the
language as is and restrict it later to test the water.

Hope this helps,

View this message in context:
Sent from the Commons - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:


This e-mail and attachments are confidential, legally privileged, may be subject to copyright
and sent solely for the attention of the addressee(s). Any unauthorized use or disclosure
is prohibited. Statements and opinions expressed in this e-mail may not represent those of

Le contenu du présent courriel est confidentiel, privilégié et peut être soumis à des droits
d'auteur. Il est envoyé à l'intention exclusive de son ou de ses destinataires. Il est interdit
de l'utiliser ou de le divulguer sans autorisation. Les opinions exprimées dans le présent
courriel peuvent diverger de celles de Radialpoint.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message