DescriptionThe expression language used in OpenSocial templating system is a JSP EL-like one. We need a EL evaluator which could do the following items correctly:
1) number / boolean operation
2) function calls
3) string handling
4) ternary conditional workflow
5) data context de-reference
6) nested structures
This patch implemented a clearly support for its evaluating.
Basically, it contains 3 parts:
1) ExpType, it defines types like int / float / string / bool / array / object etc. and handles the type coercing as well.
2) ExpLexer, which tokenizes the input expression string into intermediate tokens which will be handled in the later stage.
3) ExpParser, which evaluates the input token stream under a given data context.
Excepts the functionalities like operation computing, function calls etc, the capability of input expression validation is also provided. Unit-tests are included, too.
Some highlights of this parser:
1) handles tricky string in the right way, e.g. 'this is \\\'"the tricky string"\''
2) scientific floating parsing, e.g. .5e-3
3) nested unary operator, e.g. 5+---0.2e-3+1
4) nested ternary, e.g. a?b:c?d:e / a?(b?c:d):e
5) scoped variable: no_prefix, Cur, Top
6) access un-exist attribute should return null (it's different with JSP EL's spec)
7) nested attribute access: a[b].c
Patch Set 1 #Patch Set 2 : updated one #
MessagesTotal messages: 2
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||