Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 1354

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>3 The Gump Parser Generator</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node2.html#chapter.scanner">&lt;&lt; Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="node8.html#appendix.notation">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="chapter.parser"><H1><A name="chapter.parser">3 The Gump Parser Generator</A></H1><P> <A name="label160"></A> This chapter describes the Gump Parser Generator. As for the Gump Scanner Generator described in the last chapter, its input consists of an Oz source with embedded parser specifications and the output are Oz class definitions. </P><DIV class="apropos"><P class="margin">Definitions</P><P> A <A name="label161"></A><EM>parser</EM> is a program that performs syntax analysis. This means that a stream of tokens<A name="label162"></A> is analyzed and a (unique) tree structure on the tokens in this stream is computed. The token classes are called <A name="label163"></A><EM>terminal symbols</EM>; additionally, new <A name="label164"></A><EM>nonterminal symbols</EM> are introduced in the specification. For each nonterminal, a set of rules is given which indicates sequences of symbols that may be replaced by this nonterminal. The token sequence is read from left to right and subsequences of symbols are replaced by nonterminal symbols according to the rules (which is called a <A name="label165"></A><EM>reduction</EM>). Either the result is a special nonterminal, a <EM class="noindex">start symbol</EM><A name="label166"></A>, or the input is erroneous and rejected. A result is constructed during the parse by executing user-specified <A name="label167"></A><EM>semantic actions</EM> each reduction. </P></DIV><P> This chapter first describes the basic concepts of the Gump Parser Generator by example in <A href="node6.html#section.parser.example">Section&nbsp;3.1</A>. <A href="node7.html#section.parser.reference">Section&nbsp;3.2</A> presents the more advanced concepts and a detailed definition of the specification language. </P><HR><UL class="toc"><LI><A href="node6.html#section.parser.example">3.1 Example</A><UL class="toc"><LI><A href="node6.html#label169">3.1.1 Writing a Parser Specification</A></LI><LI><A href="node6.html#label198">3.1.2 Invoking Gump</A></LI><LI><A href="node6.html#label206">3.1.3 Using the Generated Parser</A></LI></UL></LI></UL><UL class="toc"><LI><A href="node7.html#section.parser.reference">3.2 Reference</A><UL class="toc"><LI><A href="node7.html#section.parser.syntax">3.2.1 Syntax of the Parser Specification Language</A><UL class="toc"><LI><A href="node7.html#label214">Token Declarations</A></LI><LI><A href="node7.html#label227">Syntax Rules</A></LI><LI><A href="node7.html#label243">Definition of Production Templates</A></LI><LI><A href="node7.html#label249">Expansion of Production Templates</A></LI><LI><A href="node7.html#label250">Predefined Production Templates</A></LI><LI><A href="node7.html#label253">Assignment of Attribute Types</A></LI></UL></LI><LI><A href="node7.html#section.parser.params">3.2.2 Parameters to Parser Generation</A></LI><LI><A href="node7.html#section.parser.class">3.2.3 The Mixin Class <CODE>GumpParser<SPAN class="keyword">.</SPAN><SPAN class="string">'class'</SPAN></CODE></A></LI></UL></LI></UL></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node2.html#chapter.scanner">&lt;&lt; Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="node8.html#appendix.notation">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~kornstae/">Leif&nbsp;Kornstaedt</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>