1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter3.The C++ API</title><link rel="stylesheet" href="synopsis.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="Synopsis Developer's Guide"><link rel="up" href="index.html" title="Synopsis Developer's Guide"><link rel="previous" href="python-tests.html" title="Python Regression Tests"><link rel="next" href="ptree.html" title="The Parse Tree Module"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter3.The C++ API</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="python-tests.html">Prev</a></td><th width="60%" align="center"></th><td width="20%" align="right"><a accesskey="n" href="ptree.html">Next</a></td></tr></table></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="cxx"></a>Chapter3.The C++ API</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ptree.html">The Parse Tree Module</a></span></dt><dd><dl><dt><span class="section"><a href="ptree.html#encoding">The Encoding class</a></span></dt><dt><span class="section"><a href="ptree.html#ptree-display">PTree::Display</a></span></dt></dl></dd><dt><span class="section"><a href="symbol-lookup.html">The Symbol Lookup Module</a></span></dt><dd><dl><dt><span class="section"><a href="symbol-lookup.html#symbol-display">SymbolLookup::Display</a></span></dt></dl></dd><dt><span class="section"><a href="cxx-tests.html">C++ Regression Tests</a></span></dt></dl></div><p>
The Parser operates on an in-memory buffer of the whole (preprocessed) file.
The generated parse tree refers to memory locations in that buffer, and it
is possible to replace existing tree nodes by new ones, and then writing the
modified buffer back to a file, preserving all but the modified regions.
</p><p>
This feature makes this parser an excellent choice for source-to-source
transformation, as the new code doesn't need to be generated from scratch,
but instead will preserve all features from the original file that the user
didn't explicitely modify.
</p><p>
Parsing a source file involves a number of classes, such as <span class="type">Buffer</span>,
<span class="type">Lexer</span>, <span class="type">Parser</span>, and <span class="type">SymbolFactory</span>. These
can be constructed with a number of parameters, to control the specific language /
language dialect (C, C++, GNU extensions, MSVC extensions, etc.).
</p><div class="mediaobject"><img src="images/cxx-parser.png"></div></div><div class="navfooter"><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="python-tests.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="ptree.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Python Regression Tests</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">The Parse Tree Module</td></tr></table></div></body></html>
|