PostGIS versions 1.1.7/1.2.1 wktparse.y yacc/bison Syntax Bug

rev. date: 04-Aug-2007
rev. by: Fred Morris

Abstract

The postgis-1.1.7.tar.gz and postgis-1.2.1.tar.gz downloads from http://postgis.refractions.net/ contain a yacc/bison sourcefile named lwgeom/wktparse.y. The file appears to have invalid/improper syntax.

After repairing the syntax, the software builds and passes make check.

NOTE: Nothing here is to be construed or implied as a warranty of proper operation, with or without the suggested modifications. Use at your own risk.

Observed Failure Mode

With version 1.1.7, make is observed to fail with the following error:

bison -y -vd -p lwg_parse_yy wktparse.y
wktparse.y:40.14: parse error, unexpected ":", expecting ";" or "|"
wktparse.y:58.20-32: $3 of `geometry' has no declared type
wktparse.y:61.6-19: $1 of `geometry' has no declared type
wktparse.y:145.17: parse error, unexpected ":", expecting ";" or "|"
wktparse.y:232.14-31: $1 of `geom_multilinestring' has no declared type
wktparse.y:232.14-34: $2 of `geom_multilinestring' has no declared type
wktparse.y:235.20-37: $1 of `geom_multilinestring' has no declared type
wktparse.y:235.20-40: $2 of `geom_multilinestring' has no declared type
wktparse.y:235.20-43: $3 of `geom_multilinestring' has no declared type
wktparse.y:238.26-43: $1 of `geom_multilinestring' has no declared type
wktparse.y:238.26-46: $2 of `geom_multilinestring' has no declared type
wktparse.y:238.26-49: $3 of `geom_multilinestring' has no declared type
wktparse.y:238.26-52: $4 of `geom_multilinestring' has no declared type
make[1]: *** [wktparse.tab.c] Error 1
make[1]: Leaving directory `/usr/src/postgis-1.1.7/lwgeom'
make: *** [liblwgeom] Error 2

By inspection, it appears that the version 1.2.1 sourcefile contains the same defect.

Apparent Cause

It appears that the production rule definitions lack terminating semicolons. As an example:

geometry :
	srid  SEMICOLON  { alloc_lwgeom(srid); } geometry_int
	|
	{ alloc_lwgeom(-1); } geometry_int

geometry_int :
	geom_wkb
	|
	geom_point
	|
	geom_linestring
	|
	geom_polygon
	|
	geom_multipoint
	|
	geom_multilinestring
	|
	geom_multipolygon
	|
	geom_geometrycollection

should be:

geometry :
	srid  SEMICOLON  { alloc_lwgeom(srid); } geometry_int
	|
	{ alloc_lwgeom(-1); } geometry_int
;
geometry_int :
	geom_wkb
	|
	geom_point
	|
	geom_linestring
	|
	geom_polygon
	|
	geom_multipoint
	|
	geom_multilinestring
	|
	geom_multipolygon
	|
	geom_geometrycollection
;

Corrected File for Version 1.1.7

The file wktparse-y.txt compiled successfully and passed the supplied make check tests.


Fred Morris Consulting, Licensed in Seattle, WA, USA. since 1984

Document/Collaboration/Content Management Tools and Solutions

Better, Cheaper, Highly Adaptable, Less Hassles

Custom and Extraordinary Needs Data Processing Services

What else is on this web site?

An Internet Plumber... not a web cowboy

telephone: 206.297.6344
e-mail: x0xm3047x0xatx0xinwa.net