commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guy Dumais" <guy.dum...@radialpoint.com>
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.

Thanks,
Guy.


-----Original Message-----
From: henrib [mailto:henrib@apache.org] 
Sent: 29 septembre 2011 12:57
To: user@commons.apache.org
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),
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,
Cheers
Henrib

--
View this message in context:
http://apache-commons.680414.n4.nabble.com/jexl-limiting-the-expressions
-accepted-by-JEXL-tp3856155p3856673.html
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


***********************************************************************

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
Radialpoint.

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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message