Browsable Ada 83 Grammar

CC-BY

Grammar connected by Vadim Zaytsev, see the Grammar Zoo entry for details: ada/ada83/ichbiah/connected
Source used for this grammar: Jean D. Ichbiah, Preliminary Ada reference manual; Syntax Summary, ACM SIGPLAN Notices, Volume 14 Issue 6a, June 1979, pages E-1 to E-5 (142-146) [DOI]

Summary

Syntax

identifier ::=
	letter (underscore? letter_or_digit)*
letter_or_digit ::=
	letter
	digit
letter ::=
	upper_case_letter
	lower_case_letter
number ::=
	integer_number
	approximate_number
integer_number ::=
	integer
	based_integer
integer ::=
	digit (underscore? digit)*
based_integer ::=
	base "#" extended_digit (underscore? extended_digit)*
base ::=
	integer
extended_digit ::=
	digit
	letter
approximate_number ::=
	integer "." integer ("E" exponent)?
	integer "E" exponent
exponent ::=
	"+"? integer
	"-" integer
character_string ::=
	""" character* """
pragma ::=
	"pragma" identifier ("(" argument ("," argument)* ")")? ";"
argument ::=
	identifier
	character_string
	number
declaration ::=
	object_declaration
	type_declaration
	subtype_declaration
	private_type_declaration
	subprogram_declaration
	module_declaration
	entry_declaration
	exception_declaration
	renaming_declaration
object_declaration ::=
	identifier_list ":" "constant"? type (":=" expression)? ";"
identifier_list ::=
	identifier ("," identifier)*
type ::=
	type_definition
	type_mark constraint?
type_definition ::=
	enumeration_type_definition
	integer_type_definition
	real_type_definition
	array_type_definition
	record_type_definition
	access_type_definition
	derived_type_definition
type_mark ::=
	⟨type_name⟩:namesubtype_name⟩:name
constraint ::=
	range_constraint
	accuracy_constraint
	index_constraint
	discriminant_constraint
type_declaration ::=
	"type" identifier ("is" type_definition)? ";"
subtype_declaration ::=
	"subtype" identifier "is" type_mark constraint? ";"
derived_type_definition ::=
	"new" type_mark constraint?
range_constraint ::=
	"range" range
range ::=
	simple_expression ".." simple_expression
enumeration_type_definition ::=
	"(" enumeration_literal ("," enumeration_literal)* ")"
enumeration_literal ::=
	identifier
	character_literal
integer_type_definition ::=
	range_constraint
real_type_definition ::=
	accuracy_constraint
accuracy_constraint ::=
	"digits" simple_expression range_constraint?
	"delta" simple_expression range_constraint?
array_type_definition ::=
	"array" "(" index ("," index)* ")" "of" type_mark constraint?
index ::=
	discrete_range
	type_mark
discrete_range ::=
	(type_mark "range")? range
index_constraint ::=
	"(" discrete_range ("," discrete_range)* ")"
aggregate ::=
	"(" component_association ("," component_association)* ")"
component_association ::=
	("choice" ("|" choice)* "=>")? expression
choice ::=
	simple_expression
	discrete_range
	"others"
record_type_definition ::=
	"record" component_list "end" "record"
component_list ::=
	object_declaration* variant_part?
	"null" ";"
variant_part ::=
	"case" discriminant "of" ("when" choice ("|" choice)* "=>" component_list)* "end" "case" ";"
discriminant ::=
	⟨constant_name⟩:name ".."component_name⟩:name
discriminant_constraint ::=
	aggregate
access_type_definition ::=
	"access" type
name ::=
	identifier
	indexed_component
	selected_component
	predefined_attribute
indexed_component ::=
	name "(" expression ("," expression)* ")"
selected_component ::=
	name "." identifier
predefined_attribute ::=
	name "'" identifier
literal ::=
	number
	enumeration_literal
	character_string
	"null"
variable ::=
	name ("(" discrete_range ")")?
	name "." "all"
expression ::=
	relation ("and" relation)*
	relation ("or" relation)*
	relation ("xor" relation)*
relation ::=
	simple_expression (relational_operator simple_expression)?
	simple_expression "not"? "in" range
	simple_expression "not"? "in" type_mark constraint?
simple_expression ::=
	unary_operator? term (adding_operator term)*
term ::=
	factor (multiplying_operator factor)*
factor ::=
	primary (exponentiating_operator primary)?
primary ::=
	literal
	aggregate
	variable
	allocator
	subprogram_call
	qualified_expression
	"(" expression ")"
relational_operator ::=
	"="
	"/="
	"<"
	"<="
	">"
	">="
adding_operator ::=
	"+"
	"-"
	"&"
unary_operator ::=
	"+"
	"-"
	"not"
multiplying_operator ::=
	"*"
	"/"
	"mod"
qualified_expression ::=
	type_mark "(" expression ")"
	type_mark aggregate
allocator ::=
	"new" qualified_expression
seqence_of_statements ::=
	statement*
statement ::=
	simple_statement
	compound_statement
	"<<" identifier ">>" statement
simple_statement ::=
	assignment_statement
	subprogram_call_statement
	exit_statement
	return_statement
	goto_statement
	assert_statement
	initiate_statement
	delay_statement
	raise_statement
	abort_statement
	code_statement
	"null" ";"
compound_statement ::=
	if_statement
	case_statement
	loop_statement
	accept_statement
	select_statement
	block
assignment_statement ::=
	variable ":=" expression
subprogram_call_statement ::=
	subprogram_call
subprogram_call ::=
	⟨subprogram_name⟩:name ("(" parameter_association ("," parameter_association)* ")")?
parameter_association ::=
	(formal_parameter ":=")? actual_parameter
	(formal_parameter "=:")? actual_parameter
	(formal_parameter ":=:")? actual_parameter
formal_parameter ::=
	identifier
actual_parameter ::=
	expression
return_statement ::=
	"return" expression? ";"
if_statement ::=
	"if" condition "then" seqence_of_statements ("elseif" condition "then" seqence_of_statements)* ("else" seqence_of_statements)? "end" "if" ";"
condition ::=
	expression ("and" "then" expression)*
	expression ("or" "else" expression)*
case_statement ::=
	"case" expression "of" ("when" choice ("|" choice)* "=>" seqence_of_statements)* "end" "case" ";"
loop_statement ::=
	iteration_specification? basic_loop
basic_loop ::=
	"loop" seqence_of_statements "end" "loop" identifier? ";"
iteration_specification ::=
	"for" loop_parameter "in" "reverse"? discrete_range
	"while" condition
loop_parameter ::=
	identifier
exit_statement ::=
	"exit" identifier? ("when" condition)? ";"
goto_statement ::=
	"goto" identifier ";"
assert_statement ::=
	"assert" condition ";"
declarative_part ::=
	use_clause? declaration* representation_specification* body*
body ::=
	visibility_restriction? unit_body
	body_stub
unit_body ::=
	subprogram_body
	module_specification
	module_body
subprogram_declaration ::=
	subprogram_specification ";"
	subprogram_nature designator "is" generic_instantiation ";"
subprogram_specification ::=
	generic_clause? subprogram_nature designator formal_part? ("return" type_mark constraint?)?
subprogram_nature ::=
	"function"
	"procedure"
designator ::=
	identifier
	character_string
formal_part ::=
	"(" parameter_declaration (";" parameter_declaration)* ")"
parameter_declaration ::=
	identifier_list ":" mode type_mark constraint? (":=" expression)?
mode ::=
	"in"?
	"out"
	"in" "out"
subprogram_body ::=
	subprogram_specification "is" declarative_part "begin" seqence_of_statements ("exception" exception_handler*)? "end" designator? ";"
block ::=
	("declare" declarative_part)? "begin" seqence_of_statements ("exception" exception_handler*)? "end" identifier? ";"
module_declaration ::=
	visibility_restriction? module_declaration
	module_nature identifier ("(" discrete_range ")")? "is" generic_instantiation ";"
module_specification ::=
	generic_clause? module_nature identifier_list ("(" discrete_range ")")? ("is" declarative_part ("private" declarative_part)? "end" identifier)? ";"
module_nature ::=
	"package"
	"task"
module_body ::=
	module_nature "body" identifier "is" declarative_part ("begin" seqence_of_statements)? ("exception" exception_handler*)? "end" identifier? ";"
private_type_declaration ::=
	"restricted"? "type" identifier "is" "private" ";"
visibility_restriction ::=
	"restricted" visibility_list?
visibility_list ::=
	"("unit_name⟩:name (","unit_name⟩:name)* ")"
use_clause ::=
	"use"module_name⟩:name (","module_name⟩:name)* ";"
renaming_declaration ::=
	identifier ":" type_mark "renames" name ";"
	identifier ":" "exception" "renames" name ";"
	subprogram_nature designator "renames" (name ".")? designator ";"
	module_nature identifier "renames" name ";"
initiate_statement ::=
	"initiate" task_designator ("," task_designator)* ";"
task_designator ::=
	⟨task_name⟩:name ("(" discrete_range ")")?
entry_declaration ::=
	"entry" identifier ("(" discrete_range ")")? formal_part? ";"
accept_statement ::=
	"accept"entry_name⟩:name formal_part? ("do" seqence_of_statements "end" identifier?)? ";"
delay_statement ::=
	"delay" simple_expression ";"
select_statement ::=
	"select" ("when" condition "=>")? select_alternative ("or" ("when" condition "=>")? select_alternative)* ("else" seqence_of_statements)? "end" "select" ";"
select_alternative ::=
	accept_statement seqence_of_statements?
	delay_statement seqence_of_statements?
abort_statement ::=
	"abort" task_designator ("," task_designator)* ";"
compilation ::=
	compilation_unit*
compilation_unit ::=
	visibility_restriction? "separate"? unit_body
body_stub ::=
	subprogram_specification "is" "separate" ";"
	module_nature "body" identifier "is" "separate" ";"
exception_declaration ::=
	identifier_list ":" "exception" ";"
exception_handler ::=
	"when" exception_choice ("|" exception_choice)* "=>" seqence_of_statements
exception_choice ::=
	⟨exception_name⟩:name
	"others"
raise_statement ::=
	"rause"exception_name⟩:name? ";"
generic_clause ::=
	"generic" ("(" generic_parameter (";" generic_parameter)* ")")?
generic_parameter ::=
	parameter_declaration
	subprogram_specification ("is" (name ".")? designator)?
	"restricted"? "type" identifier
generic_instantiation ::=
	"new" name ("(" generic_association ("," generic_association)* ")")?
generic_association ::=
	parameter_association
	(formal_parameter "is")? (name ".")? designator
	(formal_parameter "is")? type_mark
representation_specification ::=
	packing_specification
	length_specification
	record_type_representation
	address_specification
	enumeration_type_representation
packing_specification ::=
	"for"type_name⟩:name "use" "packing" ";"
length_specification ::=
	"for" name "use" static_expression ";"
enumeration_type_representation ::=
	"for"type_name⟩:name "use" aggregate ";"
record_type_representation ::=
	"for"type_name⟩:name "use" "record" (alignment_clause ";")? (component_name⟩:name location ";")* "end" "record" ";"
location ::=
	"at" static_expression "range" range
alignment_clause ::=
	"at" "mod" static_expression
address_specification ::=
	"for" name "use" "at" static_expression ";"
code_statement ::=
	qualified_expression ";"
exponentiating_operator ::=
	"**"
static_expression ::=
	expression

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