commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henrib <>
Subject Re: [jexl] limiting the expressions accepted by JEXL
Date Thu, 29 Sep 2011 16:56:47 GMT
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),  literals
(map/array) or even more (variable, new) etc?

On actually blocking / rejecting syntactically acceptable expressions, the
first route that comes to mind would be to walk the tree (like the Debugger
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" integration
which might not be desirable . 

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

In both cases, you'll have to maintain some code; if the language you seek
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:

View raw message