Browsable µOccam Grammar

CC-BY

Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: occam/mu/mitchell/extracted
Source used for this grammar: K. Mitchell, µOCCAM, Chapter 1, The Grammar for µOCCAM, 1995 [µOCCAM Manual]

Summary

Syntax

translation-unit ::=
	declaration-seq?
primary-expression ::=
	literal "this" "(" expression ")" id-expression
id-expression ::=
	unqualified-id qualified-id
unqualified-id ::=
	identifier operator-function-id conversion-function-id "~" class-name template-id
qualified-id ::=
	"::"? nested-name-specifier "template"? unqualified-id "::" identifier "::" operator-function-id "::" template-id
nested-name-specifier ::=
	class-or-namespace-name "::" nested-name-specifier? class-or-namespace-name "::" "template" nested-name-specifier
class-or-namespace-name ::=
	class-name namespace-name
postfix-expression ::=
	primary-expression postfix-expression "[" expression "]" postfix-expression "(" expression-list? ")" simple-type-specifier "(" expression-list? ")" "typename" "::"? nested-name-specifier identifier "(" expression-list? ")" "typename" "::"? nested-name-specifier "template"? template-id "(" expression-list? ")" postfix-expression "." "template"? id-expression postfix-expression "->" "template"? id-expression postfix-expression "." pseudo-destructor-name postfix-expression "->" pseudo-destructor-name postfix-expression "++" postfix-expression "--" "dynamic_cast" "<" type-id ">" "(" expression ")" "static_cast" "<" type-id ">" "(" expression ")" "reinterpret_cast" "<" type-id ">" "(" expression ")" "const_cast" "<" type-id ">" "(" expression ")" "typeid" "(" expression ")" "typeid" "(" type-id ")"
expression-list ::=
	assignment-expression expression-list "," assignment-expression
pseudo-destructor-name ::=
	"::"? nested-name-specifier? type-name "::" "~" type-name "::"? nested-name-specifier "template" template-id "::" "~" type-name "::"? nested-name-specifier? "~" type-name
unary-expression ::=
	postfix-expression "++" cast-expression "--" cast-expression unary-operator cast-expression "sizeof" unary-expression "sizeof" "(" type-id ")" new-expression delete-expression
unary-operator ::=
	"*"
	"&"
	"+"
	"-"
	"!"
	"~"
new-expression ::=
	"::"? "new" new-placement? new-type-id new-initializer? "::"? "new" new-placement? "(" type-id ")" new-initializer?
new-placement ::=
	"(" expression-list ")"
new-type-id ::=
	type-specifier-seq new-declarator?
new-declarator ::=
	ptr-operator new-declarator? direct-new-declarator
direct-new-declarator ::=
	"[" expression "]" direct-new-declarator "[" constant-expression "]"
new-initializer ::=
	"(" expression-list? ")"
delete-expression ::=
	"::"? "delete" cast-expression "::"? "delete" "[" "]" cast-expression
cast-expression ::=
	unary-expression "(" type-id ")" cast-expression
pm-expression ::=
	cast-expression pm-expression ".*" cast-expression pm-expression "->*" cast-expression
multiplicative-expression ::=
	pm-expression multiplicative-expression "*" pm-expression multiplicative-expression "/" pm-expression multiplicative-expression "%" pm-expression
additive-expression ::=
	multiplicative-expression additive-expression "+" multiplicative-expression additive-expression "-" multiplicative-expression
shift-expression ::=
	additive-expression shift-expression "<<" additive-expression shift-expression ">>" additive-expression
relational-expression ::=
	shift-expression relational-expression "<" shift-expression relational-expression ">" shift-expression relational-expression "<=" shift-expression relational-expression ">=" shift-expression
equality-expression ::=
	relational-expression equality-expression "==" relational-expression equality-expression "!=" relational-expression
and-expression ::=
	equality-expression and-expression "&" equality-expression
exclusive-or-expression ::=
	and-expression exclusive-or-expression "^" and-expression
inclusive-or-expression ::=
	exclusive-or-expression inclusive-or-expression "|" exclusive-or-expression
logical-and-expression ::=
	inclusive-or-expression logical-and-expression "&&" inclusive-or-expression
logical-or-expression ::=
	logical-and-expression logical-or-expression "||" logical-and-expression
conditional-expression ::=
	logical-or-expression logical-or-expression "?" expression ":" assignment-expression
assignment-expression ::=
	conditional-expression logical-or-expression assignment-operator assignment-expression throw-expression
assignment-operator ::=
	"="
	"*="
	"/="
	"%="
	"+="
	"-="
	">>="
	"<<="
	"&="
	"^="
	"|="
expression ::=
	assignment-expression expression "," assignment-expression
constant-expression ::=
	conditional-expression
statement ::=
	labeled-statement expression-statement compound-statement selection-statement iteration-statement jump-statement declaration-statement try-block
labeled-statement ::=
	identifier ":" statement "case" constant-expression ":" statement "default" ":" statement
expression-statement ::=
	expression? ";"
compound-statement ::=
	"{" statement-seq? "}"
statement-seq ::=
	statement statement-seq statement
selection-statement ::=
	"if" "(" condition ")" statement "if" "(" condition ")" statement "else" statement "switch" "(" condition ")" statement
condition ::=
	expression type-specifier-seq declarator "=" assignment-expression
iteration-statement ::=
	"while" "(" condition ")" statement "do" statement "while" "(" expression ")" ";" "for" "(" for-init-statement condition? ";" expression? ")" statement
for-init-statement ::=
	expression-statement simple-declaration
jump-statement ::=
	"break" ";" "continue" ";" "return" expression? ";" "goto" identifier ";"
declaration-statement ::=
	block-declaration
declaration-seq ::=
	declaration declaration-seq declaration
declaration ::=
	block-declaration function-definition template-declaration explicit-instantiation explicit-specialization linkage-specification namespace-definition
block-declaration ::=
	simple-declaration asm-definition namespace-alias-definition using-declaration using-directive
simple-declaration ::=
	decl-specifier-seq? init-declarator-list? ";"
decl-specifier ::=
	storage-class-specifier type-specifier function-specifier "friend" "typedef"
decl-specifier-seq ::=
	decl-specifier-seq? decl-specifier
storage-class-specifier ::=
	"auto" "register" "static" "extern" "mutable"
function-specifier ::=
	"inline" "virtual" "explicit"
typedef-name ::=
	identifier
type-specifier ::=
	simple-type-specifier class-specifier enum-specifier elaborated-type-specifier cv-qualifier
simple-type-specifier ::=
	"::"? nested-name-specifier? type-name "::"? nested-name-specifier "template" template-id "char" "wchar_t" "bool" "short" "int" "long" "signed" "unsigned" "float" "double" "void"
type-name ::=
	class-name enum-name typedef-name
elaborated-type-specifier ::=
	class-key "::"? nested-name-specifier? identifier "enum" "::"? nested-name-specifier? identifier "typename" "::"? nested-name-specifier identifier "typename" "::"? nested-name-specifier "template"? template-id
enum-name ::=
	identifier
enum-specifier ::=
	"enum" identifier? "{" enumerator-list? "}"
enumerator-list ::=
	enumerator-definition enumerator-list "," enumerator-definition
enumerator-definition ::=
	enumerator enumerator "=" constant-expression
enumerator ::=
	identifier
namespace-name ::=
	original-namespace-name namespace-alias
original-namespace-name ::=
	identifier
namespace-definition ::=
	named-namespace-definition unnamed-namespace-definition
named-namespace-definition ::=
	original-namespace-definition extension-namespace-definition
original-namespace-definition ::=
	"namespace" identifier "{" namespace-body "}"
extension-namespace-definition ::=
	"namespace" original-namespace-name "{" namespace-body "}"
unnamed-namespace-definition ::=
	"namespace" "{" namespace-body "}"
namespace-body ::=
	declaration-seq?
namespace-alias ::=
	identifier
namespace-alias-definition ::=
	"namespace" identifier "=" qualified-namespace-specifier ";"
qualified-namespace-specifier ::=
	"::"? nested-name-specifier? namespace-name
using-declaration ::=
	"using" "typename"? "::"? nested-name-specifier unqualified-id ";" "using" "::" unqualified-id ";"
using-directive ::=
	"using" "namespace" "::"? nested-name-specifier? namespace-name ";"
asm-definition ::=
	"asm" "(" string-literal ")" ";"
linkage-specification ::=
	"extern" string-literal "{" declaration-seq? "}" "extern" string-literal declaration
init-declarator-list ::=
	init-declarator init-declarator-list "," init-declarator
init-declarator ::=
	declarator initializer?
declarator ::=
	direct-declarator ptr-operator declarator
direct-declarator ::=
	declarator-id direct-declarator "(" parameter-declaration-clause ")" cv-qualifier-seq? exception-specification? direct-declarator "[" constant-expression? "]" "(" declarator ")"
ptr-operator ::=
	"*" cv-qualifier-seq? "&" "::"? nested-name-specifier "*" cv-qualifier-seq?
cv-qualifier-seq ::=
	cv-qualifier cv-qualifier-seq?
cv-qualifier ::=
	"const" "volatile"
declarator-id ::=
	id-expression "::"? nested-name-specifier? type-name
type-id ::=
	type-specifier-seq abstract-declarator?
type-specifier-seq ::=
	type-specifier type-specifier-seq?
abstract-declarator ::=
	ptr-operator abstract-declarator? direct-abstract-declarator
direct-abstract-declarator ::=
	direct-abstract-declarator? "(" parameter-declaration-clause ")" cv-qualifier-seq? exception-specification? direct-abstract-declarator? "[" constant-expression? "]" "(" abstract-declarator ")"
parameter-declaration-clause ::=
	parameter-declaration-list? "..."? parameter-declaration-list "," "..."
parameter-declaration-list ::=
	parameter-declaration parameter-declaration-list "," parameter-declaration
parameter-declaration ::=
	decl-specifier-seq declarator decl-specifier-seq declarator "=" assignment-expression decl-specifier-seq abstract-declarator? decl-specifier-seq abstract-declarator? "=" assignment-expression
function-definition ::=
	decl-specifier-seq? declarator ctor-initializer? function-body decl-specifier-seq? declarator function-try-block
function-body ::=
	compound-statement
initializer ::=
	"=" initializer-clause "(" expression-list ")"
initializer-clause ::=
	assignment-expression "{" initializer-list ","? "}" "{" "}"
initializer-list ::=
	initializer-clause initializer-list "," initializer-clause
class-name ::=
	identifier template-id
class-specifier ::=
	class-head "{" member-specification? "}"
class-head ::=
	class-key identifier? base-clause? class-key nested-name-specifier identifier base-clause? class-key nested-name-specifier? template-id base-clause?
class-key ::=
	"class" "struct" "union"
member-specification ::=
	member-declaration member-specification? access-specifier ":" member-specification?
member-declaration ::=
	decl-specifier-seq? member-declarator-list? ";" function-definition ";"? "::"? nested-name-specifier "template"? unqualified-id ";" using-declaration template-declaration
member-declarator-list ::=
	member-declarator member-declarator-list "," member-declarator
member-declarator ::=
	declarator pure-specifier? declarator constant-initializer? identifier? ":" constant-expression
pure-specifier ::=
	"=" "0"
constant-initializer ::=
	"=" constant-expression
base-clause ::=
	":" base-specifier-list
base-specifier-list ::=
	base-specifier base-specifier-list "," base-specifier
base-specifier ::=
	"::"? nested-name-specifier? class-name "virtual" access-specifier? "::"? nested-name-specifier? class-name access-specifier "virtual"? "::"? nested-name-specifier? class-name
access-specifier ::=
	"private" "protected" "public"
conversion-function-id ::=
	"operator" conversion-type-id
conversion-type-id ::=
	type-specifier-seq conversion-declarator?
conversion-declarator ::=
	ptr-operator conversion-declarator?
ctor-initializer ::=
	":" mem-initializer-list
mem-initializer-list ::=
	mem-initializer mem-initializer "," mem-initializer-list
mem-initializer ::=
	mem-initializer-id "(" expression-list? ")"
mem-initializer-id ::=
	"::"? nested-name-specifier? class-name identifier
operator-function-id ::=
	"operator" operator
operator ::=
	"new"
	"delete"
	"new" "[]"
	"delete" "[]"
	"+"
	"-"
	"*"
	"/"
	"%"
	"^"
	"&"
	"|"
	"~"
	"!"
	"="
	"<"
	">"
	"+="
	"-="
	"*="
	"/="
	"%="
	"^="
	"&="
	"|="
	"<<"
	">>"
	">>="
	"<<="
	"=="
	"!="
	"<="
	">="
	"&&"
	"||"
	"++"
	"--"
	","
	"->*"
	"->"
	"()"
	"[]"
template-declaration ::=
	"export"? "template" "<" template-parameter-list ">" declaration
template-parameter-list ::=
	template-parameter template-parameter-list "," template-parameter
template-parameter ::=
	type-parameter parameter-declaration
type-parameter ::=
	"class" identifier? "class" identifier? "=" type-id "typename" identifier? "typename" identifier? "=" type-id "template" "<" template-parameter-list ">" "class" identifier? "template" "<" template-parameter-list ">" "class" identifier? "=" id-expression
template-id ::=
	template-name "<" template-argument-list? ">"
template-name ::=
	identifier
template-argument-list ::=
	template-argument template-argument-list "," template-argument
template-argument ::=
	assignment-expression type-id id-expression
explicit-instantiation ::=
	"template" declaration
explicit-specialization ::=
	"template" "<" ">" declaration
try-block ::=
	"try" compound-statement handler-seq
function-try-block ::=
	"try" ctor-initializer? function-body handler-seq
handler-seq ::=
	handler handler-seq?
handler ::=
	"catch" "(" exception-declaration ")" compound-statement
exception-declaration ::=
	type-specifier-seq declarator type-specifier-seq abstract-declarator type-specifier-seq "..."
throw-expression ::=
	"throw" assignment-expression?
exception-specification ::=
	"throw" "(" type-id-list? ")"
type-id-list ::=
	type-id type-id-list "," type-id

GrammarLabMaintained by Dr. Vadim Zaytsev a.k.a. @grammarware. Last updated in September 2015. []