| 30 | |
| 31 | This RFC proposes a number of technical changes. The core change, however, involved updating the way logical expressions work. Additional capitalize on this to bring additional capabilities to MapServer. |
| 32 | |
| 33 | '''Core Parser Update''' |
| 34 | |
| 35 | I propose moving to a setup where a logical expression is tokenized once (via our Flex-generated lexer) and then Bison/Yacc parser works through tokens (via a custom version of yylex() defined in mapparser.y) as necessary for each feature. This eliminates the substitution and tokenize steps currently necessary and opens up possibilities for supporting more complex objects in expressions. Basically we'd hang a list/array of tokens off an expressionObj, populate it in msLayerWhichItems() and leverage the tokens as needed in the parser. The following new structs and enums are added to mapserver.h: |
| 36 | |
| 37 | {{{ |
| 38 | enum MS_TOKEN_LOGICAL_ENUM { MS_TOKEN_LOGICAL_AND=100, MS_TOKEN_LOGICAL_OR, MS_TOKEN_LOGICAL_NOT }; |
| 39 | enum MS_TOKEN_LITERAL_ENUM { MS_TOKEN_LITERAL_NUMBER=110, MS_TOKEN_LITERAL_STRING, MS_TOKEN_LITERAL_TIME, MS_TOKEN_LITERAL_SHAPE }; |
| 40 | enum MS_TOKEN_COMPARISON_ENUM { |
| 41 | MS_TOKEN_COMPARISON_EQ=120, MS_TOKEN_COMPARISON_NE, MS_TOKEN_COMPARISON_GT, MS_TOKEN_COMPARISON_LT, MS_TOKEN_COMPARISON_LE, MS_TOKEN_COMPARISON_GE, MS_TOKEN_COMPARISON_IEQ, |
| 42 | MS_TOKEN_COMPARISON_RE, MS_TOKEN_COMPARISON_IRE, |
| 43 | MS_TOKEN_COMPARISON_IN, MS_TOKEN_COMPARISON_LIKE, |
| 44 | MS_TOKEN_COMPARISON_INTERSECTS, MS_TOKEN_COMPARISON_DISJOINT, MS_TOKEN_COMPARISON_TOUCHES, MS_TOKEN_COMPARISON_OVERLAPS, MS_TOKEN_COMPARISON_CROSSES, MS_TOKEN_COMPARISON_WITHIN, MS_TOKEN_COMPARISON_CONTAINS, |
| 45 | MS_TOKEN_COMPARISON_BEYOND, MS_TOKEN_COMPARISON_DWITHIN |
| 46 | }; |
| 47 | enum MS_TOKEN_FUNCTION_ENUM { MS_TOKEN_FUNCTION_LENGTH=140, MS_TOKEN_FUNCTION_TOSTRING, MS_TOKEN_FUNCTION_COMMIFY, MS_TOKEN_FUNCTION_AREA, MS_TOKEN_FUNCTION_ROUND, MS_TOKEN_FUNCTION_FROMTEXT }; |
| 48 | enum MS_TOKEN_BINDING_ENUM { MS_TOKEN_BINDING_DOUBLE=150, MS_TOKEN_BINDING_INTEGER, MS_TOKEN_BINDING_STRING, MS_TOKEN_BINDING_TIME, MS_TOKEN_BINDING_SHAPE }; |
| 49 | |
| 50 | typedef union { |
| 51 | double dblval; |
| 52 | int intval; |
| 53 | char *strval; |
| 54 | struct tm tmval; |
| 55 | shapeObj *shpval; |
| 56 | attributeBindingObj bindval; |
| 57 | } tokenValueObj; |
| 58 | |
| 59 | typedef struct { |
| 60 | int token; |
| 61 | tokenValueObj tokenval; |
| 62 | } tokenObj; |
| 63 | }}} |