Changes between Version 1 and Version 2 of RFC59-Draft


Ignore:
Timestamp:
Aug 6, 2010, 8:36:56 AM (14 years ago)
Author:
sdlime
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RFC59-Draft

    v1 v2  
    66This is a draft RFC addressing 1) how the Bison/Yacc parser for logical expressions is implemented and 2) where in the MapServer code the parser can be used. This RFC could have broader impacts on query processing depending on additional changes at the driver level, specifically the RDBMS ones. Those changes don't have to occur for this to be a useful addition.
    77
     8A principle motivation for this work is to support OGC filter expressions in a single pass in a driver-independent manner.
     9
    810== Existing Expression Parsing ==
    911
    10 The existing logical expression handling in MapServer
     12The existing logical expression handling in MapServer works like so:
    1113
     14  1) duplicate expression string[[BR]]
     15  2) substitute shape attributes into string (e.g. '[name]' => 'Anoka')[[BR]]
     16  3) parse with yyparse()
     17
     18The parser internally calls yylex() for its tokens. Tokens are the smallest pieces of an expression.
     19
     20'''Advantages'''
     21
     22  - it's simple and it works
     23
     24'''Disadvantages'''
     25
     26  - limited by substitution to strings, no complex types can be handled
     27  - have to perform the substitution and tokenize the resulting string for every feature
    1228
    1329== Proposed Technical Changes ==
     30
     31This 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
     35I 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{{{
     38enum MS_TOKEN_LOGICAL_ENUM { MS_TOKEN_LOGICAL_AND=100, MS_TOKEN_LOGICAL_OR, MS_TOKEN_LOGICAL_NOT };
     39enum MS_TOKEN_LITERAL_ENUM { MS_TOKEN_LITERAL_NUMBER=110, MS_TOKEN_LITERAL_STRING, MS_TOKEN_LITERAL_TIME, MS_TOKEN_LITERAL_SHAPE };
     40enum 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};
     47enum 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 };
     48enum 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
     50typedef union {
     51  double dblval;
     52  int intval;
     53  char *strval;
     54  struct tm tmval;
     55  shapeObj *shpval;
     56  attributeBindingObj bindval;
     57} tokenValueObj;
     58
     59typedef struct {
     60  int token;
     61  tokenValueObj tokenval;
     62} tokenObj;
     63}}}
    1464
    1565