<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Parsing Source-code</title><link rel="stylesheet" href="synopsis.css" type="text/css" /><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><link rel="start" href="index.html" title="Synopsis Tutorial" /><link rel="up" href="using.html" title="Chapter 2. Using the synopsis tool" /><link rel="prev" href="options.html" title="Option Handling" /><link rel="next" href="compiler-emulation.html" title="Emulating A Compiler" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Parsing Source-code</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="options.html">Prev</a> </td><th width="60%" align="center">Chapter 2. Using the synopsis tool</th><td width="20%" align="right"> <a accesskey="n" href="compiler-emulation.html">Next</a></td></tr></table></div><div class="section" lang="en" xml:lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="parsing"></a>Parsing Source-code</h2></div></div></div><p>Let's assume a simple header file, containing some declarations:</p><p> </p><pre class="programlisting">#ifndef Path_h_ #define Path_h_ //. A Vertex is a 2D point. struct Vertex { Vertex(double xx, double yy): x(xx), y(yy) {} double x; //.< the x coordinate double y; //.< the y coordinate }; //. Path is the basic abstraction //. used for drawing (curved) paths. class Path { public: virtual ~Path() {} //. Draw this path. virtual void draw() = 0; // temporarily commented out... // bool intersects(const Path &); private: }; #endif </pre><p> </p><p>Process this with </p><pre class="programlisting">synopsis -p Cxx -f HTML -o Paths Path.h</pre><p> to generate an html document in the directory specified using the <code class="option">-o</code> option, i.e. <code class="filename">Paths</code>. </p><p> The above represents the simplest way to use <span class="command"><strong>synopsis</strong></span>. A simple command is used to parse a source-file and to generate a document from it. The parser to be used is selected using the <code class="option">-p</code> option, and the formatter with the <code class="option">-f</code> option. </p><p>If no formatter is specified, synopsis dumps its <a class="link" href="ir.html" title="Internal Representations">internal representation</a> to the specified output file. Similarly, if no parser is specified, the input is interpreted as an IR dump. Thus, the processing can be split into multiple synopsis invocations.</p><p> Each processor (including parsers and formatters) provides a number of parameters that can be set from the command line. For example the Cxx parser has a parameter <code class="varname">base_path</code> to specify a prefix to be stripped off of file names as they are stored in synopsis' internal representation. Parser-specific options can be given that are passed through to the parser processor. To pass such an option, use the <code class="code">-Wp,</code> prefix. For example, to set the parser's <code class="varname">base_path</code> option, use </p><pre class="programlisting">synopsis -p Cxx -Wp,--base-path=<prefix> -f HTML -o Paths Path.h</pre><p> </p></div><div class="navfooter"><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="options.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="using.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="compiler-emulation.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Option Handling </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Emulating A Compiler</td></tr></table></div></body></html>