srcML Grammar

Rule Rule Type C C++ C# Java
srcML Grammar Overview
start EBNF Rule
unit Element Rule
archiveUnit Element Rule
compilationUnit Element Rule
dirAttr Attribute Rule
filenameAttr Attribute Rule
languageAttr Attribute Rule
hashAttr Attribute Rule
optionsAttr Attribute Rule
macro-list Element Rule  
macroTokenAttr Attribute Rule  
macroTypeAttr Attribute Rule  
comment Element Rule
commentTypeAttr Attribute Rule
commentFormatAttr Attribute Rule
escape Element Rule
charAttr Attribute Rule
topLevelElements EBNF Rule
anyCPPOrCommentOrText EBNF Rule
cppDefine EBNF Rule  
cpp:define Element Rule  
cppDefineName Element Rule  
cppDefineFunction Element Rule    
cpp:directive Element Rule  
cpp:macro Element Rule  
cppMacro Element Rule  
cppMacroFunction Element Rule    
cpp:number Element Rule  
cpp:value Element Rule  
cpp:if Element Rule  
cpp:ifdef Element Rule  
cpp:ifndef Element Rule  
cpp:elif Element Rule  
cpp:else Element Rule  
cpp:endif Element Rule  
cpp:region Element Rule      
cpp:endregion Element Rule      
cpp:error Element Rule  
cpp:warning Element Rule  
cpp:literal Element Rule  
cpp:include Element Rule    
cppFile EBNF Rule    
cpp:file Element Rule  
cppFileRelative Element Rule    
cppFileSearch Element Rule  
cppLine EBNF Rule  
cpp:line Element Rule  
lineNumberAndFile Element Rule  
lineHiddenOrDefault Element Rule      
cpp:pragma Element Rule  
cpp:undef Element Rule  
cpp:empty Element Rule  
if Element Rule
condition Element Rule
condition Element Rule
forCondition Element Rule
ternaryCondition Element Rule
then Element Rule
then Element Rule
ternaryThen Element Rule
elseif Element Rule
else Element Rule
else Element Rule
ternaryElse Element Rule
while Element Rule
do Element Rule
for Element Rule
foreach Element Rule      
control Element Rule
forControl Element Rule
foreachControl Element Rule      
init Element Rule
forInit Element Rule
controlInit Element Rule
resourceInit Element Rule
typeInit Element Rule      
propertyInit Element Rule      
init Element Rule
incr Element Rule
switch Element Rule
case Element Rule
default Element Rule
defaultCase Element Rule
defaultPropertyValue Element Rule      
defaultCall Element Rule      
continue Element Rule
continue Element Rule
continueTo Element Rule      
return Element Rule
return Element Rule
yieldReturn Element Rule      
break Element Rule
break Element Rule
yieldBreak Element Rule      
breakTo Element Rule      
decl_stmt Element Rule
expr_stmt Element Rule
empty_stmt Element Rule
goto Element Rule  
goto Element Rule  
gotoCaseOrDefault Element Rule      
label Element Rule
block Element Rule
block Element Rule
initBlock Element Rule
CPlusPlusClassBodyBlock Element Rule      
CPlusPlusStructBodyBlock Element Rule      
enumBlock Element Rule  
JavaEnumBlock Element Rule      
pseudoBlock Element Rule
typePseudoAttr Attribute Rule
typedef Element Rule    
assert Element Rule    
assertStmt Element Rule      
staticAssert Element Rule      
typeStaticAttr Attribute Rule      
using_stmt Element Rule      
lock Element Rule      
synchronized Element Rule      
unsafe Element Rule      
fixed Element Rule      
asm Element Rule    
namespace Element Rule    
using Element Rule    
usingDirectiveCPlusPlus Element Rule      
usingNamespace Element Rule      
usingDirectiveCSharp Element Rule      
extern Element Rule    
import Element Rule      
package Element Rule      
template Element Rule      
typename Element Rule      
function Element Rule
CFunction Element Rule      
CPlusPlusFunction Element Rule      
CSharpFunction Element Rule      
CSharpPropertyFunction Element Rule      
JavaFunction Element Rule      
CPlusPlusOperatorFunction Element Rule      
CSharpOperatorFunction Element Rule      
function_decl Element Rule
CFunctionDecl Element Rule      
CPlusPlusFunctionDecl Element Rule      
CSharpFunctionDecl Element Rule      
JavaFunctionDecl Element Rule      
CPlusPlusFunctionDeclOperator Element Rule      
CSharpFunctionDeclOperator Element Rule      
functionTypeAttr Attribute Rule    
friend Element Rule      
ref_qualifier Element Rule      
throws Element Rule      
lambda Element Rule  
CPlusPlusLambda Element Rule      
CSharpLambda Element Rule      
JavaLambda Element Rule      
capture Element Rule      
delegate Element Rule      
property Element Rule      
property Element Rule      
indexerProperty Element Rule      
event Element Rule      
classInterfaceOrAnnotation EBNF Rule  
class Element Rule  
CPlusPlusClass Element Rule      
CSharpClass Element Rule      
JavaClass Element Rule      
JavaAnonymousClass Element Rule      
class_decl Element Rule      
annotation_defn Element Rule      
interface Element Rule    
CSharpInterface Element Rule      
JavaInterface Element Rule      
enum Element Rule
CEnum Element Rule
CPlusPlusEnum Element Rule      
CSharpEnum Element Rule      
JavaEnum Element Rule      
enumClass Element Rule      
enumTypeAttr Attribute Rule      
enum_decl Element Rule    
struct Element Rule  
CStruct Element Rule      
CPlusPlusStruct Element Rule      
CSharpStruct Element Rule      
struct_decl Element Rule    
union Element Rule      
CUnion Element Rule      
CPlusPlusUnion Element Rule      
union_decl Element Rule    
CUnionDecl Element Rule    
CPlusPlusUnionDecl Element Rule    
private Element Rule      
privateDefault Element Rule      
private Element Rule      
protected Element Rule      
public Element Rule      
publicDefault Element Rule      
public Element Rule      
accessSpecifierTypeAttr Attribute Rule      
super Element Rule  
super Element Rule    
JavaSuper Element Rule      
extends Element Rule      
implements Element Rule      
constructor Element Rule  
constructor_decl Element Rule  
member_list Element Rule  
static Element Rule      
destructor Element Rule
destructor_decl Element Rule
cast Element Rule
cast Element Rule
constCast Element Rule      
dynamicCast Element Rule      
reinterpretCast Element Rule      
staticCast Element Rule      
castTypeAttr Attribute Rule      
ternary Element Rule      
checked Element Rule      
checkedBlock Element Rule      
checkedCall Element Rule      
unchecked Element Rule      
uncheckedBlock Element Rule      
uncheckedCall Element Rule      
decltype Element Rule      
noexcept Element Rule      
sizeof Element Rule  
sizeof Element Rule  
sizeofParameterPack Element Rule      
sizeofTypeAttr Attribute Rule      
typeid Element Rule      
typeof Element Rule      
atomic Element Rule      
alignof Element Rule    
alignas Element Rule    
generic_selection Element Rule      
selector Element Rule      
association_list Element Rule      
association Element Rule      
linq Element Rule      
from Element Rule      
in Element Rule      
select Element Rule      
where Element Rule      
whereConstraint Element Rule      
whereClause Element Rule      
constraint Element Rule      
group Element Rule      
by Element Rule      
into Element Rule      
join Element Rule      
equals Element Rule      
on Element Rule      
let Element Rule      
orderby Element Rule      
try Element Rule  
throw Element Rule  
exceptionSpecification Element Rule      
throw Element Rule  
catch Element Rule  
catch Element Rule  
multiTypeCatch Element Rule      
finally Element Rule    
attribute Element Rule    
CSharpAttribute Element Rule      
CPlusPlusAttribute Element Rule      
annotation Element Rule      
argument_list Element Rule
argumentList Element Rule
templateArgumentList Element Rule  
agrumentListTypeAttr Attribute Rule
argument Element Rule
parameter_list Element Rule
parameterList Element Rule
templateParameterList Element Rule  
pseudoParameterList Element Rule      
pseudoParameterListTypeAttr Attribute Rule      
parameter Element Rule
decl Element Rule
range Element Rule
expr Element Rule
type Element Rule
typeTypeAttr Attribute Rule
call Element Rule
name EBNF Rule
name Element Rule
complexName Element Rule
simpleName Element Rule
index Element Rule
specifier Element Rule
operator Element Rule
literal Element Rule
literalTypeAttr Attribute Rule
macro Element Rule    
modifier Element Rule

srcML Grammar Overview


This sections describes the grammar used to describe the srcML structure. The grammar is an EBNF-like grammar that combines the known XML syntax and EBNF to express the contents of individual elements in terms of rules. This grammar is used instead of a DTD, RELAX NG or XML Schema because the XML is being used to express the structure of a programming language which can't be accurately or readably expressed using traditional XML data description languages.

rules

There are three types of rules within the grammar: 1) an EBNF Rule 2) an Element Rule and 3) an Attribute Rule. All of the rules follow one of two forms:
rule-name : rule-contents ;
or
rule-name [parameters]: rule-contents ;
This is the syntax for the EBNF Rule, but the other types of rules make extensions to this rule structure by adding meta information after the rule-name.

All rules are referred to by their rule-name when used as part of another rule.

rule-name the name of the rule.

parameters is a comma separated list of names.

rule-contents is the content of the rule.

Whitespace within the XML is ignored when matching unless specified as part of a literal.

EBNF rule

A EBNF Rule is the most general rule that doesn't include any additional information from XML as part of its name. Each rule is broken down into to parts: the left hand side and right hand side, both sides are separated by a :(colon). The left hand side of the rule represents its name and the right the rule's contents. The right hand side is terminated by a ;(semi-colon).
rule-name : rule-contents ;
rule-name [parameters]: rule-contents ;

element rule

An element rule describes the content of an XML element. An element rule adds the elements name and optional attribute list to the rule as meta information. An element rule may have parameters. Parameters are always last as part of a rule's left hand side before the colon. An attribute-list is an unordered comma separated list of attributes that are part of the tag-name. An attribute within the list may be optional, indicated by a ? following it's name, but no other grammar constructs can be used to describe it.
rule-name <tag-name> : rule-contents ;
rule-name <tag-name> (attribute-list) : rule-contents ;

attribute rule

An attribute rule describes an XML attribute for an element. The XML attribute's name is given as meta information following the rule name and prefixed with a @. Attribute rules can not have parameters. XML attributes take the form attribute-name="content" and the rule-contents represents what to expected within the content of an attribute.
rule-name @attribute-name : rule-contents ;

rule parameters and referencing a rule with parameters

The parameters of a rule can be used to pass any information that can be used to describe a rule. The use of a parameter within the description of a rule is indicated by using a $ before the variable's name. An example of this would be if an element only has content based on the context it's used in. Each rule that would use the parameterized rule would indicate its content using its parameter. For example, the rule
type <type> [value]: $value ;
describes an element with the name type whose value is specified by the caller. This is illustrated in the following example:
documentation <documentation> : type["docbook"] ;
This means that the documentation rule would match the following XML,
<documentation>
    <type>docbook</type>
</documentation>

group

A group is simply EBNF elements that are between ().
(pattern)

zero or more

The * indicates zero or more occurrences of the preceding pattern or group.
pattern*
(pattern)*

one or more

The + indicates one or more occurrences of the preceding pattern or group.
pattern+
(pattern)+

optional

The ? indicates that a pattern or group may occur zero or one times.
pattern?
(pattern)?

choice

The | indicates that a there are multiple possible matches.
(pattern1 | pattern2)

inline element

An inline element is used to describe a special case of an element that would usually contain a different pattern. An inline element is the element rule's meta information followed by {} which surround the element's contents.
<tag-name>{ pattern }
<tag-name> (attribute-list) { pattern }

literals

A literal describes possible text that occurs at a given location within the grammar. Whitespace between a literal and any other element within the XML is undefined, this means that it may or may not have whitespace before or after it. However, the typical srcML behavior is to place tags without preceding or trailing whitespace whenever possible.
"value"

Identifier keyword

The Identifier keyword indicates any possible identifier within the language you are interested in. In some cases this also includes keywords. Typically that means keywords that are names of built-in types, such as int, double, or auto, or implicit variable names such as this, or base.
Identifier

Text keyword

The Text keyword is used to indicate that literally ANY text (that isn't an XML element), including whitespace, could occur at that location within the grammar.
Text

Number keyword

The Number keyword is used to match any number, floating point or integer, within the XML.
Number

Operator keyword

The Operator keyword matches any operator from any of the supported languages.
Operator

Empty keyword

The empty keyword indicates that an element has no content.
Empty
C C++ C# Java

start


The starting rule for the srcML grammar. The XML generated by srcML has two forms depending on input: 1) an archive (multiple files) and 2) compilation unit (a single file).

Child Rules

Child Tags

C C++ C# Java

<unit>


Element Use Cases

C C++ C# Java

archiveUnit

An archive is a collection of compilation units.
C C++ C# Java

compilationUnit

A Compilation unit is a single file that was processed by srcML.

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

dirAttr


The directory attribute for a unit.
dirAttr@dir:Text;

Parent Rules

Parent Tags

C C++ C# Java

filenameAttr


The file that was used to create the current unit.
filenameAttr@filename:Text;

Parent Rules

Parent Tags

C C++ C# Java

languageAttr


The language used by srcML to create the current unit.
languageAttr@language:("C"|"C++"|"C#"|"Java");

Parent Rules

Parent Tags

C C++ C# Java

hashAttr


Hash of the source file.
hashAttr@hash:Text;

Parent Rules

Parent Tags

C C++ C# Java

optionsAttr


What options were used to build this document.
optionsAttr@options:Text;

Parent Rules

Parent Tags

C C++ C# Java
 

<macro-list>


A user defined macro definition provided to the srcML client.

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
 

macroTokenAttr


The element QName to mark as a macro.
macroTokenAttr@token:Text;

Parent Rules

Parent Tags

C C++ C# Java
 

macroTypeAttr


The value for the token.
macroTypeAttr@type:Text;

Parent Rules

Parent Tags

C C++ C# Java

<comment>


A comment within the supported programming languages.

Parent Rules

Child Rules

C C++ C# Java

commentTypeAttr


The type of comment, either a line comment or a block comment.
commentTypeAttr@type:("line"|"block");

Parent Rules

Parent Tags

C C++ C# Java

commentFormatAttr


Indicates a possible format of a comment.
commentFormatAttr@format:("doxygen"|"javadoc");

Parent Rules

Parent Tags

C C++ C# Java

<escape>


A special character, such as a form feed.
escape<escape>(charAttr):Empty;

Parent Rules

Child Rules

C C++ C# Java

charAttr


Escaped character code in hex.
charAttr@char:Text;

Parent Rules

Parent Tags

C C++ C# Java

topLevelElements


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

anyCPPOrCommentOrText


Any of the C preprocessor directives, any specially marked up text, or a comment. Any of the child rules contained within this rule occur almost anywhere within a compilation unit.

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

cppDefine


Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:define>


Element Use Cases

C C++ C# Java
 

cppDefineName

cppDefineName<cpp:define>:"#"cppDirective["define"](cppMacro(cppValue|cppNumber)?)?;
C C++ C# Java
   

cppDefineFunction

cppDefineFunction<cpp:define>:"#"cppDirective["define"]cppMacroFunction(cppValue|cppNumber)?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:directive>


The name of preprocessor directive.
cppDirective<cpp:directive>[value]:$value;

Parent Rules

Parent Tags

C C++ C# Java
 

<cpp:macro>


Element Use Cases

C C++ C# Java
 

cppMacro

C C++ C# Java
   

cppMacroFunction

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<cpp:number>


cppNumber<cpp:number>:Number;

Parent Rules

Parent Tags

C C++ C# Java
 

<cpp:value>


cppValue<cpp:value>:Text;

Parent Rules

Parent Tags

C C++ C# Java
 

<cpp:if>


cppIf<cpp:if>:"#"cppDirective["if"]expr?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:ifdef>


cppIfDef<cpp:ifdef>:"#"cppDirective["ifdef"]simpleName?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:ifndef>


cppIfNDef<cpp:ifndef>:"#"cppDirective["ifndef"]name?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:elif>


cppElIf<cpp:elif>:"#"cppDirective["elif"]name?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:else>


cppElse<cpp:else>:"#"cppDirective["else"];

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:endif>


cppEndIf<cpp:endif>:"#"cppDirective["endif"];

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<cpp:region>


cppRegion<cpp:region>:"#"cppDirective["region"](simpleName|cppLiteral|Text)*;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<cpp:endregion>


cppEndRegion<cpp:endregion>:"#"cppDirective["endregion"];

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:error>


cppError<cpp:error>:"#"cppDirective["error"](simpleName|cppLiteral|Text)*;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:warning>


cppWarning<cpp:warning>:"#"cppDirective["warning"](simpleName|cppLiteral|Text)*;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:literal>


A preprocessor literal can be a single or double quoted string literal.
cppLiteral<cpp:literal>:Text;

Parent Rules

Parent Tags

C C++ C# Java
   

<cpp:include>


cppInclude<cpp:include>:"#"cppDirective["include"]cppFile?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
   

cppFile


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<cpp:file>


Element Use Cases

C C++ C# Java
   

cppFileRelative

cppFileRelative<cpp:file>:"<"Text">";
C C++ C# Java
 

cppFileSearch

cppFileSearch<cpp:file>:"\""Text"\"";

Parent Rules

C C++ C# Java
 

cppLine


Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:line>


Element Use Cases

C C++ C# Java
 

lineNumberAndFile

lineNumberAndFile<cpp:line>:"#"cppDirective["line"](cppNumbercppFile?)?;
C C++ C# Java
     

lineHiddenOrDefault

lineHiddenOrDefault<cpp:line>:"#"cppDirective["line"]<name>{("hidden"|"default")};

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:pragma>


cppPragma<cpp:pragma>:"#"cppDirective["pragma"](simpleName|cppLiteral|Text)*;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:undef>


cppUndef<cpp:undef>:"#"cppDirective["undef"]simpleName?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<cpp:empty>


cppEmpty<cpp:empty>:"#";

Parent Rules

C C++ C# Java

<if>


if

if<if>:"if"(conditionthen(else|elseif)*)?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<condition>


Element Use Cases

C C++ C# Java

condition

condition<condition>:"("expr?")";
C C++ C# Java

forCondition

forCondition<condition>:expr";";
C C++ C# Java

ternaryCondition

ternaryCondition<condition>:expr?"?";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<then>


Element Use Cases

C C++ C# Java

then

C C++ C# Java

ternaryThen

ternaryThen<then>:expr;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<elseif>


elseif<elseif>:"else"if;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<else>


Element Use Cases

C C++ C# Java

else

else<else>:"else"(block|pseudoBlock);
C C++ C# Java

ternaryElse

ternaryElse<else>:":"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<while>


while<while>:"while"(condition(block|pseudoBlock))?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<do>


do

do<do>:"do"(block|pseudoBlock)("while"condition?)?";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<for>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<foreach>


Parent Rules

Child Rules

Child Tags

C C++ C# Java

<control>


Element Use Cases

C C++ C# Java

forControl

This is for a traditional for loop's control.
forControl<control>:"("(forInit(forConditionforIncr?)?)?")";
C C++ C# Java
     

foreachControl

foreachControl<control>:"("controlInit")";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<init>


Element Use Cases

C C++ C# Java

forInit

forInit<init>:(expr|decl)";"?;
C C++ C# Java

controlInit

controlInit<init>:(decl|expr)(","(decl|expr))*;
C C++ C# Java

resourceInit

resourceInit<init>:"("(decl|expr)(","(decl|expr))*")";
C C++ C# Java
     

typeInit

typeInit<init>:"="<type>{expr};
C C++ C# Java
     

propertyInit

propertyInit<init>:expr?;
C C++ C# Java

init

init<init>:"="expr;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<incr>


forIncr<incr>:(expr|Empty);

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<switch>


switch<switch>:"switch"condition?(block|pseudoBlock);

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<case>


case<case>:"case"(name|literal)?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<default>


Element Use Cases

C C++ C# Java

defaultCase

defaultCase<default>:"default"":";
C C++ C# Java
     

defaultPropertyValue

defaultPropertyValue<default>:"default"propertyInit?;
C C++ C# Java
     

defaultCall

defaultCall<default>:"default"argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<continue>


Element Use Cases

C C++ C# Java

continue

continue<continue>:"continue"";"?;
C C++ C# Java
     

continueTo

continueTo<continue>:"continue"name";"?;

Parent Rules

Child Rules

C C++ C# Java

<return>


Element Use Cases

C C++ C# Java

return

return<return>:"return"expr?";"?;
C C++ C# Java
     

yieldReturn

yieldReturn<return>:<specifier>{"yield"}"return"expr?";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<break>


Element Use Cases

C C++ C# Java

break

break<break>:"break"";"?;
C C++ C# Java
     

yieldBreak

yieldBreak<break>:<specifier>{"yield"}"break"";"?;
C C++ C# Java
     

breakTo

breakTo<break>:"break"simpleName";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<decl_stmt>


declStmt<decl_stmt>:decl(","decl)*";"?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<expr_stmt>


exprStmt<expr_stmt>:expr(<operator>{","}expr)*";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<empty_stmt>


emptyStmt<empty_stmt>:";";

Parent Rules

C C++ C# Java
 

<goto>


Element Use Cases

C C++ C# Java
 

goto

goto<goto>:"goto"(name|literal)?";"?;
C C++ C# Java
     

gotoCaseOrDefault

gotoCaseOrDefault<goto>:"goto"("default"|<name>{"case"(name|literal)})";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<label>


label<label>:simpleName?":";

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<block>


Element Use Cases

C C++ C# Java

block

block<block>:"{"topLevelElements*"}";
C C++ C# Java

initBlock

initBlock<block>:"{"(expr(","expr)*)?"}";
C C++ C# Java
     

CPlusPlusClassBodyBlock

CPlusPlusClassBodyBlock<block>:"{"privateDefault(public|private|protected)*"}";
C C++ C# Java
     

CPlusPlusStructBodyBlock

CPlusPlusStructBodyBlock<block>:"{"publicDefault(public|private|protected)*"}";
C C++ C# Java
 

enumBlock

enumBlock<block>:(decl(","decl)*)?;
C C++ C# Java
     

JavaEnumBlock

JavaEnumBlock<block>:(decl(","decl)*)?";"?topLevelElements*;
C C++ C# Java

pseudoBlock

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

typePseudoAttr


typePseudoAttr@type:"pseudo";

Parent Rules

Parent Tags

C C++ C# Java
   

<typedef>


typedef<typedef>:"typedef"(typesimpleName?)?";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
   

<assert>


Element Use Cases

C C++ C# Java
     

assertStmt

assertStmt<assert>:"assert"expr?(<operator>{":"}expr?)?;
C C++ C# Java
     

staticAssert

staticAssert<assert>(typeStaticAttr):"_Static_assert"argumentList?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

typeStaticAttr


typeStaticAttr@type:"static";

Parent Rules

Parent Tags

C C++ C# Java
     

<using_stmt>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<lock>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<synchronized>


synchronized<synchronized>:"synchronized"resourceInit?(block|pseudoBlock);

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<unsafe>


unsafe<unsafe>:"unsafe"block;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<fixed>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
   

<asm>


ASM

ASM<asm>:("asm"|"__asm__"|"__asm")(Text|ASM)*";"?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<namespace>


namespace<namespace>:<specifier>{"inline"}?"namespace"name?(block|("="name?))?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
   

<using>


Element Use Cases

C C++ C# Java
     

usingDirectiveCPlusPlus

usingDirectiveCPlusPlus<using>:template*"using"(simpleNametypeInit?)?";"?;
C C++ C# Java
     

usingNamespace

usingNamespace<using>:"using"<namespace>{"namespace"name?}";"?;
C C++ C# Java
     

usingDirectiveCSharp

usingDirectiveCSharp<using>:"using"name?init?";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
   

<extern>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<import>


import<import>:"import"name?";"?;

Parent Rules

Child Rules

C C++ C# Java
     

<package>


package<package>:"package"name?";"?;

Parent Rules

Child Rules

C C++ C# Java
     

<template>


template<template>:"template"templateParameterList?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<typename>


typename<typename>:"typename";

Parent Rules

Parent Tags

C C++ C# Java

<function>


Element Use Cases

C C++ C# Java
     

CFunction

C function definition. The declaration statements following the parameter list are only used for K & R C.
C C++ C# Java
     

CSharpFunction

C C++ C# Java
     

CSharpPropertyFunction

CSharpPropertyFunction<function>:<name>{("get"|"set"|"add"|"remove")}block;
C C++ C# Java
     

JavaFunction

C C++ C# Java
     

CPlusPlusOperatorFunction

C C++ C# Java
     

CSharpOperatorFunction

CSharpOperatorFunction<function>(functionTypeAttr):specifier*type<name>{"operator"<name>{Operator}}parameterListblock;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<function_decl>


Element Use Cases

C C++ C# Java
     

CFunctionDecl

C C++ C# Java
     

CPlusPlusFunctionDecl

C C++ C# Java
     

CSharpFunctionDecl

C C++ C# Java
     

CPlusPlusFunctionDeclOperator

CPlusPlusFunctionDeclOperator<function_decl>(functionTypeAttr):template*specifier*type<name>{"operator"<name>{Operator}}("="(<specifier>{("default"|"delete")}|literal))?(specifier|noexcept|exceptionSpecification|refQualifier|("->"type))*";"?;
C C++ C# Java
     

CSharpFunctionDeclOperator

CSharpFunctionDeclOperator<function_decl>(functionTypeAttr):specifier*type<name>{"operator"<name>{Operator}}parameterList";"?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

functionTypeAttr


functionTypeAttr@type:"operator";

Parent Rules

Parent Tags

C C++ C# Java
     

<friend>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<ref_qualifier>


refQualifier<ref_qualifier>:("&"|"&&");

Parent Rules

Parent Tags

C C++ C# Java
     

<throws>


throws<throws>:"throws"(argument(","argument)*)?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<lambda>


Element Use Cases

C C++ C# Java
     

CPlusPlusLambda

C C++ C# Java
     

CSharpLambda

C C++ C# Java
     

JavaLambda

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<capture>


capture<capture>:"["(argument(","argument)*)?"]";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<delegate>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<property>


Element Use Cases

C C++ C# Java
     

property

C C++ C# Java
     

indexerProperty

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<event>


The event keyword occurs as part of the type element as text.
event<event>:typename(block|";")?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

classInterfaceOrAnnotation


Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<class>


Element Use Cases

C C++ C# Java
     

CPlusPlusClass

C C++ C# Java
     

CSharpClass

CSharpClass<class>:"class"simpleName?super?block;
C C++ C# Java
     

JavaClass

JavaClass<class>:"class"simpleName?JavaSuper?block;
C C++ C# Java
     

JavaAnonymousClass

JavaAnonymousClass<class>:"class"JavaSuperargumentListblock;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<class_decl>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<annotation_defn>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
   

<interface>


Element Use Cases

C C++ C# Java
     

CSharpInterface

CSharpInterface<interface>:"interface"simpleName?super?block;
C C++ C# Java
     

JavaInterface

JavaInterface<interface>:"interface"simpleName?JavaSuper?block;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<enum>


Element Use Cases

C C++ C# Java

CEnum

CEnum<enum>:"enum"name?enumBlock?decl?";"?;
C C++ C# Java
     

CPlusPlusEnum

CPlusPlusEnum<enum>:CPlusPlusAttribute*"enum"name?enumBlock?decl?";"?;
C C++ C# Java
     

CSharpEnum

CSharpEnum<enum>:CSharpAttribute*"enum"name?enumBlock?;
C C++ C# Java
     

JavaEnum

JavaEnum<enum>:annotation*"enum"name?JavaEnumBlock?;
C C++ C# Java
     

enumClass

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

enumTypeAttr


Used to indicate that an enum is an enum class.
enumTypeAttr@type:"class";

Parent Rules

Parent Tags

C C++ C# Java
   

<enum_decl>


enumDecl<enum_decl>:"enum"name?";"?;

Parent Rules

Child Rules

C C++ C# Java
 

<struct>


Element Use Cases

C C++ C# Java
     

CStruct

CStruct<struct>:"struct"name?blockdecl?";"?;
C C++ C# Java
     

CPlusPlusStruct

C C++ C# Java
     

CSharpStruct

CSharpStruct<struct>:CSharpAttribute*"struct"nameblock;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<struct_decl>


structDecl<struct_decl>:"struct"name";"?;

Parent Rules

Child Rules

C C++ C# Java
     

<union>


Element Use Cases

C C++ C# Java
     

CUnion

CUnion<union>:"union"name?blockdecl?";"?;
C C++ C# Java
     

CPlusPlusUnion

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<union_decl>


Element Use Cases

C C++ C# Java
   

CUnionDecl

CUnionDecl<union_decl>:"union"name?";"?;
C C++ C# Java
   

CPlusPlusUnionDecl

CPlusPlusUnionDecl<union_decl>:(template|CPlusPlusAttribute)*"union"name?";"?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java
     

<private>


Element Use Cases

C C++ C# Java
     

privateDefault

C C++ C# Java
     

private

private<private>:"private"":"topLevelElements*;

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
     

<protected>


protected<protected>:"protected"":"topLevelElements*;

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
     

<public>


Element Use Cases

C C++ C# Java
     

publicDefault

C C++ C# Java
     

public

public<public>:"public"":"topLevelElements*;

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
     

accessSpecifierTypeAttr


accessSpecifierTypeAttr@type:"default";

Parent Rules

Parent Tags

C C++ C# Java
 

<super>


Element Use Cases

C C++ C# Java
   

super

C C++ C# Java
     

JavaSuper

There are two ways that the super element is used. 1) Within a class, interface or annotation definition. 2) Within an enum or an anonymous class.

In the first case super will contain some combination of at least extends and/or implements.

In the second case only a name appears within the super indicating the enum type or class.
JavaSuper<super>:((extendsimplements)+|name);

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<extends>


extends<extends>:"extends"name?;

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
     

<implements>


implements<implements>:"implements"(name(","name)*)?;

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
 

<constructor>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<constructor_decl>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<member_list>


memberList<member_list>:":"(call(","call)*)?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<static>


staticBlock<static>:"static"block?;

Parent Rules

Child Rules

Child Tags

C C++ C# Java

<destructor>


Parent Rules

Child Rules

Child Tags

C C++ C# Java

<destructor_decl>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<cast>


Element Use Cases

C C++ C# Java

cast

A C-Style cast.
cast<cast>:"("name?")";
C C++ C# Java
     

constCast

C C++ C# Java
     

dynamicCast

C C++ C# Java
     

reinterpretCast

reinterpretCast<cast>(castTypeAttr):"reinterpret_cast"templateArgumentListargumentList;
C C++ C# Java
     

staticCast

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

castTypeAttr


castTypeAttr@type:("const"|"dynamic"|"reinterpret"|"static");

Parent Rules

Parent Tags

C C++ C# Java
     

<ternary>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<checked>


Element Use Cases

C C++ C# Java
     

checkedBlock

checkedBlock<checked>:"checked"block;
C C++ C# Java
     

checkedCall

checkedCall<checked>:"checked"argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<unchecked>


Element Use Cases

C C++ C# Java
     

uncheckedBlock

uncheckedBlock<unchecked>:"unchecked"block;
C C++ C# Java
     

uncheckedCall

uncheckedCall<unchecked>:"unchecked"argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<decltype>


decltype<decltype>:"decltype"argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<noexcept>


noexcept<noexcept>:"noexcept"argumentList?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<sizeof>


Element Use Cases

C C++ C# Java
 

sizeof

sizeof<sizeof>:"sizeof"argumentList;
C C++ C# Java
     

sizeofParameterPack

sizeofParameterPack<sizeof>(sizeofTypeAttr):"sizeof""..."argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

sizeofTypeAttr


This represents when size of is being used to count the number of parameters within a parameter pack, instead of determining the size of a type.
sizeofTypeAttr@type:"pack";

Parent Rules

Parent Tags

C C++ C# Java
     

<typeid>


typeid<typeid>:"typeid"argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<typeof>


typeof<typeof>:"typeof"argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<atomic>


atomic<atomic>:"_Atomic"argumentList?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<alignof>


alignof<alignof>:("_Alignof"|"alignof")argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<alignas>


alignas<alignas>:("_Alignas"|"alignas")argumentList;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<generic_selection>


genericSelection<generic_selection>:"_Generic""("selector(","associationList?)?")";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<selector>


selector<selector>:expr;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<association_list>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<association>


association<association>:(type|<type>{"default"})":"expr;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<linq>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<from>


from<from>:"from"exprin?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<in>


in

in<in>:"in"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<select>


select<select>:"select"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<where>


Element Use Cases

C C++ C# Java
     

whereConstraint

whereConstraint<where>:"where"name":"constraint*;
C C++ C# Java
     

whereClause

whereClause<where>:"where"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<constraint>


constraint<constraint>:((nameText?)|"struct"|"class");

Parent Rules

Child Rules

Parent Tags

C C++ C# Java
     

<group>


group<group>:"group"expr?by?into?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<by>


by

by<by>:"by"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<into>


into<into>:"into"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<join>


join<join>:"join"expr?in?on?equals?into?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<equals>


equals<equals>:"equals"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<on>


on

on<on>:"on"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<let>


let

let<let>:"let"expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<orderby>


orderby<orderby>:"orderby"expr?<name>{"descending""ascending"}?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<try>


Parent Rules

Child Rules

Child Tags

C C++ C# Java
 

<throw>


Element Use Cases

C C++ C# Java
     

exceptionSpecification

exceptionSpecification<throw>:"throw"argumentList?;
C C++ C# Java
 

throw

throw<throw>:"throw"expr?";"?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
 

<catch>


Element Use Cases

C C++ C# Java
 

catch

catch<catch>:"catch"parameterList?block?;
C C++ C# Java
     

multiTypeCatch

multiTypeCatch<catch>:"catch"<parameter_list>{<parameter>{decl("|"decl)*simpleName?}}block?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<finally>


finally<finally>:"literal"block?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
   

<attribute>


Element Use Cases

C C++ C# Java
     

CSharpAttribute

CSharpAttribute<attribute>:"["expr"]";
C C++ C# Java
     

CPlusPlusAttribute

CPlusPlusAttribute<attribute>:"[["expr"]]";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

<annotation>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<argument_list>


Element Use Cases

C C++ C# Java

argumentList

argumentList<argument_list>:(("("(argument(","argument)*)?")")|("{"(argument(","argument)*)?"}"));
C C++ C# Java
 

templateArgumentList

templateArgumentList<argument_list>(agrumentListTypeAttr?):"<"(argument(","argument)*)?">";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

agrumentListTypeAttr


agrumentListTypeAttr@type:"template";

Parent Rules

Parent Tags

C C++ C# Java

<argument>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<parameter_list>


Element Use Cases

C C++ C# Java

parameterList

parameterList<parameter_list>:"("(parameter(","parameter)*)?")";
C C++ C# Java
 

templateParameterList

templateParameterList<parameter_list>:"<"(parameter(","parameter)*)?">";
C C++ C# Java
     

pseudoParameterList

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java
     

pseudoParameterListTypeAttr


pseudoParameterListTypeAttr@type:"pseudo";

Parent Rules

Parent Tags

C C++ C# Java

<parameter>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<decl>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<range>


range<range>:(":"|"in")expr?;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<expr>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<type>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

typeTypeAttr


This attribute is only used during the declaration of multiple variables of the same type. The element with this attribute may be empty.
typeTypeAttr@type:"prev";

Parent Rules

Parent Tags

C C++ C# Java

<call>


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

name


Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<name>


Element Use Cases

C C++ C# Java

simpleName

simpleName<name>:Identifier;

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<index>


index<index>:"["(expr|literal|name)?"]";

Parent Rules

Child Rules

Parent Tags

Child Tags

C C++ C# Java

<specifier>


specifier<specifier>:Text;

Parent Rules

Parent Tags

C C++ C# Java

<operator>


operator<operator>:Operator;

Parent Rules

Parent Tags

C C++ C# Java

<literal>


literal<literal>(literalTypeAttr):Text;

Parent Rules

Child Rules

Parent Tags

C C++ C# Java

literalTypeAttr


literalTypeAttr@type:("boolean"|"char"|"null"|"number"|"string"|"complex");

Parent Rules

Parent Tags

C C++ C# Java
   

<macro>


macro<macro>:Identifier;

Parent Rules

Parent Tags

C C++ C# Java

<modifier>


modifier<modifier>:Text;

Parent Rules

Parent Tags