Mercurial > repos > deepakjadmin > mayatool3_test3
diff mayachemtools/docs/modules/html/SimpleCalcYYLexer.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/SimpleCalcYYLexer.html Wed Jan 20 11:55:01 2016 -0500 @@ -0,0 +1,146 @@ +<html> +<head> +<title>MayaChemTools:Documentation:Parsers::SimpleCalcYYLexer.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="./SimpleCalcParser.html" title="SimpleCalcParser.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./YYLexer.html" title="YYLexer.html">Next</a></td><td width="34%" align="middle"><strong>Parsers::SimpleCalcYYLexer.pm</strong></td><td width="33%" align="right"><a href="././code/SimpleCalcYYLexer.html" title="View source code">Code</a> | <a href="./../pdf/SimpleCalcYYLexer.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/SimpleCalcYYLexer.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/SimpleCalcYYLexer.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/SimpleCalcYYLexer.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr> +</table> +</div> +<p> +</p> +<h2>NAME</h2> +<p>Parsers::SimpleCalcYYLexer</p> +<p> +</p> +<h2>SYNOPSIS</h2> +<p>use Parsers::SimpleCalcYYLexer;</p> +<p>use Parsers::SimpleCalcYYLexer qw(:all);</p> +<p> +</p> +<h2>DESCRIPTION</h2> +<p><strong>SimpleCalcYYLexer</strong> class provides the following methods:</p> +<p> <a href="#new">new</a>, <a href="#yylex">YYLex</a>, <a href="#getyylex">GetYYLex</a>, <a href="#stringifysimplecalcyylexer">StringifySimpleCalcYYLexer</a> +</p><p><strong>Parser::SimpleCalcYYLexer</strong> class is derived from <strong>Parser::YYLexer</strong> class, which in +turn is derived from base class <strong>Parser::Lexer</strong> that provides all the underlying +lexer functionality. <strong>SimpleCalcYYLexer</strong> class is designed to be used with +<strong>yyparse</strong> code generated by running <strong>byacc</strong> on a parser defined using +parser definition <strong>SimpleCalcParser.yy</strong> file.</p> +<p>The parser package and token table files, <strong>SimpleCalcParser.pm</strong> and <strong>SimpleCalcParser.tab.ph</strong>, +are automatically generated from parser grammar definition file, <strong>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><strong>SimpleCalcYYLexer.pm</strong> class implements a lexer for a simple calculator and is provided +to highlight usasge of <strong>YYLex</strong> through <strong>yyparse</strong>.</p> +<p>The default specification of lexer tokens for <strong>SimpleCalcYYLexer.pm</strong> includes:</p> +<div class="OptionsBox"> + @YYLexerTokensSpec = ( +<br/> [ 'LETTER', qr/[a-zA-Z]/ ], + [ 'NUMBER', qr/\d+/ ], + [ 'SPACE', qr/[ ]*/, +<br/> sub { my($This, $TokenLabel, $MatchedText) = @_; return ''; } +<br/> ], + [ 'NEWLINE', qr/(?:\r\n|\r|\n)/, +<br/> sub { my($This, $TokenLabel, $MatchedText) = @_; return "\n"; } +<br/> ], + [ 'CHAR', qr/./ ] +<br/> );</div> +<p>The default <strong>SimpleCalcParser.tab.ph</strong> file containing token identifiers for +<strong>SimpleCalcParser.yy</strong> includes:</p> +<div class="OptionsBox"> + $NUMBER=257; +<br/> $LETTER=258;</div> +<p> +</p> +<h2>METHODS</h2> +<dl> +<dt><strong><a name="new" class="item"><strong>new</strong></a></strong></dt> +<dd> +<div class="OptionsBox"> + $SimpleCalcYYLexer = new Parsers::SimpleCalcYYLexer($Input);</div> +<p>Using specified <em>Input</em>, <strong>new</strong> method generates a new <strong>SimpleCalcYYLexer</strong> +and returns a reference to newly created <strong>SimpleCalcYYLexer</strong> object.</p> +<p>Examples:</p> +<div class="OptionsBox"> + # Input string... +<br/> $InputText = "3 + 4 +6\nx=3\ny=5\nx+y\nx+z\n";</div> +<div class="OptionsBox"> + $YYLexer = new Parsers::SimpleCalcYYLexer($InputText); +<br/> $YYLex = $YYLexer->GetYYLex();</div> +<div class="OptionsBox"> + $Debug = 0; +<br/> $CalcParser = new Parsers::SimpleCalcParser($YYLex, + \&Parsers::SimpleCalcParser::yyerror, $Debug); +<br/> $Value = $SimpleCalcParser->yyparse(); +<br/> print "Value: $Value\n";</div> +<div class="OptionsBox"> + # Input file... +<br/> $InputFile = "Input.txt"; +<br/> open INPUTFILE, "$InputFile" or die "Couldn't open $InputFile: $!\n"; +<br/> $YYLexer = new Parsers::SimpleCalcYYLexer($InputFile); +<br/> $YYLex = $YYLexer->GetYYLex();</div> +<div class="OptionsBox"> + $CalcParser = new Parsers::SimpleCalcParser($YYLex, + \&Parsers::SimpleCalcParser::yyerror); +<br/> $Value = $SimpleCalcParser->yyparse(); +<br/> print "Value: $Value\n";</div> +<div class="OptionsBox"> + # Input file iterator... +<br/> $InputFile = "TestSimpleCalcParser.txt"; +<br/> open INPUTFILE, "$InputFile" or die "Couldn't open $InputFile: $!\n"; +<br/> $InputIterator = sub { return <INPUTFILE>; }; +<br/> $YYLexer = new Parsers::SimpleCalcYYLexer($InputIterator); +<br/> $YYLex = $YYLexer->GetYYLex();</div> +<div class="OptionsBox"> + $CalcParser = new Parsers::SimpleCalcParser($YYLex, + \&Parsers::SimpleCalcParser::yyerror); +<br/> $Value = $SimpleCalcParser->yyparse(); +<br/> print "Value: $Value\n";</div> +</dd> +<dt><strong><a name="stringifysimplecalcyylexer" class="item"><strong>StringifySimpleCalcYYLexer</strong></a></strong></dt> +<dd> +<div class="OptionsBox"> + $YYLexerString = $YYLexer->StringifySimpleCalcYYLexer();</div> +<p>Returns a string containing information about <em>YYLexer</em> object.</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>, <a href="./YYLexer.html">YYLexer.pm</a>, <a href="./SimpleCalcParser.html">SimpleCalcParser.yy</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> </p><p> </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="./SimpleCalcParser.html" title="SimpleCalcParser.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./YYLexer.html" title="YYLexer.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>Parsers::SimpleCalcYYLexer.pm</strong></td></tr> +</table> +</div> +<br /> +<center> +<img src="../../images/h2o2.png"> +</center> +</body> +</html>