srcML v1.0.0 C Documentation

Base Elements XML Element Subelements
comment <comment type="block|line" format="javadoc|doxygen">
escape <escape char="0xXX">
literal <literal type="number|char|string">
name <name> <name>, <operator>
Statements XML Element Subelements
block <block> <block_content>
break statement <break>
case statement <case> <expr>
continue statement <continue>
default statement <default>
do while statement <do> <block> <condition>
empty statement <empty_stmt>
expr_stmt <expr_stmt> <expr>
for statement <for> <control> <block>
goto statement <goto> <name>
if statement <if_stmt> <if> <else> <if type="elseif">
label <label> <name>
return statement <return> <expr>
switch statement <switch> <condition> <case> <block>
while statement <while> <condition> <block>
Statement Subelements XML Element Subelements
block_content <block_content>
condition <condition> <expr>
control <control> <init> <condition> <incr>
else <else> <block>
else if <else type="elsif> <condition> <block>
expression <expr> <name>, <operator>, <call>, <ternary>
if <if> <condition> <block>
incr <incr> <expr>
then <then> <expr>
type <type> <specifier>, <name>
Specifiers XML Element Subelements
const <specifier>
extern block <extern> <literal>, <function_decl>, <decl_stmt>, <block>
extern specifier <specifier>
inline <specifier>
register <specifier>
restrict <specifier>
static <specifier>
volatile <specifier>
Declarations, Definitions, and Initializations XML Element Subelements
array declaration <decl> <name>, <index>
array initialization <init> <block>
bitfield <range> <expr>
function declaration <function_decl> <type> <name> <parameter_list>
function definition <function> <type> <name> <parameter_list> <block>
pointer declaration <modifier>
typedef <typedef> <type> <name> <function_decl>
variable declaration <decl> <name> <init>
variable declaration statement <decl_stmt> <decl>
Structs, Unions, and Enums XML Element Subelements
enum declaration <enum_decl> <name>
enum definition <enum> <name> <block>
struct declaration <struct_decl> <name>
struct definition <struct> <name> <block>
struct initialization <decl_stmt> <decl>, <init>, <block>
union declaration <union_decl> <name>
union definition <union> <name> <block>
Expressions XML Element Subelements
array index <index> <expr>
dereference member access <expr> <name>, <operator>
function call <call> <name> <argument_list>
member access <expr> <name>, <operator>
ternary operator <ternary> <condition> <then> <else>
Other XML Element Subelements
_Alignas <alignas> <argument_list>
_Alignof <alignof> <argument_list>
_Atomic <atomic> <argument_list>
_Generic <generic_selection> <selector>, <association_list>
_Noreturn <specifier>
_Static_assert <assert type="static"> <argument_list>
_Thread_local <specifier>
asm <asm>
association <association> <type>, <expr>
association_list <association_list> <association>
selector <selector> <expr>
sizeof <sizeof> <argument_list>, <name>
OpenMP XML Element Subelements
omp:argument <omp:argument> <omp:expr>
omp:argument_list <omp:argument_list> <omp:argument>
omp:clause <omp:clause> <omp:name> <omp:argument_list>
omp:directive <omp:directive> <omp:name> <omp:clause>
omp:expr <omp:expr>
omp:name <omp:name>

_Alignof


Element

  • <alignof>

Subelement

  • <argument_list>

XPath Query

  • uses of _Alignof

    //src:alignof

Example

_Alignof(union type);
<expr_stmt><expr><alignof>_Alignof<argument_list>(<argument><expr>union <name>type</name></expr></argument>)</argument_list></alignof></expr>;</expr_stmt>

_Static_assert


Element

  • <assert type="static">

Subelement

  • <argument_list>

XPath Query

  • uses of _Static_assert

    //src:assert[src:type ='static']

Example

_Static_assert(DEBUG_LEVEL > 5, "Message");
<assert type="static">_Static_assert<argument_list>(<argument><expr><name>DEBUG_LEVEL</name> <operator>&gt;</operator> <literal type="number">5</literal></expr></argument>, <argument><expr><literal type="string">"Message"</literal></expr></argument>)</argument_list>;</assert>

_Thread_local


Element

  • <specifier>

XPath Query

  • uses of _Thread_local

    //src:specifier[.='_Thread_local']

Example

_Thread_local int x;
<decl_stmt><decl><type><specifier>_Thread_local</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>

asm


Element

  • <asm>

XPath Query

  • uses of asm

    //src:asm

Examples

asm("movl %ebx, %eax");
<asm>asm("movl %ebx, %eax");</asm>
__asm__("movl %ebx, %eax");
<asm>__asm__("movl %ebx, %eax");</asm>
__asm { __asm mov al, 2  __asm mov dx, 0xD007 __asm out dx, al }
<asm>__asm { <asm>__asm mov al, 2</asm>  <asm>__asm mov dx, 0xD007</asm> <asm>__asm out dx, al</asm> }</asm>

bitfield


Element

  • <range>

Subelement

  • <expr>

XPath Query

  • bitfield declarations

    //src:decl[src:range]

Example

struct mybitfields
{
    int a : 5;
} test;
<struct>struct <name>mybitfields</name>
<block>{
    <decl_stmt><decl><type><name>int</name></type> <name>a</name> <range>: <expr><literal type="number">5</literal></expr></range></decl>;</decl_stmt>
}</block> <decl><name>test</name></decl>;</struct>

block


Element

  • <block>

Subelement

  • <block_content>

XPath Queries

  • blocks

    //src:block
  • variable declarations in a block

    //src:block//src:decl_stmt
  • top-level variable declarations in a block

    //src:block/src:block_content/src:decl_stmt

Example

 {
    line[i] = x;
    x++;
    i--;
}
 <block>{<block_content>
    <expr_stmt><expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>=</operator> <name>x</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>x</name><operator>++</operator></expr>;</expr_stmt>
    <expr_stmt><expr><name>i</name><operator>--</operator></expr>;</expr_stmt>
</block_content>}</block>

block_content


Element

  • <block_content>

XPath Queries

  • block contents

    //src:block_content
  • declaration block_contents

    //src:decl/src:block/src:block_content
  • function block_contents

    //src:function/src:block/src:block_content

case statement


Element

  • <case>

Subelement

  • <expr>

XPath Queries

  • case labels

    //src:case
  • case labels that use SATURDAY

    //src:case[.//src:name = 'SATURDAY']
  • switch statements with a case that uses SATURDAY

    //src:switch[src:block/src:block_content/src:case//src:name='SATURDAY']

Example

case SATURDAY:
<case>case <expr><name>SATURDAY</name></expr>:</case>

comment


Element

  • <comment type="block|line" format="javadoc|doxygen">

XPath Queries

  • comments

    //src:comment
  • block comments

    //src:comment[@type='block']
  • line comments

    //src:comment[@type='line']
  • javadoc comments

    //src:comment[@format='javadoc']
  • doxygen comments

    //src:comment[@format='doxygen']
  • line Javadoc comments

    //src:comment[@type='line'][@format='javadoc']

condition


Element

  • <condition>

Subelement

  • <expr>

XPath Queries

  • conditions, including ternary conditions

    //src:condition
  • condition expressions

    //src:condition/src:expr
  • if conditions

    //src:if/src:condition
  • while conditions

    //src:while/src:condition
  • do while conditions

    //src:do/src:condition
  • ternary conditions

    //src:do/src:condition

const


Element

  • <specifier>

XPath Queries

  • const variables

    //src:decl[src:type/src:specifier='const']
  • const function declarations

    //src:function_decl[src:specifier='const']
  • function declarations with a const return type

    //src:function_decl[src:type/src:specifier='const']

Examples

const int x;
const X y;
<decl_stmt><decl><type><specifier>const</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>
<decl_stmt><decl><type><specifier>const</specifier> <name>X</name></type> <name>y</name></decl>;</decl_stmt>
int const x;
X const y;
<decl_stmt><decl><type><name>int</name> <specifier>const</specifier></type> <name>x</name></decl>;</decl_stmt>
<decl_stmt><decl><type><name>X</name> <specifier>const</specifier></type> <name>y</name></decl>;</decl_stmt>

control


Element

  • <control>

Subelements

  • <init>
  • <condition>
  • <incr>

XPath Query

  • initialization, condition, and increment of for loops

    //src:control

default statement


Element

  • <default>

XPath Queries

  • default labels

    //src:default
  • switch statements with a default label

    //src:switch[src:block/src:block_content/src:default]

Example

default:
<default>default:</default>

dereference member access


Element

  • <expr>

Subelements

  • <name>
  • <operator>

XPath Query

  • uses of the -> operator

    //src:operator[.='->']

Example

 t->tm_sec;
 <expr_stmt><expr><name><name>t</name><operator>-&gt;</operator><name>tm_sec</name></name></expr>;</expr_stmt>

else


Element

  • <else>

Subelement

  • <block>

XPath Query

  • all elses

    //src:else

else if


Element

  • <else type="elsif>

Subelements

  • <condition>
  • <block>

XPath Query

  • all else ifs

    //src:else[type="elsif"]

empty statement


Element

  • <empty_stmt>

XPath Query

  • empty statements

    //src:empty_stmt

Example

;
<empty_stmt>;</empty_stmt>

enum declaration


Element

  • <enum_decl>

Subelement

  • <name>

XPath Query

  • enum declarations

    //src:enum_decl

Example

enum DAY;
<enum_decl>enum <name>DAY</name>;</enum_decl>

enum definition


Element

  • <enum>

Subelements

  • <name>
  • <block>

XPath Queries

  • enum definitions

    //src:enum
  • names of members of enums

    //src:enum/src:block/src:decl/src:name

Examples

enum DAY {
    sunday = 0,
    monday,
    tuesday,
    wednesday,
    thursday,
    friday,
    saturday,
};
<enum>enum <name>DAY</name> <block>{
    <decl><name>sunday</name> <init>= <expr><literal type="number">0</literal></expr></init></decl>,
    <decl><name>monday</name></decl>,
    <decl><name>tuesday</name></decl>,
    <decl><name>wednesday</name></decl>,
    <decl><name>thursday</name></decl>,
    <decl><name>friday</name></decl>,
    <decl><name>saturday</name></decl>,
}</block>;</enum>
enum { yes, no } response;
<enum>enum <block>{ <decl><name>yes</name></decl>, <decl><name>no</name></decl> }</block> <decl><name>response</name></decl>;</enum>

escape


Element

  • <escape char="0xXX">

expr_stmt


Element

  • <expr_stmt>

Subelement

  • <expr>

expression


Element

  • <expr>

Subelements

  • <name>
  • <operator>
  • <call>
  • <ternary>

XPath Query

  • expressions

    //src:expr

extern block


Element

  • <extern>

Subelements

  • <literal>
  • <function_decl>
  • <decl_stmt>
  • <block>

XPath Query

  • extern blocks

    //src:extern

Examples

extern function with linkage specifier

extern "C" void foo();
<extern>extern <literal type="string">"C"</literal> <function_decl><type><name>void</name></type> <name>foo</name><parameter_list>()</parameter_list>;</function_decl></extern>

extern structure with linkage specifier

extern "C" struct Z X;
<extern>extern <literal type="string">"C"</literal> <decl_stmt><decl><type><name><name>struct</name> <name>Z</name></name></type> <name>X</name></decl>;</decl_stmt></extern>

extern variable with linkage specifier

extern "C" int X;
<extern>extern <literal type="string">"C"</literal> <decl_stmt><decl><type><name>int</name></type> <name>X</name></decl>;</decl_stmt></extern>

extern block with linkage specifier

extern "C" { }
<extern>extern <literal type="string">"C"</literal> <block>{<block_content> </block_content>}</block></extern>

extern specifier


Element

  • <specifier>

XPath Queries

  • extern variables

    //src:decl[src:type/src:specifier='extern']
  • extern function declarations

    //src:function_decl[src:type/src:specifier='extern']

Examples

external variable

extern int X;
<decl_stmt><decl><type><specifier>extern</specifier> <name>int</name></type> <name>X</name></decl>;</decl_stmt>

external structure

extern struct Z X;
<decl_stmt><decl><type><specifier>extern</specifier> <name><name>struct</name> <name>Z</name></name></type> <name>X</name></decl>;</decl_stmt>

external function

extern void foo();
<function_decl><type><specifier>extern</specifier> <name>void</name></type> <name>foo</name><parameter_list>()</parameter_list>;</function_decl>

for statement


Element

  • <for>

Subelements

  • <control>
  • <block>

XPath Queries

  • for loops

    //src:for
  • for-loop initialization statements

    //src:for/src:control/src:init
  • for-loop conditions

    //src:for/src:control/src:condition
  • for-loop increments

    //src:for/src:control/src:incr
  • for loops that declare a variable with a single character name (e.g. x, i or y)

    //src:for[string-length(src:control/src:init/src:decl/src:name) = 1]
  • for loops with post-increment in the increment expression

    //src:for[src:control/src:incr/src:expr//following-sibling::src:operator= '++']

Examples

for( ;; ) { }
<for>for<control>( <init>;</init><condition>;</condition> <incr/>)</control> <block>{<block_content> </block_content>}</block></for>
for (i = 0; i < max; i++ ) 
{
  if ( line[i] == ' ' )
  {
      space++;
  }
  if ( line[i] == '\t' )
  {
      tab++;
  }
}
<for>for <control>(<init><expr><name>i</name> <operator>=</operator> <literal type="number">0</literal></expr>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <name>max</name></expr>;</condition> <incr><expr><name>i</name><operator>++</operator></expr></incr> )</control> 
<block>{<block_content>
  <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">' '</literal></expr> )</condition>
  <block>{<block_content>
      <expr_stmt><expr><name>space</name><operator>++</operator></expr>;</expr_stmt>
  </block_content>}</block></if></if_stmt>
  <if_stmt><if>if <condition>( <expr><name><name>line</name><index>[<expr><name>i</name></expr>]</index></name> <operator>==</operator> <literal type="char">'\t'</literal></expr> )</condition>
  <block>{<block_content>
      <expr_stmt><expr><name>tab</name><operator>++</operator></expr>;</expr_stmt>
  </block_content>}</block></if></if_stmt>
</block_content>}</block></for>
for(int i =0; i < 10;++i)
	a += x[i];
<for>for<control>(<init><decl><type><name>int</name></type> <name>i</name> <init>=<expr><literal type="number">0</literal></expr></init></decl>;</init> <condition><expr><name>i</name> <operator>&lt;</operator> <literal type="number">10</literal></expr>;</condition><incr><expr><operator>++</operator><name>i</name></expr></incr>)</control><block type="pseudo"><block_content>
	<expr_stmt><expr><name>a</name> <operator>+=</operator> <name><name>x</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt></block_content></block></for>

function call


Element

  • <call>

Subelements

  • <name>
  • <argument_list>

XPath Query

  • function calls

    //src:call

Example

typical function call

foo(x, y, z);
<expr_stmt><expr><call><name>foo</name><argument_list>(<argument><expr><name>x</name></expr></argument>, <argument><expr><name>y</name></expr></argument>, <argument><expr><name>z</name></expr></argument>)</argument_list></call></expr>;</expr_stmt>

function declaration


Element

  • <function_decl>

Subelements

  • <type>
  • <name>
  • <parameter_list>

XPath Queries

  • function declarations

    //src:function_decl
  • function-declaration return types

    //src:function_decl/src:type
  • function-declaration parameters

    //src:function_decl/src:parameter_list/src:parameter
  • function declarations with only two parameters

    //src:function_decl[count(src:parameter_list/src:parameter) = 2]
  • function declaration names

    //src:function_decl/src:name
  • function declarations that have variadic arguments

    //src:function_decl[src:parameter_list/src:parameter/src:decl/src:type/src:modifier='...']

Examples

struct STUDENT sortstu( STUDENT a, STUDENT b );
void print(STUDENT a);
<function_decl><type><name><name>struct</name> <name>STUDENT</name></name></type> <name>sortstu</name><parameter_list>( <parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>, <parameter><decl><type><name>STUDENT</name></type> <name>b</name></decl></parameter> )</parameter_list>;</function_decl>
<function_decl><type><name>void</name></type> <name>print</name><parameter_list>(<parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>)</parameter_list>;</function_decl>
void foo (int a[]);
<function_decl><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name><name>a</name><index>[]</index></name></decl></parameter>)</parameter_list>;</function_decl>
void foo (int* a);
<function_decl><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>a</name></decl></parameter>)</parameter_list>;</function_decl>
int add_multiple_values (int number, ...);
<function_decl><type><name>int</name></type> <name>add_multiple_values</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name>number</name></decl></parameter>, <parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list>;</function_decl>
int func(a, b, c)
   int a;
   int b;
   int c;
{ }
<function><type><name>int</name></type> <name>func</name><parameter_list>(<parameter><decl><type><name>a</name></type></decl></parameter>, <parameter><decl><type><name>b</name></type></decl></parameter>, <parameter><decl><type><name>c</name></type></decl></parameter>)</parameter_list>
   <decl_stmt><decl><type><name>int</name></type> <name>a</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>b</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>c</name></decl>;</decl_stmt>
<block>{<block_content> </block_content>}</block></function>

function definition


Element

  • <function>

Subelements

  • <type>
  • <name>
  • <parameter_list>
  • <block>

XPath Queries

  • function definitions

    //src:function
  • function-definition return types

    //src:function/src:type
  • function-definition parameters

    //src:function/src:parameter_list/src:parameter
  • function definitions with only two parameters

    //src:function[count(src:parameter_list/src:parameter) = 2]
  • function-definition names

    //src:function/src:name
  • function definitions that have variadic arguments

    //src:function[src:parameter_list/src:parameter/src:decl/src:type/src:modifier='...']
  • K & R function definitions

    //src:function[src:decl_stmt]

Examples

struct STUDENT sortstu( STUDENT a, STUDENT b ) {
    struct STUDENT x;
    return x;
}
<function><type><name><name>struct</name> <name>STUDENT</name></name></type> <name>sortstu</name><parameter_list>( <parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>, <parameter><decl><type><name>STUDENT</name></type> <name>b</name></decl></parameter> )</parameter_list> <block>{<block_content>
    <decl_stmt><decl><type><name><name>struct</name> <name>STUDENT</name></name></type> <name>x</name></decl>;</decl_stmt>
    <return>return <expr><name>x</name></expr>;</return>
</block_content>}</block></function>
void print(STUDENT a) { }
<function><type><name>void</name></type> <name>print</name><parameter_list>(<parameter><decl><type><name>STUDENT</name></type> <name>a</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
void foo (int a[]) { } 
<function><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name><name>a</name><index>[]</index></name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function> 
void foo (int* a) { }
<function><type><name>void</name></type> <name>foo</name> <parameter_list>(<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>a</name></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
int add_multiple_values (int number, ...) { }
<function><type><name>int</name></type> <name>add_multiple_values</name> <parameter_list>(<parameter><decl><type><name>int</name></type> <name>number</name></decl></parameter>, <parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list> <block>{<block_content> </block_content>}</block></function>
int func(a, b, c)
   int a;
   int b;
   int c;
{ }
<function><type><name>int</name></type> <name>func</name><parameter_list>(<parameter><decl><type><name>a</name></type></decl></parameter>, <parameter><decl><type><name>b</name></type></decl></parameter>, <parameter><decl><type><name>c</name></type></decl></parameter>)</parameter_list>
   <decl_stmt><decl><type><name>int</name></type> <name>a</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>b</name></decl>;</decl_stmt>
   <decl_stmt><decl><type><name>int</name></type> <name>c</name></decl>;</decl_stmt>
<block>{<block_content> </block_content>}</block></function>

goto statement


Element

  • <goto>

Subelement

  • <name>

XPath Query

  • goto statements

    //src:goto

Example

goto stop;
<goto>goto <name>stop</name>;</goto>

if


Element

  • <if>

Subelements

  • <condition>
  • <block>

XPath Query

  • all ifs

    //src:if

if statement


Element

  • <if_stmt>

Subelements

  • <if>
  • <else>
  • <if type="elseif">

XPath Queries

  • if conditions

    //src:if/src:condition
  • then

    //src:if/src:block
  • else

    //src:else/src:block
  • if statements without an else

    //src:if_stmt[not(src:else)]
  • else-if

    //src:if[@type="elseif"]
  • First if in a nested if statement

    //src:if_stmt/src:if[1]
  • Second if in a nested if statement

    //src:if_stmt/src:if[2]
  • Last if in a nested if statement

    //src:if_stmt/src:if[last()]

Examples

if then

if (A)
    B;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if></if_stmt>

if then else

if (A)
    B;
else
    C;
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

if then elseif

if (A)
    B;
else if (A2)
    C;
else
    D:
<if_stmt><if>if <condition>(<expr><name>A</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>B</name></expr>;</expr_stmt></block_content></block></if>
<if type="elseif">else if <condition>(<expr><name>A2</name></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>C</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content>
    <label><name>D</name>:</label></block_content></block></else></if_stmt>
if(x > 5)
    y+=4;
<if_stmt><if>if<condition>(<expr><name>x</name> <operator>&gt;</operator> <literal type="number">5</literal></expr>)</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name><operator>+=</operator><literal type="number">4</literal></expr>;</expr_stmt></block_content></block></if></if_stmt>
if ( i > 0 ) {
    y = x / i;
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> <block>{<block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt>
</block_content>}</block></if></if_stmt>
if ( i > 0 )
    y = x / i;
else 
{
    x = i;
    y = f( x );
}
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <name>x</name> <operator>/</operator> <name>i</name></expr>;</expr_stmt></block_content></block></if>
<else>else 
<block>{<block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>
    <expr_stmt><expr><name>y</name> <operator>=</operator> <call><name>f</name><argument_list>( <argument><expr><name>x</name></expr></argument> )</argument_list></call></expr>;</expr_stmt>
</block_content>}</block></else></if_stmt>

Without braces

if ( i > 0 )
    if ( j > i )
        x = j;
    else
        x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition><block type="pseudo"><block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if>
    <else>else<block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt></block_content></block></if></if_stmt>

With braces

if ( i > 0 ) 
{
    if ( j > i )
        x = j;
}
else
    x = i;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
    <if_stmt><if>if <condition>( <expr><name>j</name> <operator>&gt;</operator> <name>i</name></expr> )</condition><block type="pseudo"><block_content>
        <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></if></if_stmt>
</block_content>}</block></if>
<else>else<block type="pseudo"><block_content>
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt></block_content></block></else></if_stmt>
if ( i > 0 ) 
{
 	x = i;   
}
else if( i < 0)
	x = q;
else 
    x = j;
<if_stmt><if>if <condition>( <expr><name>i</name> <operator>&gt;</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
 	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>i</name></expr>;</expr_stmt>   
</block_content>}</block></if>
<if type="elseif">else if<condition>( <expr><name>i</name> <operator>&lt;</operator> <literal type="number">0</literal></expr>)</condition><block type="pseudo"><block_content>
	<expr_stmt><expr><name>x</name> <operator>=</operator> <name>q</name></expr>;</expr_stmt></block_content></block></if>
<else>else<block type="pseudo"><block_content> 
    <expr_stmt><expr><name>x</name> <operator>=</operator> <name>j</name></expr>;</expr_stmt></block_content></block></else></if_stmt>

incr


Element

  • <incr>

Subelement

  • <expr>

XPath Query

  • increment of for loops

    //src:incr

inline


Element

  • <specifier>

XPath Queries

  • inline function declarations

    //src:function_decl[src:type/src:specifier='inline']
  • inline namespace declarations

    //src:namespace[src:specifier='inline']

Example

inline void swapValues(int* a,int* b);
<function_decl><type><specifier>inline</specifier> <name>void</name></type> <name>swapValues</name><parameter_list>(<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>a</name></decl></parameter>,<parameter><decl><type><name>int</name><modifier>*</modifier></type> <name>b</name></decl></parameter>)</parameter_list>;</function_decl>

label


Element

  • <label>

Subelement

  • <name>

XPath Queries

  • labels

    //src:label
  • label names

    //src:label/src:name
  • labels with a goto statement

    //src:label[src:name = //src:goto/src:name]
  • labels without a goto statement

    //src:label[not(src:name[. = //src:goto/src:name])]

Example

stop:
<label><name>stop</name>:</label>

literal


Element

  • <literal type="number|char|string">

XPath Queries

  • literals

    //src:literal
  • string literals

    //src:literal[@type='string']

Example

123;
42.0;
'c';
"Hello";
<expr_stmt><expr><literal type="number">123</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="number">42.0</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="char">'c'</literal></expr>;</expr_stmt>
<expr_stmt><expr><literal type="string">"Hello"</literal></expr>;</expr_stmt>

member access


Element

  • <expr>

Subelements

  • <name>
  • <operator>

XPath Query

  • uses of the . operator

    //src:operator[.='.']

Example

t.tm_sec;
<expr_stmt><expr><name><name>t</name><operator>.</operator><name>tm_sec</name></name></expr>;</expr_stmt>

omp:argument


Element

  • <omp:argument>

Subelement

  • <omp:expr>

XPath Query

  • omp arguments

    //omp:argument

omp:argument_list


Element

  • <omp:argument_list>

Subelement

  • <omp:argument>

XPath Query

  • omp argument lists

    //omp:argument_list

omp:clause


Element

  • <omp:clause>

Subelements

  • <omp:name>
  • <omp:argument_list>

XPath Query

  • omp clauses

    //omp:clause

omp:directive


Element

  • <omp:directive>

Subelements

  • <omp:name>
  • <omp:clause>

XPath Queries

  • omp directives

    //omp:directive
  • omp directives with the name ‘parallel’

    //omp:directive[omp:name='parallel']

Example

#pragma omp parallel
#pragma omp parallel if()
#pragma omp parallel if(list)
#pragma omp parallel if(one, two)
#pragma omp parallel if(one, two) if(one, two)
#pragma omp parallel if(one, two), if(one, two)
#pragma omp parallel reduction(+: sum)
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>()</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>list</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause>, <omp:clause><omp:name>if</omp:name><omp:argument_list>(<omp:argument><omp:expr>one</omp:expr></omp:argument>, <omp:argument><omp:expr>two</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>
<cpp:pragma>#<cpp:directive>pragma</cpp:directive> <omp:directive>omp <omp:name>parallel</omp:name> <omp:clause><omp:name>reduction</omp:name><omp:argument_list>(<omp:argument><omp:expr>+: sum</omp:expr></omp:argument>)</omp:argument_list></omp:clause></omp:directive></cpp:pragma>

omp:expr


Element

  • <omp:expr>

XPath Query

  • omp expressions

    //omp:expr

omp:name


Element

  • <omp:name>

XPath Query

  • omp names

    //omp:name

pointer declaration


Element

  • <modifier>

XPath Queries

  • declarations of pointers

    //src:decl[src:type/src:modifier='*']
  • function pointers

    //src:function_decl[contains(., ')')]

Examples

char *message;
<decl_stmt><decl><type><name>char</name> <modifier>*</modifier></type><name>message</name></decl>;</decl_stmt>
int *pointers[10];
<decl_stmt><decl><type><name>int</name> <modifier>*</modifier></type><name><name>pointers</name><index>[<expr><literal type="number">10</literal></expr>]</index></name></decl>;</decl_stmt>
int (*pointer)[10];
<expr_stmt><expr><call><name>int</name> <argument_list>(<argument><expr><operator>*</operator><name>pointer</name></expr></argument>)</argument_list></call><index>[<expr><literal type="number">10</literal></expr>]</index></expr>;</expr_stmt>
int const *x;
<decl_stmt><decl><type><name>int</name> <specifier>const</specifier> <modifier>*</modifier></type><name>x</name></decl>;</decl_stmt>
int(*X)(void);
int(*X)(int, float);
int(*X)(char const*,...);
<function_decl><type><name>int</name></type>(<modifier>*</modifier><name>X</name>)<parameter_list>(<parameter><decl><type><name>void</name></type></decl></parameter>)</parameter_list>;</function_decl>
<function_decl><type><name>int</name></type>(<modifier>*</modifier><name>X</name>)<parameter_list>(<parameter><decl><type><name>int</name></type></decl></parameter>, <parameter><decl><type><name>float</name></type></decl></parameter>)</parameter_list>;</function_decl>
<function_decl><type><name>int</name></type>(<modifier>*</modifier><name>X</name>)<parameter_list>(<parameter><decl><type><name>char</name> <specifier>const</specifier><modifier>*</modifier></type></decl></parameter>,<parameter><decl><type><modifier>...</modifier></type></decl></parameter>)</parameter_list>;</function_decl>
int volatile *const z = &some_object;
<decl_stmt><decl><type><name>int</name> <specifier>volatile</specifier> <modifier>*</modifier><specifier>const</specifier></type> <name>z</name> <init>= <expr><operator>&amp;</operator><name>some_object</name></expr></init></decl>;</decl_stmt>
int *const volatile w = &some_object;
<decl_stmt><decl><type><name>int</name> <modifier>*</modifier><specifier>const</specifier> <specifier>volatile</specifier></type> <name>w</name> <init>= <expr><operator>&amp;</operator><name>some_object</name></expr></init></decl>;</decl_stmt>

register


Element

  • <specifier>

XPath Query

  • variable declarations with the register specifier

    //src:decl[src:type/src:specifier='register']

Example

register int x;
<decl_stmt><decl><type><specifier>register</specifier> <name>int</name></type> <name>x</name></decl>;</decl_stmt>

restrict


Element

  • <specifier>

XPath Query

  • variables declarations with the restrict specifier

    //src:decl[src:type/src:specifier='restrict']

Example

restrict double* x;
<decl_stmt><decl><type><specifier>restrict</specifier> <name>double</name><modifier>*</modifier></type> <name>x</name></decl>;</decl_stmt>

return statement


Element

  • <return>

Subelement

  • <expr>

XPath Queries

  • return statements

    //src:return
  • return expressions

    //src:return/src:expr
  • return statements that return true

    //src:return[src:expr='true']
  • functions with more then one return

    //src:function[count(.//src:return) > 1]

Examples

return;
<return>return;</return>
return true;
<return>return <expr><name>true</name></expr>;</return>
return( s * (long long)s );
<return>return<expr><operator>(</operator> <name>s</name> <operator>*</operator> <operator>(</operator><name>long</name> <name>long</name><operator>)</operator><name>s</name> <operator>)</operator></expr>;</return>

sizeof


Element

  • <sizeof>

Subelements

  • <argument_list>
  • <name>

XPath Query

  • uses of sizeof

    //src:sizeof

Example

sizeof(struct type);
<expr_stmt><expr><sizeof>sizeof<argument_list>(<argument><expr>struct <name>type</name></expr></argument>)</argument_list></sizeof></expr>;</expr_stmt>

struct declaration


Element

  • <struct_decl>

Subelement

  • <name>

XPath Query

  • forward struct declarations

    //src:struct_decl

Example

forward declaration

struct employee;
<struct_decl>struct <name>employee</name>;</struct_decl>

struct definition


Element

  • <struct>

Subelements

  • <name>
  • <block>

XPath Queries

  • struct definitions

    //src:struct
  • struct members

    //src:struct/src:block/*[self::src:public | self::src:private | self::src:protected]/src:decl_stmt

Examples

struct a {
    int x;
    double y;
    float z;
 };
<struct>struct <name>a</name> <block>{
    <decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>double</name></type> <name>y</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>float</name></type> <name>z</name></decl>;</decl_stmt>
 }</block>;</struct>

variable of an anonymous struct type

struct
{
    int x;
    int y;
} mystruct;
<struct>struct
<block>{
    <decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>int</name></type> <name>y</name></decl>;</decl_stmt>
}</block> <decl><name>mystruct</name></decl>;</struct>

declaring a struct and instance

struct employee
{
    char name[20];
    int id;
    long cls;
} temp;
<struct>struct <name>employee</name>
<block>{
    <decl_stmt><decl><type><name>char</name></type> <name><name>name</name><index>[<expr><literal type="number">20</literal></expr>]</index></name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>int</name></type> <name>id</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>long</name></type> <name>cls</name></decl>;</decl_stmt>
}</block> <decl><name>temp</name></decl>;</struct>

switch statement


Element

  • <switch>

Subelements

  • <condition>
  • <case>
  • <block>

XPath Queries

  • switch statements

    //src:switch
  • switch-statement conditions

    //src:switch/src:condition

Examples

switch (c) {

    case 'A':
        ++capa;
    case 'a':
        ++lettera;
    default :
        ++total;
}
<switch>switch <condition>(<expr><name>c</name></expr>)</condition> <block>{<block_content>

    <case>case <expr><literal type="char">'A'</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>capa</name></expr>;</expr_stmt>
    <case>case <expr><literal type="char">'a'</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>lettera</name></expr>;</expr_stmt>
    <default>default :</default>
        <expr_stmt><expr><operator>++</operator><name>total</name></expr>;</expr_stmt>
</block_content>}</block></switch>
switch (i) {

    case -1:
        ++n;
        break;
    case 0 :
        ++z;
        break;
    case 1 :
        ++p;
        break;
}
<switch>switch <condition>(<expr><name>i</name></expr>)</condition> <block>{<block_content>

    <case>case <expr><operator>-</operator><literal type="number">1</literal></expr>:</case>
        <expr_stmt><expr><operator>++</operator><name>n</name></expr>;</expr_stmt>
        <break>break;</break>
    <case>case <expr><literal type="number">0</literal></expr> :</case>
        <expr_stmt><expr><operator>++</operator><name>z</name></expr>;</expr_stmt>
        <break>break;</break>
    <case>case <expr><literal type="number">1</literal></expr> :</case>
        <expr_stmt><expr><operator>++</operator><name>p</name></expr>;</expr_stmt>
        <break>break;</break>
</block_content>}</block></switch>

ternary operator


Element

  • <ternary>

Subelements

  • <condition>
  • <then>
  • <else>

XPath Query

  • ternary operators

    //src:ternary

Example

a ? x : y;
<expr_stmt><expr><ternary><condition><expr><name>a</name></expr> ?</condition><then> <expr><name>x</name></expr> </then><else>: <expr><name>y</name></expr></else></ternary></expr>;</expr_stmt>

then


Element

  • <then>

Subelement

  • <expr>

XPath Query

  • then parts of ternary

    //src:then

type


Element

  • <type>

Subelements

  • <specifier>
  • <name>

XPath Queries

  • types

    //src:type
  • declaration types

    //src:decl/src:type
  • function types

    //src:function/src:type
  • function declaration types

    //src:function_decl/src:type

typedef


Element

  • <typedef>

Subelements

  • <type>
  • <name>
  • <function_decl>

XPath Queries

  • typedefs

    //src:typedef
  • types in typedefs

    //src:typedef/src:type
  • typedef names

    //src:typedef/src:name
  • typedefs that define a struct

    //src:typedef[src:type/src:struct]
  • typedefs that declare a function type

    //src:typedef[src:function_decl]
  • typedefs of function pointers

    //src:typedef[contains(src:function_decl, ')')]
  • names of typedefs of function pointers

    //src:typedef/src:function_decl[contains(., ')')]/src:name

Examples

typedef char C;
typedef unsigned int WORD;
typedef char * pChar;
typedef char field [50]; 
typedef char field, *field2; 
<typedef>typedef <type><name>char</name></type> <name>C</name>;</typedef>
<typedef>typedef <type><name>unsigned</name> <name>int</name></type> <name>WORD</name>;</typedef>
<typedef>typedef <type><name>char</name> <modifier>*</modifier></type> <name>pChar</name>;</typedef>
<typedef>typedef <type><name>char</name></type> <name><name>field</name> <index>[<expr><literal type="number">50</literal></expr>]</index></name>;</typedef> 
<typedef>typedef <type><name>char</name></type> <name>field</name>, <modifier>*</modifier><name>field2</name>;</typedef> 
typedef struct club 
{
    char name[30];
    int size, year;
} GROUP;
<typedef>typedef <type><struct>struct <name>club</name> 
<block>{
    <decl_stmt><decl><type><name>char</name></type> <name><name>name</name><index>[<expr><literal type="number">30</literal></expr>]</index></name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>int</name></type> <name>size</name></decl>, <name>year</name>;</decl_stmt>
}</block></struct></type> <name>GROUP</name>;</typedef>
typedef void DRAWF( int, int );
<typedef>typedef <function_decl><type><name>void</name></type> <name>DRAWF</name><parameter_list>( <parameter><decl><type><name>int</name></type></decl></parameter>, <parameter><decl><type><name>int</name></type></decl></parameter> )</parameter_list>;</function_decl></typedef>
typedef void (*DRAWF)( int, int );
<typedef>typedef <function_decl><type><name>void</name></type> (<modifier>*</modifier><name>DRAWF</name>)<parameter_list>( <parameter><decl><type><name>int</name></type></decl></parameter>, <parameter><decl><type><name>int</name></type></decl></parameter> )</parameter_list>;</function_decl></typedef>

union declaration


Element

  • <union_decl>

Subelement

  • <name>

XPath Query

  • forward declarations for unions

    //src:union_decl

Example

union X;
<union_decl>union <name>X</name>;</union_decl>

union definition


Element

  • <union>

Subelements

  • <name>
  • <block>

XPath Query

  • union definitions

    //src:union

Example

union sign
{
    int svar;
    unsigned uvar;
} number;
<union>union <name>sign</name>
<block>{
    <decl_stmt><decl><type><name>int</name></type> <name>svar</name></decl>;</decl_stmt>
    <decl_stmt><decl><type><name>unsigned</name></type> <name>uvar</name></decl>;</decl_stmt>
}</block> <decl><name>number</name></decl>;</union>

variable declaration


Element

  • <decl>

Subelements

  • <name>
  • <init>

XPath Queries

  • variable declarations

    //src:decl
  • variable declarations with an initialization

    //src:decl[src:init]
  • variable declarations with the struct qualifier

    //src:decl[contains(src:type, 'struct')]

Examples

int x;
<decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>

struct declarations

struct X y;
<decl_stmt><decl><type><name><name>struct</name> <name>X</name></name></type> <name>y</name></decl>;</decl_stmt>

variable declaration statement


Element

  • <decl_stmt>

Subelement

  • <decl>

XPath Queries

  • declaration statements

    //src:decl_stmt
  • variable declaration statements with the union qualifier

    //src:decl_stmt/src:decl[contains(src:type, 'union')]

Examples

int x;
<decl_stmt><decl><type><name>int</name></type> <name>x</name></decl>;</decl_stmt>

struct declarations

struct X y;
<decl_stmt><decl><type><name><name>struct</name> <name>X</name></name></type> <name>y</name></decl>;</decl_stmt>

volatile


Element

  • <specifier>

XPath Query

  • volatile variables

    //src:decl[src:type/src:specifier='volatile']

Example

volatile int foo; 
int volatile foo;
<decl_stmt><decl><type><specifier>volatile</specifier> <name>int</name></type> <name>foo</name></decl>;</decl_stmt> 
<decl_stmt><decl><type><name>int</name> <specifier>volatile</specifier></type> <name>foo</name></decl>;</decl_stmt>

while statement


Element

  • <while>

Subelements

  • <condition>
  • <block>

XPath Queries

  • while loops

    //src:while
  • while-loop conditions

    //src:while/src:condition
  • while loops with a condition containing the variable i

    //src:while[src:condition//src:name = 'i']

Example

while ( i >= 0 ) 
{
    string1[i] = string2[i];
    i--;
}
<while>while <condition>( <expr><name>i</name> <operator>&gt;=</operator> <literal type="number">0</literal></expr> )</condition> 
<block>{<block_content>
    <expr_stmt><expr><name><name>string1</name><index>[<expr><name>i</name></expr>]</index></name> <operator>=</operator> <name><name>string2</name><index>[<expr><name>i</name></expr>]</index></name></expr>;</expr_stmt>
    <expr_stmt><expr><name>i</name><operator>--</operator></expr>;</expr_stmt>
</block_content>}</block></while>