[Mapserver-users] maplexer and mapparser
Andrew Arace
AArace at geonetics.com
Fri Dec 19 11:38:06 PST 2003
This is a multi-part message in MIME format.
--=__Part6937B88E.1__=
Content-Type: text/plain; charset="US-ASCII"
I appreciate the explanation, and yes, it helps thanks.
You say "Any changes made [in maplexer.l and mapparser.y] would be lost
anyway" but how would they be lost?
I'm using my own build environment on windows, so I'm not running flex
or bison on those files at any time.
I'm currently not changing them at all, just trying to understand how
they work.
Mainly, what I've been implementing, is the ability to read map files
from a url instead of a static file on the hdd.
This will let me send the map= parameter as
map=http://server/getmap.asp
to be able to geneate a text/plain response which is the map file. In
this way, I can utilize asp's (or any web
language's) database connections, session, etc to write back the map
file syntax. hence dynamic on-the-fly maps.
The functionality for reading data from http was already built in
(using cURL) and I utilized the function calls
that it provided.
Right now, I have it functioning, but in order "msyylex" the new
'virtual' map file, it had to be FILE on
the disk. So currently, when fetching the map file response from the
URL, it is saving it to temp directory.
My goal was to keep the map file in memory when it is read from the url
response, but I could not understand
the maplexer.c enough to change it (because I see that it is only
written to read from files)
What do you think of my approach, and how I should proceed for the
virtual map file?
--
Andrew Arace
aarace at geonetics.com
Software Engineer
Geonetics, Inc
(617) 896 - 4409
>>> "Steve Lime" <steve.lime at dnr.state.mn.us> 2:22:11 PM Friday,
December 19, 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/
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/
--=__Part6937B88E.1__=
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>I appreciate the explanation, and yes, it helps thanks.</DIV>
<DIV>You say "Any changes made [in maplexer.l and mapparser.y] would be lost anyway" but how would they be lost?</DIV>
<DIV>I'm using my own build environment on windows, so I'm not running flex or bison on those files at any time. </DIV>
<DIV>I'm currently not changing them at all, just trying to understand how they work.</DIV>
<DIV> </DIV>
<DIV>Mainly, what I've been implementing, is the ability to read map files from a url instead of a static file on the hdd.</DIV>
<DIV>This will let me send the map= parameter as map=http://server/getmap.asp </DIV>
<DIV>to be able to geneate a text/plain response which is the map file. In this way, I can utilize asp's (or any web</DIV>
<DIV>language's) database connections, session, etc to write back the map file syntax. hence dynamic on-the-fly maps.</DIV>
<DIV> </DIV>
<DIV>The functionality for reading data from http was already built in (using cURL) and I utilized the function calls</DIV>
<DIV>that it provided.</DIV>
<DIV>Right now, I have it functioning, but in order "msyylex" the new 'virtual' map file, it had to be FILE on </DIV>
<DIV>the disk. So currently, when fetching the map file response from the URL, it is saving it to temp directory.</DIV>
<DIV> </DIV>
<DIV>My goal was to keep the map file in memory when it is read from the url response, but I could not understand</DIV>
<DIV>the maplexer.c enough to change it (because I see that it is only written to read from files)</DIV>
<DIV> </DIV>
<DIV>What do you think of my approach, and how I should proceed for the virtual map file?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>--<BR>Andrew Arace<BR><A href="mailto:aarace at geonetics.com">aarace at geonetics.com</A><BR>Software Engineer<BR>Geonetics, Inc<BR>(617) 896 - 4409<BR><BR>>>> "Steve Lime" <steve.lime at dnr.state.mn.us> 2:22:11 PM Friday, December 19, 2003 >>><BR></DIV>
<DIV style="COLOR: #000000">Hi Andrew. The files maplexer.c and mapparser.c are generated<BR>automatically by the tools flex and bison respectively, and in turn are<BR>based on the configuration files maplexer.l and mapparser.y. I've never<BR>looked at the C source for those files, nor would I want to. Any changes<BR>made there would be lost anyway. Here's what each file is used for:<BR><BR> - maplexer.l contains regular expressions and C snippets to break a<BR>map file, certain CGI parameters and MapServer expressions into tokens.<BR>These tokens are then handed off to other sections of the code to be<BR>used. The lexer keeps track of where it is in a file or string and the<BR>function msyylex simply gets the next token. The C code generated by<BR>flex uses lots of global variables (and is not thread safe) to hold<BR>various pieces of information about a token such as it's string<BR>representation.<BR><BR> - mapparser.y defines the grammar, the rules, for MapServer logical<BR>expressions. It has nothing to do with parsing map files, only<BR>expressions. It's cryptic to look at but once you figure it out it's not<BR>bad. The grammar consists of things like setting operator precedance<BR>(i.e evaluate * before +) and sets the rules for doing things like<BR>adding 2 numbers, or comparing strings. The parser takes tokens from the<BR>lexer and input. There's a function called msyyparse that evaluates any<BR>particular string against the grammar.<BR><BR>Does this help?<BR><BR>Steve <BR><BR>>>> "Andrew Arace" <AArace at geonetics.com> 12/18/2003 4:59:28 PM >>><BR>I'm currently working on some modifications to the MapServer source<BR>code, and I've built the whole project in windows 2000, using the .NET<BR>IDE.<BR>I've got the exe, the necessary functions run great.<BR><BR>However, my current modifications require me to understand the<BR>maplexer.c and mapparser.c.<BR>I'm a pretty smart guy. But I'm a Unix noobie. (I know, some will<BR>think<BR>that's a contradiction...)<BR><BR>Anyway,
I have NO IDEA what is going on in those files. No clue.<BR>People<BR>have told me what yacc is, and bison, but I don't have a very good<BR>understanding, and these files are the root of all my confusion.<BR><BR>Basically, what are these used for. what is actually going on when the<BR>mapfile parser calls switch(msyylex()) {...} (mapfile.c,<BR>loadMapInternal())<BR><BR>What are the crazy int arrays in the maplexer? such as yy_accept[2174]<BR><BR>? What are the maplexer.l and mapparser.y files?<BR><BR>I'm just in need of a thorough explanation, please please? <BR><BR>Thanks very much in advance<BR><BR>--<BR>Andrew Arace<BR>aarace at geonetics.com <BR>Software Engineer<BR>Geonetics, Inc<BR>(617) 896 - 4409<BR><BR>Disclaimer Notice: This message contains confidential information and<BR>is intended only for the individual named. If you are not the named<BR>addressee you should not disseminate, distribute, or copy this e-mail.<BR>Please notify the sender immediately if you have received this e-mail by<BR>mistake and delete this e-mail from your system. E-mail transmission<BR>cannot be guaranteed to be secure or error free as information can be<BR>intercepted, corrupted, lost, destroyed, arrive late or incomplete, or<BR>contain viruses. The sender therefore does not accept liability for any<BR>errors or omissions in the contents of this message, which arise as a<BR>result of e-mail transmission. If verification is required please<BR>request a hard copy version. BSC Companies, Inc.; BSC Group, Inc.;<BR>Geonetics, Inc. 15 Elkins Street Boston, Massachusetts 02127 USA.<BR><A href="http://www.BSCGroup.com.">www.BSCGroup.com.</A> <BR><A href="http://www.bscgroup.com/">http://www.bscgroup.com/</A><BR></DIV>
<style>
<!--
/* Font Definitions */
@font-face
{font-family:"Berkeley Book";
panose-1:0 0 0 0 0 0 0 0 0 0;
mso-font-charset:0;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:3 0 0 0 1 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;
text-underline:single;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;
mso-header-margin:.5in;
mso-footer-margin:.5in;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
</style>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:"Berkeley Book"'><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>
<table border=1 cellspacing=0 cellpadding=0 align=left style='border-collapse:
collapse;border:none;mso-border-alt:double gray 2.25pt;mso-table-lspace:9.0pt;
mso-table-rspace:9.0pt;mso-table-anchor-vertical:paragraph;mso-table-anchor-horizontal:
page;mso-table-left:1.95in;mso-table-top:50.3pt;mso-padding-alt:0in 5.4pt 0in 5.4pt'>
<tr style='height:85.85pt'>
<td width=734 valign=top style='width:550.45pt;border:double gray 2.25pt;
padding:0in 5.4pt 0in 5.4pt;height:85.85pt'>
<p class=MsoNormal><b><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:"Berkeley Book"'><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></b></p>
<p class=MsoNormal><b><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:"Berkeley Book"'>Disclaimer Notice:</span></b><span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Berkeley Book"'>
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.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:"Berkeley Book"'><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:"Berkeley Book"'>BSC Companies, Inc.; BSC Group, Inc.; Geonetics, Inc. 15 Elkins Street Boston,
Massachusetts 02127 USA. <a href="http://www.bscgroup.com/">www.BSCGroup.com</a>.<o:p></o:p></span></p>
<p class=MsoNormal style='mso-element:frame;mso-element-frame-width:225.0pt;
mso-element-frame-height:153.0pt;mso-element-frame-hspace:9.0pt;mso-element-wrap:
around;mso-element-anchor-vertical:paragraph;mso-element-anchor-horizontal:
page;mso-element-left:140.45pt;mso-element-top:50.3pt'><![if !supportEmptyParas]> <![endif]><span
style='font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:"Berkeley Book"'><o:p></o:p></span></p>
</td>
</tr>
</table>
<p class=MsoNormal><span style='font-size:10.0pt;mso-bidi-font-size:12.0pt;
font-family:"Berkeley Book"'><![if !supportEmptyParas]> <![endif]><o:p></o:p></span></p>
</BODY></HTML>
--=__Part6937B88E.1__=--
More information about the MapServer-users
mailing list