<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Flex Bison C++ Example: src/driver.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul>
</div>
<h1>src/driver.h</h1><a href="driver_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// $Id: driver.h 17 2007-08-19 18:51:39Z tb $ </span>
<a name="l00004"></a>00004 <span class="comment"></span><span class="preprocessor">#ifndef EXAMPLE_DRIVER_H</span>
<a name="l00005"></a>00005 <span class="preprocessor"></span><span class="preprocessor">#define EXAMPLE_DRIVER_H</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span>
<a name="l00007"></a>00007 <span class="preprocessor">#include <string></span>
<a name="l00008"></a>00008 <span class="preprocessor">#include <vector></span>
<a name="l00009"></a>00009
<a name="l00010"></a>00010 <span class="comment">// forward declaration</span>
<a name="l00011"></a>00011 <span class="keyword">class </span><a class="code" href="classCalcContext.html" title="Calculator context used to save the parsed expressions.">CalcContext</a>;
<a name="l00012"></a>00012
<a name="l00015"></a>00015 <span class="keyword">namespace </span>example {
<a name="l00016"></a>00016
<a name="l00023"></a><a class="code" href="classexample_1_1Driver.html">00023</a> <span class="keyword">class </span><a class="code" href="classexample_1_1Driver.html" title="The Driver class brings together all components.">Driver</a>
<a name="l00024"></a>00024 {
<a name="l00025"></a>00025 <span class="keyword">public</span>:
<a name="l00027"></a>00027 <a class="code" href="classexample_1_1Driver.html#c7e62776c89658a2d2ff66761bed2a23" title="construct a new parser driver context">Driver</a>(<span class="keyword">class</span> <a class="code" href="classCalcContext.html" title="Calculator context used to save the parsed expressions.">CalcContext</a>& <a class="code" href="classexample_1_1Driver.html#95b70ba231e8b912fc638989ed977bcf" title="Reference to the calculator context filled during parsing of the expressions.">calc</a>);
<a name="l00028"></a>00028
<a name="l00030"></a><a class="code" href="classexample_1_1Driver.html#2bb8042bae70236f6c1aaa0b60d3b171">00030</a> <span class="keywordtype">bool</span> <a class="code" href="classexample_1_1Driver.html#2bb8042bae70236f6c1aaa0b60d3b171" title="enable debug output in the flex scanner">trace_scanning</a>;
<a name="l00031"></a>00031
<a name="l00033"></a><a class="code" href="classexample_1_1Driver.html#680f62dafcd90219e3b943b9f89a7e5a">00033</a> <span class="keywordtype">bool</span> <a class="code" href="classexample_1_1Driver.html#680f62dafcd90219e3b943b9f89a7e5a" title="enable debug output in the bison parser">trace_parsing</a>;
<a name="l00034"></a>00034
<a name="l00036"></a><a class="code" href="classexample_1_1Driver.html#fc2dff95d108322cd7032d192c0a8f92">00036</a> std::string <a class="code" href="classexample_1_1Driver.html#fc2dff95d108322cd7032d192c0a8f92" title="stream name (file or input stream) used for error messages.">streamname</a>;
<a name="l00037"></a>00037
<a name="l00043"></a>00043 <span class="keywordtype">bool</span> <a class="code" href="classexample_1_1Driver.html#a02195b250993e74acceb0fdd5e04414" title="Invoke the scanner and parser for a stream.">parse_stream</a>(std::istream& in,
<a name="l00044"></a>00044 <span class="keyword">const</span> std::string& sname = <span class="stringliteral">"stream input"</span>);
<a name="l00045"></a>00045
<a name="l00051"></a>00051 <span class="keywordtype">bool</span> <a class="code" href="classexample_1_1Driver.html#34d3f98359759bd7dbec2ae9cf14ca6f" title="Invoke the scanner and parser on an input string.">parse_string</a>(<span class="keyword">const</span> std::string& input,
<a name="l00052"></a>00052 <span class="keyword">const</span> std::string& sname = <span class="stringliteral">"string stream"</span>);
<a name="l00053"></a>00053
<a name="l00059"></a>00059 <span class="keywordtype">bool</span> <a class="code" href="classexample_1_1Driver.html#ffea06783586d2253a4231e89cfd1ff7" title="Invoke the scanner and parser on a file.">parse_file</a>(<span class="keyword">const</span> std::string& filename);
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">// To demonstrate pure handling of parse errors, instead of</span>
<a name="l00062"></a>00062 <span class="comment">// simply dumping them on the standard error output, we will pass</span>
<a name="l00063"></a>00063 <span class="comment">// them to the driver using the following two member functions.</span>
<a name="l00064"></a>00064
<a name="l00067"></a>00067 <span class="keywordtype">void</span> <a class="code" href="classexample_1_1Driver.html#e86d346bd0baa8e13222f5c38a13623d" title="Error handling with associated line number.">error</a>(<span class="keyword">const</span> <span class="keyword">class</span> <a class="code" href="classexample_1_1location.html" title="Abstract a location.">location</a>& l, <span class="keyword">const</span> std::string& m);
<a name="l00068"></a>00068
<a name="l00071"></a>00071 <span class="keywordtype">void</span> <a class="code" href="classexample_1_1Driver.html#e86d346bd0baa8e13222f5c38a13623d" title="Error handling with associated line number.">error</a>(<span class="keyword">const</span> std::string& m);
<a name="l00072"></a>00072
<a name="l00075"></a><a class="code" href="classexample_1_1Driver.html#986f4e13999e2f328041740d3ca6e4c2">00075</a> <span class="keyword">class </span><a class="code" href="classexample_1_1Scanner.html" title="Scanner is a derived class to add some extra function to the scanner class.">Scanner</a>* <a class="code" href="classexample_1_1Driver.html#986f4e13999e2f328041740d3ca6e4c2" title="Pointer to the current lexer instance, this is used to connect the parser to the...">lexer</a>;
<a name="l00076"></a>00076
<a name="l00079"></a><a class="code" href="classexample_1_1Driver.html#95b70ba231e8b912fc638989ed977bcf">00079</a> <span class="keyword">class </span><a class="code" href="classCalcContext.html" title="Calculator context used to save the parsed expressions.">CalcContext</a>& calc;
<a name="l00080"></a>00080 };
<a name="l00081"></a>00081
<a name="l00082"></a>00082 } <span class="comment">// namespace example</span>
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="preprocessor">#endif // EXAMPLE_DRIVER_H</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat Sep 5 10:26:25 2009 for Flex Bison C++ Example by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>