[Mapserver-users] maplexer and mapparser
Steve Lime
steve.lime at dnr.state.mn.us
Fri Dec 19 11:22:11 PST 2003
Hi Andrew. The files maplexer.c and mapparser.c are generated
automatically by the tools flex and bison respectively, and in turn are
based on the configuration files maplexer.l and mapparser.y. I've never
looked at the C source for those files, nor would I want to. Any changes
made there would be lost anyway. Here's what each file is used for:
- maplexer.l contains regular expressions and C snippets to break a
map file, certain CGI parameters and MapServer expressions into tokens.
These tokens are then handed off to other sections of the code to be
used. The lexer keeps track of where it is in a file or string and the
function msyylex simply gets the next token. The C code generated by
flex uses lots of global variables (and is not thread safe) to hold
various pieces of information about a token such as it's string
representation.
- mapparser.y defines the grammar, the rules, for MapServer logical
expressions. It has nothing to do with parsing map files, only
expressions. It's cryptic to look at but once you figure it out it's not
bad. The grammar consists of things like setting operator precedance
(i.e evaluate * before +) and sets the rules for doing things like
adding 2 numbers, or comparing strings. The parser takes tokens from the
lexer and input. There's a function called msyyparse that evaluates any
particular string against the grammar.
Does this help?
Steve
>>> "Andrew Arace" <AArace at geonetics.com> 12/18/2003 4:59:28 PM >>>
I'm currently working on some modifications to the MapServer source
code, and I've built the whole project in windows 2000, using the .NET
IDE.
I've got the exe, the necessary functions run great.
However, my current modifications require me to understand the
maplexer.c and mapparser.c.
I'm a pretty smart guy. But I'm a Unix noobie. (I know, some will
think
that's a contradiction...)
Anyway, I have NO IDEA what is going on in those files. No clue.
People
have told me what yacc is, and bison, but I don't have a very good
understanding, and these files are the root of all my confusion.
Basically, what are these used for. what is actually going on when the
mapfile parser calls switch(msyylex()) {...} (mapfile.c,
loadMapInternal())
What are the crazy int arrays in the maplexer? such as yy_accept[2174]
? What are the maplexer.l and mapparser.y files?
I'm just in need of a thorough explanation, please please?
Thanks very much in advance
--
Andrew Arace
aarace at geonetics.com
Software Engineer
Geonetics, Inc
(617) 896 - 4409
Disclaimer Notice: This message contains confidential information and
is intended only for the individual named. If you are not the named
addressee you should not disseminate, distribute, or copy this e-mail.
Please notify the sender immediately if you have received this e-mail by
mistake and delete this e-mail from your system. E-mail transmission
cannot be guaranteed to be secure or error free as information can be
intercepted, corrupted, lost, destroyed, arrive late or incomplete, or
contain viruses. The sender therefore does not accept liability for any
errors or omissions in the contents of this message, which arise as a
result of e-mail transmission. If verification is required please
request a hard copy version. BSC Companies, Inc.; BSC Group, Inc.;
Geonetics, Inc. 15 Elkins Street Boston, Massachusetts 02127 USA.
www.BSCGroup.com.
http://www.bscgroup.com/
More information about the MapServer-users
mailing list