[mapserver-commits] r10227 - sandbox/sdlime/common-expressions/mapserver

svn at osgeo.org svn at osgeo.org
Mon Jun 14 00:23:54 EDT 2010


Author: sdlime
Date: 2010-06-14 04:23:53 +0000 (Mon, 14 Jun 2010)
New Revision: 10227

Modified:
   sandbox/sdlime/common-expressions/mapserver/Makefile.in
   sandbox/sdlime/common-expressions/mapserver/maplayer.c
   sandbox/sdlime/common-expressions/mapserver/maplexer.c
   sandbox/sdlime/common-expressions/mapserver/maplexer.l
   sandbox/sdlime/common-expressions/mapserver/mapparser.c
   sandbox/sdlime/common-expressions/mapserver/mapparser.h
   sandbox/sdlime/common-expressions/mapserver/mapparser.y
   sandbox/sdlime/common-expressions/mapserver/mapserver.h
   sandbox/sdlime/common-expressions/mapserver/maputil.c
Log:
More change...

Modified: sandbox/sdlime/common-expressions/mapserver/Makefile.in
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/Makefile.in	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/Makefile.in	2010-06-14 04:23:53 UTC (rev 10227)
@@ -325,7 +325,8 @@
 mapparser.o: mapparser.c mapserver.h
 
 mapparser.c: mapparser.y
-	$(YACC) -p mseyy -d -omapparser.c mapparser.y
+	# $(YACC) -p mseyy -d -omapparser.c mapparser.y
+	$(YACC) -d -omapparser.c mapparser.y
 
 lib:    $(LIBMAP_STATIC)
 libmapserver: $(LIBMAP_STATIC)

Modified: sandbox/sdlime/common-expressions/mapserver/maplayer.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maplayer.c	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/maplayer.c	2010-06-14 04:23:53 UTC (rev 10227)
@@ -352,7 +352,7 @@
 
     switch(token) {
     case MS_NUMBER:
-      expression->tokens[n].token = token;
+      expression->tokens[n].token = NUMBER;
       expression->tokens[n].tokenval.dblval = msyynumber;
       break;
     case STRING:
@@ -362,7 +362,7 @@
       expression->tokens[n].token = token;
       expression->tokens[n].tokenval.strval = strdup(msyytext);
       break;
-    case MS_TIME:
+    case TIME:
       expression->tokens[n].token = token;
       msTimeInit(&(expression->tokens[n].tokenval.tmval));
       if(msParseTime(msyytext, &(expression->tokens[n].tokenval.tmval)) != MS_TRUE) {
@@ -373,6 +373,7 @@
     case SHAPE:
       expression->tokens[n].token = token;
       expression->tokens[n].tokenval.shpval = msShapeFromWKT(msyytext);
+      // set scope
       if(!expression->tokens[n].tokenval.shpval) {
         msSetError(MS_PARSEERR, "Parsing time value failed.", "tokenizeExression()");
         goto parse_error;

Modified: sandbox/sdlime/common-expressions/mapserver/maplexer.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maplexer.c	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/maplexer.c	2010-06-14 04:23:53 UTC (rev 10227)
@@ -3336,7 +3336,7 @@
 {
   msyytext++;
   msyytext[strlen(msyytext)-1] = '\0';
-  return(MS_TIME);
+  return(TIME);
 }
 	YY_BREAK
 case 285:

Modified: sandbox/sdlime/common-expressions/mapserver/maplexer.l
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maplexer.l	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/maplexer.l	2010-06-14 04:23:53 UTC (rev 10227)
@@ -456,7 +456,7 @@
 <EXPRESSION_STRING>\`[^\`]*\` {
   msyytext++;
   msyytext[strlen(msyytext)-1] = '\0';
-  return(MS_TIME);
+  return(TIME);
 }
 
 <INITIAL,URL_STRING>\/[^\/]*\/i                {

Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.c	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.c	2010-06-14 04:23:53 UTC (rev 10227)
@@ -45,14 +45,6 @@
 /* Using locations.  */
 #define YYLSP_NEEDED 0
 
-/* Substitute the variable and function names.  */
-#define yyparse mseyyparse
-#define yylex   mseyylex
-#define yyerror mseyyerror
-#define yylval  mseyylval
-#define yychar  mseyychar
-#define yydebug mseyydebug
-#define yynerrs mseyynerrs
 
 
 /* Tokens.  */
@@ -129,12 +121,21 @@
 #include "maptime.h" /* for time comparison routines */
 #include "mapprimitive.h" /* for shapeObj */
 
-extern int msyylex(void); /* lexer globals */
-extern int msyyerror(const char *);
+// extern int msyylex(void); /* lexer globals */
+// extern int msyyerror(const char *);
 
-int msyyresult;
+shapeObj *yyshape;
+layerObj *yylayer;
+expressionObj *yyexpr;
 
+typedef union {
+  int intval;
+  char *strval;
+  shapeObj *shpval;
+} parseResultObj;
+parseResultObj yyresult;
 
+
 /* Enabling traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
@@ -149,7 +150,7 @@
 #endif
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 25 "mapparser.y"
+#line 34 "mapparser.y"
 typedef union YYSTYPE {
   double dblval;
   int intval;  
@@ -158,7 +159,7 @@
   shapeObj *shpval;
 } YYSTYPE;
 /* Line 185 of yacc.c.  */
-#line 162 "mapparser.c"
+#line 163 "mapparser.c"
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 # define YYSTYPE_IS_TRIVIAL 1
@@ -170,7 +171,7 @@
 
 
 /* Line 213 of yacc.c.  */
-#line 174 "mapparser.c"
+#line 175 "mapparser.c"
 
 #if ! defined (yyoverflow) || YYERROR_VERBOSE
 
@@ -369,13 +370,13 @@
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const unsigned short int yyrline[] =
 {
-       0,    63,    63,    64,    65,    73,    76,    84,    93,   101,
-     110,   118,   127,   135,   144,   145,   146,   159,   165,   171,
-     177,   183,   189,   195,   196,   204,   212,   221,   229,   237,
-     245,   251,   257,   263,   269,   275,   281,   302,   323,   329,
-     337,   343,   356,   357,   358,   359,   360,   361,   362,   369,
-     370,   371,   372,   382,   383,   384,   396,   397,   398,   401,
-     402
+       0,    72,    72,    73,    74,    82,    85,    93,   102,   110,
+     119,   127,   136,   144,   153,   154,   155,   168,   174,   180,
+     186,   192,   198,   204,   205,   213,   221,   230,   238,   246,
+     254,   260,   266,   272,   278,   284,   290,   311,   332,   338,
+     346,   352,   365,   366,   367,   368,   369,   370,   371,   378,
+     379,   380,   381,   391,   392,   393,   405,   406,   407,   410,
+     411
 };
 #endif
 
@@ -1201,22 +1202,22 @@
   switch (yyn)
     {
         case 3:
-#line 64 "mapparser.y"
-    { msyyresult = (yyvsp[0].intval); }
+#line 73 "mapparser.y"
+    { yyresult.intval = (yyvsp[0].intval); }
     break;
 
   case 4:
-#line 65 "mapparser.y"
+#line 74 "mapparser.y"
     {
      if((yyvsp[0].dblval) != 0)
-       msyyresult = MS_TRUE;
+       yyresult.intval = MS_TRUE;
      else
-       msyyresult = MS_FALSE;			    
+       yyresult.intval = MS_FALSE;			    
    }
     break;
 
   case 6:
-#line 76 "mapparser.y"
+#line 85 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE)
 		                           (yyval.intval) = MS_TRUE;
@@ -1228,7 +1229,7 @@
     break;
 
   case 7:
-#line 84 "mapparser.y"
+#line 93 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE) {
 			                   if((yyvsp[0].intval) == MS_TRUE)
@@ -1241,7 +1242,7 @@
     break;
 
   case 8:
-#line 93 "mapparser.y"
+#line 102 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE)
 		                           (yyval.intval) = MS_TRUE;
@@ -1253,7 +1254,7 @@
     break;
 
   case 9:
-#line 101 "mapparser.y"
+#line 110 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE) {
 			                   if((yyvsp[0].dblval) != 0)
@@ -1266,7 +1267,7 @@
     break;
 
   case 10:
-#line 110 "mapparser.y"
+#line 119 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0)
 		                           (yyval.intval) = MS_TRUE;
@@ -1278,7 +1279,7 @@
     break;
 
   case 11:
-#line 118 "mapparser.y"
+#line 127 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0) {
 			                   if((yyvsp[0].intval) == MS_TRUE)
@@ -1291,7 +1292,7 @@
     break;
 
   case 12:
-#line 127 "mapparser.y"
+#line 136 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0)
 		                           (yyval.intval) = MS_TRUE;
@@ -1303,7 +1304,7 @@
     break;
 
   case 13:
-#line 135 "mapparser.y"
+#line 144 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0) {
 			                   if((yyvsp[0].dblval) != 0)
@@ -1316,17 +1317,17 @@
     break;
 
   case 14:
-#line 144 "mapparser.y"
+#line 153 "mapparser.y"
     { (yyval.intval) = !(yyvsp[0].intval); }
     break;
 
   case 15:
-#line 145 "mapparser.y"
+#line 154 "mapparser.y"
     { (yyval.intval) = !(yyvsp[0].dblval); }
     break;
 
   case 16:
-#line 146 "mapparser.y"
+#line 155 "mapparser.y"
     {
                                          ms_regex_t re;
 
@@ -1343,7 +1344,7 @@
     break;
 
   case 17:
-#line 159 "mapparser.y"
+#line 168 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
 	 		                   (yyval.intval) = MS_TRUE;
@@ -1353,7 +1354,7 @@
     break;
 
   case 18:
-#line 165 "mapparser.y"
+#line 174 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1363,7 +1364,7 @@
     break;
 
   case 19:
-#line 171 "mapparser.y"
+#line 180 "mapparser.y"
     {	                                 
 	                                 if((yyvsp[-2].dblval) > (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1373,7 +1374,7 @@
     break;
 
   case 20:
-#line 177 "mapparser.y"
+#line 186 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) < (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1383,7 +1384,7 @@
     break;
 
   case 21:
-#line 183 "mapparser.y"
+#line 192 "mapparser.y"
     {	                                 
 	                                 if((yyvsp[-2].dblval) >= (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1393,7 +1394,7 @@
     break;
 
   case 22:
-#line 189 "mapparser.y"
+#line 198 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) <= (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1403,12 +1404,12 @@
     break;
 
   case 23:
-#line 195 "mapparser.y"
+#line 204 "mapparser.y"
     { (yyval.intval) = (yyvsp[-1].intval); }
     break;
 
   case 24:
-#line 196 "mapparser.y"
+#line 205 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1420,7 +1421,7 @@
     break;
 
   case 25:
-#line 204 "mapparser.y"
+#line 213 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) != 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1432,7 +1433,7 @@
     break;
 
   case 26:
-#line 212 "mapparser.y"
+#line 221 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) > 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1445,7 +1446,7 @@
     break;
 
   case 27:
-#line 221 "mapparser.y"
+#line 230 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) < 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1457,7 +1458,7 @@
     break;
 
   case 28:
-#line 229 "mapparser.y"
+#line 238 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) >= 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1469,7 +1470,7 @@
     break;
 
   case 29:
-#line 237 "mapparser.y"
+#line 246 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) <= 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1481,7 +1482,7 @@
     break;
 
   case 30:
-#line 245 "mapparser.y"
+#line 254 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1491,7 +1492,7 @@
     break;
 
   case 31:
-#line 251 "mapparser.y"
+#line 260 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) != 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1501,7 +1502,7 @@
     break;
 
   case 32:
-#line 257 "mapparser.y"
+#line 266 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) > 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1511,7 +1512,7 @@
     break;
 
   case 33:
-#line 263 "mapparser.y"
+#line 272 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) < 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1521,7 +1522,7 @@
     break;
 
   case 34:
-#line 269 "mapparser.y"
+#line 278 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) >= 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1531,7 +1532,7 @@
     break;
 
   case 35:
-#line 275 "mapparser.y"
+#line 284 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) <= 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1541,7 +1542,7 @@
     break;
 
   case 36:
-#line 281 "mapparser.y"
+#line 290 "mapparser.y"
     {
 					 char *delim,*bufferp;
 
@@ -1566,7 +1567,7 @@
     break;
 
   case 37:
-#line 302 "mapparser.y"
+#line 311 "mapparser.y"
     {
 					 char *delim,*bufferp;
 
@@ -1591,7 +1592,7 @@
     break;
 
   case 38:
-#line 323 "mapparser.y"
+#line 332 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
 	 		                   (yyval.intval) = MS_TRUE;
@@ -1601,7 +1602,7 @@
     break;
 
   case 39:
-#line 329 "mapparser.y"
+#line 338 "mapparser.y"
     {
                                          if(strcasecmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1613,7 +1614,7 @@
     break;
 
   case 40:
-#line 337 "mapparser.y"
+#line 346 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1623,7 +1624,7 @@
     break;
 
   case 41:
-#line 343 "mapparser.y"
+#line 352 "mapparser.y"
     {
       int rval;
       rval = msGEOSIntersects((yyvsp[-2].shpval), (yyvsp[0].shpval));      
@@ -1638,32 +1639,32 @@
     break;
 
   case 43:
-#line 357 "mapparser.y"
+#line 366 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-1].dblval); }
     break;
 
   case 44:
-#line 358 "mapparser.y"
+#line 367 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-2].dblval) + (yyvsp[0].dblval); }
     break;
 
   case 45:
-#line 359 "mapparser.y"
+#line 368 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-2].dblval) - (yyvsp[0].dblval); }
     break;
 
   case 46:
-#line 360 "mapparser.y"
+#line 369 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-2].dblval) * (yyvsp[0].dblval); }
     break;
 
   case 47:
-#line 361 "mapparser.y"
+#line 370 "mapparser.y"
     { (yyval.dblval) = (int)(yyvsp[-2].dblval) % (int)(yyvsp[0].dblval); }
     break;
 
   case 48:
-#line 362 "mapparser.y"
+#line 371 "mapparser.y"
     {
       if((yyvsp[0].dblval) == 0.0) {
         msyyerror("Division by zero.");
@@ -1674,22 +1675,22 @@
     break;
 
   case 49:
-#line 369 "mapparser.y"
+#line 378 "mapparser.y"
     { (yyval.dblval) = (yyvsp[0].dblval); }
     break;
 
   case 50:
-#line 370 "mapparser.y"
+#line 379 "mapparser.y"
     { (yyval.dblval) = pow((yyvsp[-2].dblval), (yyvsp[0].dblval)); }
     break;
 
   case 51:
-#line 371 "mapparser.y"
+#line 380 "mapparser.y"
     { (yyval.dblval) = strlen((yyvsp[-1].strval)); }
     break;
 
   case 52:
-#line 372 "mapparser.y"
+#line 381 "mapparser.y"
     {
       if((yyvsp[-1].shpval)->type != MS_SHAPE_POLYGON) {
         msyyerror("Area can only be computed for polygon shapes.");
@@ -1701,12 +1702,12 @@
     break;
 
   case 54:
-#line 383 "mapparser.y"
+#line 392 "mapparser.y"
     { (yyval.shpval) = (yyvsp[-1].shpval); }
     break;
 
   case 55:
-#line 384 "mapparser.y"
+#line 393 "mapparser.y"
     {
       shapeObj *s;
       s = msShapeFromWKT((yyvsp[-1].strval));
@@ -1720,17 +1721,17 @@
     break;
 
   case 57:
-#line 397 "mapparser.y"
+#line 406 "mapparser.y"
     { (yyval.strval) = (yyvsp[-1].strval); free((yyvsp[-1].strval)); }
     break;
 
   case 58:
-#line 398 "mapparser.y"
+#line 407 "mapparser.y"
     { sprintf((yyval.strval), "%s%s", (yyvsp[-2].strval), (yyvsp[0].strval)); free((yyvsp[-2].strval)); free((yyvsp[0].strval)); }
     break;
 
   case 60:
-#line 402 "mapparser.y"
+#line 411 "mapparser.y"
     { (yyval.tmval) = (yyvsp[-1].tmval); }
     break;
 
@@ -1738,7 +1739,7 @@
     }
 
 /* Line 1037 of yacc.c.  */
-#line 1742 "mapparser.c"
+#line 1743 "mapparser.c"
 
   yyvsp -= yylen;
   yyssp -= yylen;
@@ -1966,6 +1967,30 @@
 }
 
 
-#line 405 "mapparser.y"
+#line 414 "mapparser.y"
 
 
+/*
+** Any extra C functions
+*/
+
+int yylex(void) 
+{
+  int token;
+
+  if(yyexpr->curtoken == yyexpr->numtokens) return(0); /* done */
+  token = msyyexpr->tokens[msyyexpr->curtoken];
+  msyyexpr->curtoken++;
+  return(token);
+}
+
+int yywrap() /* override */
+{
+  return(1);
+}
+
+int yyerror(char *s) {
+  msSetError(MS_PARSEERR, s, "yyparse()");
+  return(0);
+}
+

Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.h
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.h	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.h	2010-06-14 04:23:53 UTC (rev 10227)
@@ -84,7 +84,7 @@
 
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 25 "mapparser.y"
+#line 34 "mapparser.y"
 typedef union YYSTYPE {
   double dblval;
   int intval;  
@@ -99,7 +99,7 @@
 # define YYSTYPE_IS_TRIVIAL 1
 #endif
 
-extern YYSTYPE mseyylval;
+extern YYSTYPE yylval;
 
 
 

Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.y
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.y	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.y	2010-06-14 04:23:53 UTC (rev 10227)
@@ -14,10 +14,19 @@
 #include "maptime.h" /* for time comparison routines */
 #include "mapprimitive.h" /* for shapeObj */
 
-extern int msyylex(void); /* lexer globals */
-extern int msyyerror(const char *);
+// extern int msyylex(void); /* lexer globals */
+// extern int msyyerror(const char *);
 
-int msyyresult;
+shapeObj *yyshape;
+layerObj *yylayer;
+expressionObj *yyexpr;
+
+typedef union {
+  int intval;
+  char *strval;
+  shapeObj *shpval;
+} parseResultObj;
+parseResultObj yyresult;
 %}
 
 /* Bison/Yacc declarations */
@@ -61,12 +70,12 @@
 %%
 
 input: /* empty string */
- | logical_exp { msyyresult = $1; }
+ | logical_exp { yyresult.intval = $1; }
  | math_exp {
      if($1 != 0)
-       msyyresult = MS_TRUE;
+       yyresult.intval = MS_TRUE;
      else
-       msyyresult = MS_FALSE;			    
+       yyresult.intval = MS_FALSE;			    
    }
 ;
 
@@ -346,7 +355,7 @@
       if($1->scope == 1) msFreeShape($1);
       if($3->scope == 1) msFreeShape($3); 
       if(rval == -1) {
-        msyyerror("Intersects operator failed.");
+        yyerror("Intersects operator failed.");
         return(-1);
       } else
         $$ = rval;
@@ -361,7 +370,7 @@
   | math_exp '%' math_exp { $$ = (int)$1 % (int)$3; }
   | math_exp '/' math_exp {
       if($3 == 0.0) {
-        msyyerror("Division by zero.");
+        yyerror("Division by zero.");
         return(-1);
       } else
         $$ = $1 / $3; 
@@ -371,7 +380,7 @@
   | LENGTH '(' string_exp ')' { $$ = strlen($3); }
   | AREA '(' shape_exp ')' {
       if($3->type != MS_SHAPE_POLYGON) {
-        msyyerror("Area can only be computed for polygon shapes.");
+        yyerror("Area can only be computed for polygon shapes.");
         return(-1);
       }
       $$ = msGetPolygonArea($3);
@@ -385,7 +394,7 @@
       shapeObj *s;
       s = msShapeFromWKT($3);
       if(!s) {
-        msyyerror("Parsing WKT text failed.");
+        yyerror("Parsing WKT text failed.");
         return(-1);
       }
       s->scope = 1;
@@ -403,3 +412,63 @@
 ;
 
 %%
+
+/*
+** Any extra C functions
+*/
+
+int yylex(void) 
+{
+  int token, i=yyexpr->curtoken;
+
+  if(yyexpr->curtoken == yyexpr->numtokens) return(0); /* done */
+
+  token = yyexpr->tokens[i].token; /* may override if a binding token */
+  switch(yyexpr->tokens[i].token) {
+  case NUMBER:
+    yylval.dblval = yyexpr->tokens[i].tokenval.dblval;
+    break;
+  case STRING:
+  case ISTRING:
+    yylval.strval = strdup(yyexpr->tokens[i].tokenval.strval);    
+    break;
+  case REGEX:
+  case IREGEX:
+    yylval.strval = yyexpr->tokens[i].tokenval.strval;
+    break;
+  case TIME:
+    yylval.tmval = yyexpr->tokens[i].tokenval.tmval;
+    break;
+  case MS_TOKEN_BINDING_DOUBLE:
+  case MS_TOKEN_BINDING_INTEGER:
+    token = NUMBER;
+    yylval.dblval = atof(yyshape->values[yyexpr->tokens[i].tokenval.bindval.index]);
+    break;
+  case MS_TOKEN_BINDING_STRING:
+    token = STRING;
+    yylval.strval = strdup(yyshape->values[yyexpr->tokens[i].tokenval.bindval.index]);
+    break;
+  case MS_TOKEN_BINDING_TIME:
+    token = TIME;
+    msTimeInit(&(yylval.tmval));
+    if(msParseTime(yyshape->values[yyexpr->tokens[i].tokenval.bindval.index], &(yylval.tmval)) != MS_TRUE) {
+      yyerror("Parsing time value failed.", "yylex()");
+      return(-1);
+    }
+    break;
+  case MS_TOKEN_BINDING_SHAPE:
+    token = SHAPE;
+    yylval.shpval = yyshape;
+    break;
+  default:
+    break;
+  }
+
+  yyexpr->curtoken++;
+  return(token);
+}
+
+int yyerror(char *s) {
+  msSetError(MS_PARSEERR, s, "yyparse()");
+  return(0);
+}

Modified: sandbox/sdlime/common-expressions/mapserver/mapserver.h
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapserver.h	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/mapserver.h	2010-06-14 04:23:53 UTC (rev 10227)
@@ -441,12 +441,12 @@
 
 typedef struct _FilterNode
 {
-    FilterNodeType      eType;
-    char                *pszValue;
-    void                *pOther;
-    char                *pszSRS;
-    struct _FilterNode  *psLeftNode;
-    struct _FilterNode  *psRightNode;
+  FilterNodeType      eType;
+  char                *pszValue;
+  void                *pOther;
+  char                *pszSRS;
+  struct _FilterNode  *psLeftNode;
+  struct _FilterNode  *psRightNode;
 } FilterEncodingNode;
 
 /* Define supported bindings here (only covers existing bindings at first). Not accessible directly using MapScript. */
@@ -488,17 +488,17 @@
 
 typedef struct {
 #ifdef SWIG
-    %immutable;
+%immutable;
 #endif
-    char *filename; 
-    int numfonts;
-    hashTableObj fonts;
+  char *filename; 
+  int numfonts;
+  hashTableObj fonts;
 #ifdef SWIG
-    %mutable;
+%mutable;
 #endif
 
 #ifndef SWIG
-    struct map_obj *map;
+  struct map_obj *map;
 #endif
 } fontSetObj;
 
@@ -509,9 +509,9 @@
 /************************************************************************/
 #ifndef SWIG
 typedef struct listNode {
-    shapeObj shape;
-    struct listNode *next;
-    struct listNode *tailifhead; /* this is the tail node in the list, if this is the head element, otherwise NULL */
+  shapeObj shape;
+  struct listNode *next;
+  struct listNode *tailifhead; /* this is the tail node in the list, if this is the head element, otherwise NULL */
 } featureListNodeObj;
 
 typedef featureListNodeObj * featureListNodeObjPtr;
@@ -524,9 +524,9 @@
 /************************************************************************/
 #ifndef SWIG
 typedef struct {
-    colorObj colors[MS_MAXCOLORS-1];
-    int      colorvalue[MS_MAXCOLORS-1];
-    int numcolors;
+  colorObj colors[MS_MAXCOLORS-1];
+  int colorvalue[MS_MAXCOLORS-1];
+  int numcolors;
 } paletteObj;
 #endif
 
@@ -550,19 +550,20 @@
 } tokenObj;
 
 typedef struct {
-    char *string;
-    int type;
-    /* container for expression options such as case-insensitiveness */
-    /* This is a boolean container. */
-    int flags;
+  char *string;
+  int type;
+  /* container for expression options such as case-insensitiveness */
+  /* This is a boolean container. */
+  int flags;
     
-    /* logical expression options */
-    tokenObj tokens[100];
-    int numtokens;    
-    
-    /* regular expression options */
-    ms_regex_t regex; /* compiled regular expression to be matched */
-    int compiled;
+  /* logical expression options */
+  tokenObj tokens[100];
+  int numtokens;
+  int curtoken;
+
+  /* regular expression options */
+  ms_regex_t regex; /* compiled regular expression to be matched */
+  int compiled;
 } expressionObj;
 #endif
 
@@ -575,25 +576,24 @@
 
 #ifndef SWIG
 typedef struct {
-    char *name;
-    char **items, **values; /* items/values (process 1 record at a time) */
-    int numitems;
+  char *name;
+  char **items, **values; /* items/values (process 1 record at a time) */
+  int numitems;
+
+  char *table;
+  char *from, *to; /* item names */
     
-    char *table;
-    char *from, *to; /* item names */
-    
-    void *joininfo; /* vendor specific (i.e. XBase, MySQL, etc.) stuff to allow for persistant access */
-    
-    char *header, *footer;
+  void *joininfo; /* vendor specific (i.e. XBase, MySQL, etc.) stuff to allow for persistant access */
+  char *header, *footer;
 #ifndef __cplusplus
-    char *template;
+  char *template;
 #else
-    char *_template;
+  char *_template;
 #endif
-    
-    enum MS_JOIN_TYPE type;
-    char *connection;
-    enum MS_JOIN_CONNECTION_TYPE connectiontype;
+
+  enum MS_JOIN_TYPE type;
+  char *connection;
+  enum MS_JOIN_CONNECTION_TYPE connectiontype;
 } joinObj;
 #endif
 
@@ -604,19 +604,19 @@
 /************************************************************************/
 
 typedef struct {
-    char *name;
-    char *mimetype;
-    char *driver;
-    char *extension;
-    int  renderer;  /* MS_RENDER_WITH_* */
-    int  imagemode; /* MS_IMAGEMODE_* value. */
-    int  transparent;
-    int  bands;
-    int  numformatoptions;
-    char **formatoptions;
-    int  refcount;
-    int inmapfile; /* boolean value for writing */
-    rendererVTableObj *vtable;
+  char *name;
+  char *mimetype;
+  char *driver;
+  char *extension;
+  int  renderer;  /* MS_RENDER_WITH_* */
+  int  imagemode; /* MS_IMAGEMODE_* value. */
+  int  transparent;
+  int  bands;
+  int  numformatoptions;
+  char **formatoptions;
+  int  refcount;
+  int inmapfile; /* boolean value for writing */
+  rendererVTableObj *vtable;
 } outputFormatObj;
 
 /* The following is used for "don't care" values in transparent, interlace and
@@ -661,10 +661,10 @@
 /*      used to visualize query results                                 */
 /************************************************************************/
 typedef struct {
-    int height, width;
-    int status;
-    int style; /* HILITE, SELECTED or NORMAL */
-    colorObj color;
+  int height, width;
+  int status;
+  int style; /* HILITE, SELECTED or NORMAL */
+  colorObj color;
 } queryMapObj;
 
 /************************************************************************/

Modified: sandbox/sdlime/common-expressions/mapserver/maputil.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maputil.c	2010-06-12 18:11:09 UTC (rev 10226)
+++ sandbox/sdlime/common-expressions/mapserver/maputil.c	2010-06-14 04:23:53 UTC (rev 10227)
@@ -52,15 +52,15 @@
 
 MS_CVSID("$Id$")
 
-extern int msyyparse(void);
-extern int msyylex(void);
 extern int msyylex_destroy(void);
-extern char *msyytext;
 
-extern int msyyresult; /* result of parsing, true/false */
-extern int msyystate;
-extern char *msyystring;
+extern int yyparse(void);
+extern parseResultObj yyresult; /* result of parsing, true/false */
 
+extern shapeObj *yyshape; /* globals to hold the active shape/layer/expression */
+extern layerObj *yylayer;
+extern expressionObj *yyexpr;
+
 /*
 ** Helper functions to convert from strings to other types or objects.
 */
@@ -378,14 +378,11 @@
   case(MS_EXPRESSION):
 
     msAcquireLock( TLOCK_PARSER );
-    msyystate = MS_TOKENIZE_EXPRESSION;
+    yyshape = shape;
+    yylayer = layer;
+    yyexpr = expression;
 
-    // msyyshape = shape;
-    // msyylayer = layer;
-
-    msyystring = expression->string;
-    status = msyyparse();
-    expresult = msyyresult;
+    status = yyparse();
     msReleaseLock( TLOCK_PARSER );
 
     if (status != 0) {
@@ -393,7 +390,7 @@
       return MS_FALSE;
     }
 
-    return expresult;    
+    return yyresult.intval;
     break;
   case(MS_REGEX):
     if(itemindex == -1) {



More information about the mapserver-commits mailing list