diff mayachemtools/docs/modules/html/SimpleCalcParser.html @ 0:73ae111cf86f draft

Uploaded
author deepakjadmin
date Wed, 20 Jan 2016 11:55:01 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mayachemtools/docs/modules/html/SimpleCalcParser.html	Wed Jan 20 11:55:01 2016 -0500
@@ -0,0 +1,159 @@
+<html>
+<head>
+<title>MayaChemTools:Documentation:Parsers::SimpleCalcParser.pm</title>
+<meta http-equiv="content-type" content="text/html;charset=utf-8">
+<link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
+</head>
+<body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
+<br/>
+<center>
+<a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
+</center>
+<br/>
+<div class="DocNav">
+<table width="100%" border=0 cellpadding=0 cellspacing=2>
+<tr align="left" valign="top"><td width="33%" align="left"><a href="./Lexer.html" title="Lexer.html">Previous</a>&nbsp;&nbsp;<a href="./index.html" title="Table of Contents">TOC</a>&nbsp;&nbsp;<a href="./SimpleCalcYYLexer.html" title="SimpleCalcYYLexer.html">Next</a></td><td width="34%" align="middle"><strong>Parsers::SimpleCalcParser.pm</strong></td><td width="33%" align="right"><a href="././code/SimpleCalcParser.html" title="View source code">Code</a>&nbsp;|&nbsp;<a href="./../pdf/SimpleCalcParser.pdf" title="PDF US Letter Size">PDF</a>&nbsp;|&nbsp;<a href="./../pdfgreen/SimpleCalcParser.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a>&nbsp;|&nbsp;<a href="./../pdfa4/SimpleCalcParser.pdf" title="PDF A4 Size">PDFA4</a>&nbsp;|&nbsp;<a href="./../pdfa4green/SimpleCalcParser.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
+</table>
+</div>
+<p>
+</p>
+<h2>NAME</h2>
+<p>Parsers::SimpleCalcParser</p>
+<p>
+</p>
+<h2>SYNOPSIS</h2>
+<p>use Parsers::SimpleCalcParser ;</p>
+<p>use Parsers::SimpleCalcParser qw(:all);</p>
+<p>
+</p>
+<h2>DESCRIPTION</h2>
+<p><strong>Parsers::SimpleCalcParser</strong> class provides the following methods:</p>
+<p> <a href="#new">new</a>, <a href="#yyclearin">yyclearin</a>, <a href="#yyerrok">yyerrok</a>, <a href="#yyerror">yyerror</a>, <a href="#yyparse">yyparse</a>
+</p><p><strong>Parsers::SimpleCalcParse.yy</strong> parser grammer definition file implements a simple
+calculator and is provided to highlight usage of lexer capability available through
+<strong>Parsers::SimpleCalcYYLexer</strong>, which in turn uses <strong>Parsers::YYLexer</strong> and
+<strong>Parsers::Lexer</strong> classes to procide underlying lexer functionality.</p>
+<p>The parser package and token table files, <strong>Parsers::SimpleCalcParser.pm</strong> and
+<strong>SimpleCalcParser.tab.ph</strong>, are automatically generated from parser grammar definition
+file, <strong>Parsers::SimpleCalcParser.yy</strong>, using byacc available through perl-byacc1.8 modified
+with perl5-byacc-patches-0.5 for generation of object oriented parser:</p>
+<div class="OptionsBox">
+    byacc -l -P -d -b SimpleCalcParser SimpleCalcParser.yy
+<br/>    mv SimpleCalcParser.tab.pl SimpleCalcParser.pm</div>
+<p>
+</p>
+<h2>METHODS</h2>
+<dl>
+<dt><strong><a name="new" class="item"><strong>new</strong></a></strong></dt>
+<dd>
+<div class="OptionsBox">
+    $SimpleCalcParser = new Parsers::SimpleCalcParser($YYLex,
+                                \&amp;Parsers::SimpleCalcParser::yyerror);
+<br/>    $SimpleCalcParser = new Parsers::SimpleCalcParser($YYLex,
+                                \&amp;Parsers::SimpleCalcParser::yyerror, $Debug);</div>
+<p>Using specified <em>YYLex</em> <em>YYError</em> functions, <strong>new</strong> method generates a new
+<strong>SimpleCalcParser</strong> and returns a reference to newly created <strong>SimpleCalcYYParser</strong> object.</p>
+<p>Examples:</p>
+<div class="OptionsBox">
+    # Input string...
+<br/>    $InputText = &quot;3 + 4 +6\nx=3\ny=5\nx+y\nx+z\n&quot;;
+<br/>    $YYLexer = new Parsers::SimpleCalcYYLexer($InputText);
+<br/>    $YYLex = $YYLexer-&gt;GetYYLex();</div>
+<div class="OptionsBox">
+    $Debug = 0;
+<br/>    $SimpleCalcParser = new Parsers::SimpleCalcParser($YYLex,
+                               \&amp;Parsers::SimpleCalcParser::yyerror, $Debug);
+<br/>    $Value = $SimpleCalcParser-&gt;yyparse();
+<br/>    print &quot;Value = &quot; . (defined($Value) ? &quot;$Value&quot; : &quot;Undefined&quot;) . &quot;\n&quot;;</div>
+<div class="OptionsBox">
+    # Input file...
+<br/>    $InputFile = &quot;TestSimpleCalcParser.txt&quot;;
+<br/>    open INPUTFILE, &quot;$InputFile&quot; or die &quot;Couldn't open $InputFile: $!\n&quot;;</div>
+<div class="OptionsBox">
+    $YYLexer = new Parsers::SimpleCalcYYLexer(\*INPUTFILE);
+<br/>    $YYLex = $YYLexer-&gt;GetYYLex();</div>
+<div class="OptionsBox">
+    $Debug = 0;
+<br/>    $SimpleCalcParser = new Parsers::SimpleCalcParser($YYLex,
+                               \&amp;Parsers::SimpleCalcParser::yyerror, $Debug);
+<br/>    $Value = $SimpleCalcParser-&gt;yyparse();
+<br/>    print &quot;Value = &quot; . (defined($Value) ? &quot;$Value&quot; : &quot;Undefined&quot;) . &quot;\n&quot;;</div>
+<div class="OptionsBox">
+    close INPUTFILE;</div>
+<div class="OptionsBox">
+    # Input iterator...
+<br/>    $InputFile = &quot;TestSimpleCalcParser.txt&quot;;
+<br/>    open INPUTFILE, &quot;$InputFile&quot; or die &quot;Couldn't open $InputFile: $!\n&quot;;
+<br/>    $InputIterator = sub { return &lt;INPUTFILE&gt;; };</div>
+<div class="OptionsBox">
+    $YYLexer = new Parsers::SimpleCalcYYLexer($InputIterator);
+<br/>    $YYLex = $YYLexer-&gt;GetYYLex();</div>
+<div class="OptionsBox">
+    $Debug = 0;
+<br/>    $SimpleCalcParser = new Parsers::SimpleCalcParser($YYLex,
+                               \&amp;Parsers::SimpleCalcParser::yyerror, $Debug);
+<br/>    $Value = $SimpleCalcParser-&gt;yyparse();
+<br/>    print &quot;Value = &quot; . (defined($Value) ? &quot;$Value&quot; : &quot;Undefined&quot;) . &quot;\n&quot;;</div>
+<div class="OptionsBox">
+    close INPUTFILE;</div>
+</dd>
+<dt><strong><a name="yyclearin" class="item"><strong>yyclearin</strong></a></strong></dt>
+<dd>
+<div class="OptionsBox">
+    $SimpleCalcParser-&gt;yyclearin();</div>
+<p><strong>yyclearin</strong> method clears any previous look-ahead token after encountering a syntax error
+during parsing. It can be used after <strong>yyerrok</strong> in a grammer rule with the reserved word
+<strong>error</strong>.</p>
+</dd>
+<dt><strong><a name="yyerrok" class="item"><strong>yyerrok</strong></a></strong></dt>
+<dd>
+<div class="OptionsBox">
+    $SimpleCalcParser-&gt;yyerrok();</div>
+<p><strong>yyerrok</strong> method is used with the reserved word <strong>error</strong> in grammer rule to indcate
+error recovery is complete after encountering a syntax error during parsing.</p>
+</dd>
+<dt><strong><a name="yyerror" class="item"><strong>yyerror</strong></a></strong></dt>
+<dd>
+<div class="OptionsBox">
+    $SimpleCalcParser-&gt;yyerror();</div>
+<p><strong>yyerror</strong> function is provided for the caller to use during initialization of a parser. It
+is used by <strong>yyparse</strong> to print any error messages encountered during parsing of the
+input.</p>
+</dd>
+<dt><strong><a name="yyparse" class="item"><strong>yyparse</strong></a></strong></dt>
+<dd>
+<div class="OptionsBox">
+    $Value = $SimpleCalcParser-&gt;yyparse();</div>
+<p>Returns <em>Value</em> after parsing all the input from a input stream using specified
+grammer rules.</p>
+</dd>
+</dl>
+<p>
+</p>
+<h2>AUTHOR</h2>
+<p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
+<p>
+</p>
+<h2>SEE ALSO</h2>
+<p><a href="./Lexer.html">Lexer.pm</a>,&nbsp<a href="./YYLexer.html">YYLexer.pm</a>,&nbsp<a href="./SimpleCalcYYLexer.html">SimpleCalcYYLexer.pm</a>
+</p>
+<p>
+</p>
+<h2>COPYRIGHT</h2>
+<p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
+<p>This file is part of MayaChemTools.</p>
+<p>MayaChemTools is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 3 of the License, or (at your option)
+any later version.</p>
+<p>&nbsp</p><p>&nbsp</p><div class="DocNav">
+<table width="100%" border=0 cellpadding=0 cellspacing=2>
+<tr align="left" valign="top"><td width="33%" align="left"><a href="./Lexer.html" title="Lexer.html">Previous</a>&nbsp;&nbsp;<a href="./index.html" title="Table of Contents">TOC</a>&nbsp;&nbsp;<a href="./SimpleCalcYYLexer.html" title="SimpleCalcYYLexer.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>Parsers::SimpleCalcParser.pm</strong></td></tr>
+</table>
+</div>
+<br />
+<center>
+<img src="../../images/h2o2.png">
+</center>
+</body>
+</html>