[mapserver-commits] r10269 -
sandbox/sdlime/common-expressions/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Jun 30 23:49:04 EDT 2010
Author: sdlime
Date: 2010-07-01 03:49:04 +0000 (Thu, 01 Jul 2010)
New Revision: 10269
Modified:
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/mapraster.c
sandbox/sdlime/common-expressions/mapserver/mapserver.h
sandbox/sdlime/common-expressions/mapserver/maputil.c
Log:
More...
Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.c 2010-06-30 16:37:12 UTC (rev 10268)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.c 2010-07-01 03:49:04 UTC (rev 10269)
@@ -121,19 +121,14 @@
#include "maptime.h" /* for time comparison routines */
#include "mapprimitive.h" /* for shapeObj */
-// extern int msyylex(void); /* lexer globals */
-// extern int msyyerror(const char *);
+// int yylex(void); /* lexer globals */
+// int yyerror(const char *);
shapeObj *yyshape;
layerObj *yylayer;
expressionObj *yyexpr;
-typedef union {
- int intval;
- char *strval;
- shapeObj *shpval;
-} parseResultObj;
-parseResultObj yyresult;
+parseResultObj yypresult;
/* Enabling traces. */
@@ -150,7 +145,7 @@
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 34 "mapparser.y"
+#line 29 "mapparser.y"
typedef union YYSTYPE {
double dblval;
int intval;
@@ -159,7 +154,7 @@
shapeObj *shpval;
} YYSTYPE;
/* Line 185 of yacc.c. */
-#line 163 "mapparser.c"
+#line 158 "mapparser.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@@ -171,7 +166,7 @@
/* Line 213 of yacc.c. */
-#line 175 "mapparser.c"
+#line 170 "mapparser.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
@@ -370,13 +365,13 @@
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned short int yyrline[] =
{
- 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
+ 0, 67, 67, 68, 69, 77, 80, 88, 97, 105,
+ 114, 122, 131, 139, 148, 149, 150, 163, 169, 175,
+ 181, 187, 193, 199, 200, 208, 216, 225, 233, 241,
+ 249, 255, 261, 267, 273, 279, 285, 306, 327, 333,
+ 341, 347, 360, 361, 362, 363, 364, 365, 366, 373,
+ 374, 375, 376, 386, 387, 388, 400, 401, 402, 405,
+ 406
};
#endif
@@ -1202,22 +1197,22 @@
switch (yyn)
{
case 3:
-#line 73 "mapparser.y"
- { yyresult.intval = (yyvsp[0].intval); }
+#line 68 "mapparser.y"
+ { yypresult.intval = (yyvsp[0].intval); }
break;
case 4:
-#line 74 "mapparser.y"
+#line 69 "mapparser.y"
{
if((yyvsp[0].dblval) != 0)
- yyresult.intval = MS_TRUE;
+ yypresult.intval = MS_TRUE;
else
- yyresult.intval = MS_FALSE;
+ yypresult.intval = MS_FALSE;
}
break;
case 6:
-#line 85 "mapparser.y"
+#line 80 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE)
(yyval.intval) = MS_TRUE;
@@ -1229,7 +1224,7 @@
break;
case 7:
-#line 93 "mapparser.y"
+#line 88 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE) {
if((yyvsp[0].intval) == MS_TRUE)
@@ -1242,7 +1237,7 @@
break;
case 8:
-#line 102 "mapparser.y"
+#line 97 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE)
(yyval.intval) = MS_TRUE;
@@ -1254,7 +1249,7 @@
break;
case 9:
-#line 110 "mapparser.y"
+#line 105 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE) {
if((yyvsp[0].dblval) != 0)
@@ -1267,7 +1262,7 @@
break;
case 10:
-#line 119 "mapparser.y"
+#line 114 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0)
(yyval.intval) = MS_TRUE;
@@ -1279,7 +1274,7 @@
break;
case 11:
-#line 127 "mapparser.y"
+#line 122 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0) {
if((yyvsp[0].intval) == MS_TRUE)
@@ -1292,7 +1287,7 @@
break;
case 12:
-#line 136 "mapparser.y"
+#line 131 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0)
(yyval.intval) = MS_TRUE;
@@ -1304,7 +1299,7 @@
break;
case 13:
-#line 144 "mapparser.y"
+#line 139 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0) {
if((yyvsp[0].dblval) != 0)
@@ -1317,17 +1312,17 @@
break;
case 14:
-#line 153 "mapparser.y"
+#line 148 "mapparser.y"
{ (yyval.intval) = !(yyvsp[0].intval); }
break;
case 15:
-#line 154 "mapparser.y"
+#line 149 "mapparser.y"
{ (yyval.intval) = !(yyvsp[0].dblval); }
break;
case 16:
-#line 155 "mapparser.y"
+#line 150 "mapparser.y"
{
ms_regex_t re;
@@ -1344,7 +1339,7 @@
break;
case 17:
-#line 168 "mapparser.y"
+#line 163 "mapparser.y"
{
if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1354,7 +1349,7 @@
break;
case 18:
-#line 174 "mapparser.y"
+#line 169 "mapparser.y"
{
if((yyvsp[-2].dblval) != (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1364,7 +1359,7 @@
break;
case 19:
-#line 180 "mapparser.y"
+#line 175 "mapparser.y"
{
if((yyvsp[-2].dblval) > (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1374,7 +1369,7 @@
break;
case 20:
-#line 186 "mapparser.y"
+#line 181 "mapparser.y"
{
if((yyvsp[-2].dblval) < (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1384,7 +1379,7 @@
break;
case 21:
-#line 192 "mapparser.y"
+#line 187 "mapparser.y"
{
if((yyvsp[-2].dblval) >= (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1394,7 +1389,7 @@
break;
case 22:
-#line 198 "mapparser.y"
+#line 193 "mapparser.y"
{
if((yyvsp[-2].dblval) <= (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1404,12 +1399,12 @@
break;
case 23:
-#line 204 "mapparser.y"
+#line 199 "mapparser.y"
{ (yyval.intval) = (yyvsp[-1].intval); }
break;
case 24:
-#line 205 "mapparser.y"
+#line 200 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
(yyval.intval) = MS_TRUE;
@@ -1421,7 +1416,7 @@
break;
case 25:
-#line 213 "mapparser.y"
+#line 208 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) != 0)
(yyval.intval) = MS_TRUE;
@@ -1433,7 +1428,7 @@
break;
case 26:
-#line 221 "mapparser.y"
+#line 216 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) > 0)
(yyval.intval) = MS_TRUE;
@@ -1446,7 +1441,7 @@
break;
case 27:
-#line 230 "mapparser.y"
+#line 225 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) < 0)
(yyval.intval) = MS_TRUE;
@@ -1458,7 +1453,7 @@
break;
case 28:
-#line 238 "mapparser.y"
+#line 233 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) >= 0)
(yyval.intval) = MS_TRUE;
@@ -1470,7 +1465,7 @@
break;
case 29:
-#line 246 "mapparser.y"
+#line 241 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) <= 0)
(yyval.intval) = MS_TRUE;
@@ -1482,7 +1477,7 @@
break;
case 30:
-#line 254 "mapparser.y"
+#line 249 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
(yyval.intval) = MS_TRUE;
@@ -1492,7 +1487,7 @@
break;
case 31:
-#line 260 "mapparser.y"
+#line 255 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) != 0)
(yyval.intval) = MS_TRUE;
@@ -1502,7 +1497,7 @@
break;
case 32:
-#line 266 "mapparser.y"
+#line 261 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) > 0)
(yyval.intval) = MS_TRUE;
@@ -1512,7 +1507,7 @@
break;
case 33:
-#line 272 "mapparser.y"
+#line 267 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) < 0)
(yyval.intval) = MS_TRUE;
@@ -1522,7 +1517,7 @@
break;
case 34:
-#line 278 "mapparser.y"
+#line 273 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) >= 0)
(yyval.intval) = MS_TRUE;
@@ -1532,7 +1527,7 @@
break;
case 35:
-#line 284 "mapparser.y"
+#line 279 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) <= 0)
(yyval.intval) = MS_TRUE;
@@ -1542,7 +1537,7 @@
break;
case 36:
-#line 290 "mapparser.y"
+#line 285 "mapparser.y"
{
char *delim,*bufferp;
@@ -1567,7 +1562,7 @@
break;
case 37:
-#line 311 "mapparser.y"
+#line 306 "mapparser.y"
{
char *delim,*bufferp;
@@ -1592,7 +1587,7 @@
break;
case 38:
-#line 332 "mapparser.y"
+#line 327 "mapparser.y"
{
if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1602,7 +1597,7 @@
break;
case 39:
-#line 338 "mapparser.y"
+#line 333 "mapparser.y"
{
if(strcasecmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
(yyval.intval) = MS_TRUE;
@@ -1614,7 +1609,7 @@
break;
case 40:
-#line 346 "mapparser.y"
+#line 341 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
(yyval.intval) = MS_TRUE;
@@ -1624,14 +1619,14 @@
break;
case 41:
-#line 352 "mapparser.y"
+#line 347 "mapparser.y"
{
int rval;
rval = msGEOSIntersects((yyvsp[-2].shpval), (yyvsp[0].shpval));
if((yyvsp[-2].shpval)->scope == 1) msFreeShape((yyvsp[-2].shpval));
if((yyvsp[0].shpval)->scope == 1) msFreeShape((yyvsp[0].shpval));
if(rval == -1) {
- msyyerror("Intersects operator failed.");
+ yyerror("Intersects operator failed.");
return(-1);
} else
(yyval.intval) = rval;
@@ -1639,35 +1634,35 @@
break;
case 43:
-#line 366 "mapparser.y"
+#line 361 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-1].dblval); }
break;
case 44:
-#line 367 "mapparser.y"
+#line 362 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-2].dblval) + (yyvsp[0].dblval); }
break;
case 45:
-#line 368 "mapparser.y"
+#line 363 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-2].dblval) - (yyvsp[0].dblval); }
break;
case 46:
-#line 369 "mapparser.y"
+#line 364 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-2].dblval) * (yyvsp[0].dblval); }
break;
case 47:
-#line 370 "mapparser.y"
+#line 365 "mapparser.y"
{ (yyval.dblval) = (int)(yyvsp[-2].dblval) % (int)(yyvsp[0].dblval); }
break;
case 48:
-#line 371 "mapparser.y"
+#line 366 "mapparser.y"
{
if((yyvsp[0].dblval) == 0.0) {
- msyyerror("Division by zero.");
+ yyerror("Division by zero.");
return(-1);
} else
(yyval.dblval) = (yyvsp[-2].dblval) / (yyvsp[0].dblval);
@@ -1675,25 +1670,25 @@
break;
case 49:
-#line 378 "mapparser.y"
+#line 373 "mapparser.y"
{ (yyval.dblval) = (yyvsp[0].dblval); }
break;
case 50:
-#line 379 "mapparser.y"
+#line 374 "mapparser.y"
{ (yyval.dblval) = pow((yyvsp[-2].dblval), (yyvsp[0].dblval)); }
break;
case 51:
-#line 380 "mapparser.y"
+#line 375 "mapparser.y"
{ (yyval.dblval) = strlen((yyvsp[-1].strval)); }
break;
case 52:
-#line 381 "mapparser.y"
+#line 376 "mapparser.y"
{
if((yyvsp[-1].shpval)->type != MS_SHAPE_POLYGON) {
- msyyerror("Area can only be computed for polygon shapes.");
+ yyerror("Area can only be computed for polygon shapes.");
return(-1);
}
(yyval.dblval) = msGetPolygonArea((yyvsp[-1].shpval));
@@ -1702,17 +1697,17 @@
break;
case 54:
-#line 392 "mapparser.y"
+#line 387 "mapparser.y"
{ (yyval.shpval) = (yyvsp[-1].shpval); }
break;
case 55:
-#line 393 "mapparser.y"
+#line 388 "mapparser.y"
{
shapeObj *s;
s = msShapeFromWKT((yyvsp[-1].strval));
if(!s) {
- msyyerror("Parsing WKT text failed.");
+ yyerror("Parsing WKT text failed.");
return(-1);
}
s->scope = 1;
@@ -1721,17 +1716,17 @@
break;
case 57:
-#line 406 "mapparser.y"
+#line 401 "mapparser.y"
{ (yyval.strval) = (yyvsp[-1].strval); free((yyvsp[-1].strval)); }
break;
case 58:
-#line 407 "mapparser.y"
+#line 402 "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 411 "mapparser.y"
+#line 406 "mapparser.y"
{ (yyval.tmval) = (yyvsp[-1].tmval); }
break;
@@ -1739,7 +1734,7 @@
}
/* Line 1037 of yacc.c. */
-#line 1743 "mapparser.c"
+#line 1738 "mapparser.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1967,7 +1962,7 @@
}
-#line 414 "mapparser.y"
+#line 409 "mapparser.y"
/*
@@ -1976,19 +1971,55 @@
int yylex(void)
{
- int token;
+ int token, i=yyexpr->curtoken;
if(yyexpr->curtoken == yyexpr->numtokens) return(0); /* done */
- token = msyyexpr->tokens[msyyexpr->curtoken];
- msyyexpr->curtoken++;
+
+ 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 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-30 16:37:12 UTC (rev 10268)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.h 2010-07-01 03:49:04 UTC (rev 10269)
@@ -84,7 +84,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 34 "mapparser.y"
+#line 29 "mapparser.y"
typedef union YYSTYPE {
double dblval;
int intval;
Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.y
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.y 2010-06-30 16:37:12 UTC (rev 10268)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.y 2010-07-01 03:49:04 UTC (rev 10269)
@@ -14,19 +14,14 @@
#include "maptime.h" /* for time comparison routines */
#include "mapprimitive.h" /* for shapeObj */
-// extern int msyylex(void); /* lexer globals */
-// extern int msyyerror(const char *);
+// int yylex(void); /* lexer globals */
+// int yyerror(const char *);
shapeObj *yyshape;
layerObj *yylayer;
expressionObj *yyexpr;
-typedef union {
- int intval;
- char *strval;
- shapeObj *shpval;
-} parseResultObj;
-parseResultObj yyresult;
+parseResultObj yypresult;
%}
/* Bison/Yacc declarations */
@@ -70,12 +65,12 @@
%%
input: /* empty string */
- | logical_exp { yyresult.intval = $1; }
+ | logical_exp { yypresult.intval = $1; }
| math_exp {
if($1 != 0)
- yyresult.intval = MS_TRUE;
+ yypresult.intval = MS_TRUE;
else
- yyresult.intval = MS_FALSE;
+ yypresult.intval = MS_FALSE;
}
;
Modified: sandbox/sdlime/common-expressions/mapserver/mapraster.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapraster.c 2010-06-30 16:37:12 UTC (rev 10268)
+++ sandbox/sdlime/common-expressions/mapserver/mapraster.c 2010-07-01 03:49:04 UTC (rev 10269)
@@ -37,13 +37,13 @@
MS_CVSID("$Id$")
-extern int msyyparse(void);
-extern int msyylex(void);
-extern char *msyytext;
+extern int yyparse(void);
+// extern int msyylex(void);
+// extern char *msyytext;
-extern int msyyresult; /* result of parsing, true/false */
-extern int msyystate;
-extern char *msyystring;
+extern parseResultObj yypresult; /* result of parsing, true/false */
+// extern int msyystate;
+// extern char *msyystring;
#ifdef USE_GDAL
#include "gdal.h"
Modified: sandbox/sdlime/common-expressions/mapserver/mapserver.h
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapserver.h 2010-06-30 16:37:12 UTC (rev 10268)
+++ sandbox/sdlime/common-expressions/mapserver/mapserver.h 2010-07-01 03:49:04 UTC (rev 10269)
@@ -536,6 +536,12 @@
#ifndef SWIG
typedef union {
+ int intval;
+ char *strval;
+ shapeObj *shpval;
+} parseResultObj;
+
+typedef union {
double dblval;
int intval;
char *strval;
Modified: sandbox/sdlime/common-expressions/mapserver/maputil.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maputil.c 2010-06-30 16:37:12 UTC (rev 10268)
+++ sandbox/sdlime/common-expressions/mapserver/maputil.c 2010-07-01 03:49:04 UTC (rev 10269)
@@ -55,7 +55,7 @@
extern int msyylex_destroy(void);
extern int yyparse(void);
-extern parseResultObj yyresult; /* result of parsing, true/false */
+extern parseResultObj yypresult; /* result of parsing, true/false */
extern shapeObj *yyshape; /* globals to hold the active shape/layer/expression */
extern layerObj *yylayer;
@@ -328,9 +328,12 @@
}
msAcquireLock( TLOCK_PARSER );
- msyystate = MS_TOKENIZE_EXPRESSION; msyystring = tmpstr1;
- status = msyyparse();
- result = msyyresult;
+
+ // after subs, tokenize, then parse...
+
+ // msyystate = MS_TOKENIZE_EXPRESSION; msyystring = tmpstr1;
+ // status = msyyparse();
+ // result = msyyresult;
msReleaseLock( TLOCK_PARSER );
free(tmpstr1);
@@ -390,7 +393,7 @@
return MS_FALSE;
}
- return yyresult.intval;
+ return yypresult.intval;
break;
case(MS_REGEX):
if(itemindex == -1) {
More information about the mapserver-commits
mailing list