File: cpp-parser.html

package info (click to toggle)
synopsis 0.8.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 10,112 kB
  • ctags: 12,996
  • sloc: cpp: 34,254; ansic: 33,620; python: 10,975; sh: 7,261; xml: 6,369; makefile: 773; asm: 445
file content (19 lines) | stat: -rw-r--r-- 3,871 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Cpp Parser</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 Tutorial"><link rel="up" href="ch04.html" title="Chapter4.Processor design"><link rel="previous" href="idl-parser.html" title="IDL Parser"><link rel="next" href="cc-parser.html" title="C Parser"></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">Cpp Parser</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="idl-parser.html">Prev</a></td><th width="60%" align="center">Chapter4.Processor design</th><td width="20%" align="right"><a accesskey="n" href="cc-parser.html">Next</a></td></tr></table></div><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="cpp-parser"></a>Cpp Parser</h2></div></div><div></div></div><p>The Cpp parser preprocesses C and C++ files. As any normal preprocessor,
        it will generate a file suitable as input for a C or C++ parser, i.e. it 
        processes include and macro statements. However, it will store the encountered
        preprocessor directives in the AST for further analysis.</p><p>As the list of included files may grow rather large, there exist two mechanisms
        to restrict the number of files for which information is retained. The <span class="type">main_file_only</span>
        parameter is used to indicate that only the top-level file being parsed should be included.
        The <span class="type">base_path</span> parameter, on the other hand, will restrict the number files if
        <span class="type">main_file_only</span> is set to <span class="type">False</span>. In this case, the <span class="type">base_path</span>
        is used as a prefix, and only those file whose name starts with that prefix are marked as 
        <span class="type">main</span>.
      </p><p>For each included file, a <span class="type">SourceFile</span> object is created and added
        to the parent's <span class="type">Include</span> list. Further, all macro declarations, as well
        as macro calls, are recorded. While most useful in conjunction with the C and Cxx processors,
        these data can be of use stand-alone, too. For example consider a tool that reports file
        dependencies based on <span class="type">#include</span> statements. The Dot formatter (see <a href="dot-formatter.html" title="Dot Formatter">the section called &#8220;Dot Formatter&#8221;</a>)
        can generate a file dependency graph from the Cpp processor output alone:
      </p><div class="mediaobject"><img src="images/Files.png"></div><p>Particular care has been taken in order to emulate system compilers, as these
        all provide their own sets of macros, include paths, etc. Thus, the Cpp parser can
        be trained to understand these compiler-specific settings.</p><p>For details about the parameters see <a href="Cpp-Parser-ref.html" title="Synopsis.Parsers.Cpp.Parser">the section called &#8220;Synopsis.Parsers.Cpp.Parser&#8221;</a>.</p></div><div class="navfooter"><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="idl-parser.html">Prev</a></td><td width="20%" align="center"><a accesskey="u" href="ch04.html">Up</a></td><td width="40%" align="right"><a accesskey="n" href="cc-parser.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">IDL Parser</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">C Parser</td></tr></table></div></body></html>