[mapserver-dev] Mapfile syntax permissiveness

Howard Butler hobu.inc at gmail.com
Mon Dec 29 00:57:08 EST 2008

On Dec 27, 2008, at 11:53 AM, Christopher Schmidt wrote:

> On Sat, Dec 27, 2008 at 09:05:46AM -0600, Howard Butler wrote:
>> I was working on implementing a Pygments lexer so we could have
>> mapfile styling for the new website (see the results at
>> http://mapserver.osgeo.org/ogc/mapcontext.html ) and one thing that  
>> caused
>> me trouble (still not right in my lexer,  anyway) is that we allow  
>> both:
>> NAME mymapname
>> and
>> NAME "mymapname"
>> Why do some keywords like NAME and DATA allow both the quoted and
>> unquoted form?  Was there a historical reason for this?  Is it just
>> because flex supported it?  In my mind, unquoted implies a symbol  
>> or a
>> reserved name, not user data.  Would we ever revert to requiring  
>> every
>> piece of user data to be quoted?
> I don't see a reason for that; if both work, why make the mapfile  
> *more*
> restrictive?

Maybe I was looking for consistent rather than restrictive.

NAME MY NAME WITH A SPACE # <-- won't work

NAME "MY NAME WITH A SPACE" # <-- works fine

This is consistent in that if you want to write things that have  
spaces, you need to quote them.  It's not consistent in that sometimes  
you need quotes and sometimes you don't.

> That said, it seems to me that a mapfile pygments parser can only
> support the more 'restrictive' form properly, and just make sure all  
> the
> documentation examples match that...

*My* mapfile Pygments parser can only support quoted stuff because I'm  
an idiot :)  Someone with real skills should have no trouble making  
Pygments do what it needs to to follow what MapServer currently allows.

>> Would there be benefits to this in
>> contrast to the pain it would cause (maybe we have a 'strict' and
>> 'lax' mapfile parser or something)?
> I can't think of any...

One thing I thought of is 'strict' might help if we ever make the much- 
talked-about and never-materialized XML mapfile happen.  It might make  
it easier to transform back and forth between .map and .xml formats.   
Whether it's worth much, I don't know.  I remember JF talking about  
some cool Python Mapfile parsing/lexing stuff that he did a while  
back.  Maybe we can nag him into showing it to us :)


More information about the mapserver-dev mailing list