Grammar extracted by Vadim Zaytsev, see the Grammar Zoo entry for details: ada/ada83/ichbiah/extracted
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]
identifier
, letter_or_digit
, letter
, number
, integer_number
, integer
, based_integer
, base
, extended_digit
, approximate_number
, exponent
, character_string
, pragma
, argument
, declaration
, object_declaration
, identifier_list
, type
, type_definition
, type_mark
, constraint
, type_declaration
, subtype_declaration
, derived_type_definition
, range_constraint
, range
, enumeration_type_definition
, enumeration_literal
, integer_type_definition
, real_type_definition
, accuracy_constraint
, array_type_definition
, index
, discrete_range
, index_constraint
, aggregate
, component_association
, choice
, record_type_definition
, component_list
, variant_part
, discriminant
, discriminant_constraint
, access_type_definition
, name
, indexed_component
, selected_component
, predefined_attribute
, literal
, variable
, expression
, relation
, simple_expression
, term
, factor
, primary
, logical_operator
, relational_operator
, adding_operator
, unary_operator
, multiplying_operator
, exponentiating_operator
, qualified_expression
, allocator
, seqence_of_statements
, statement
, simple_statement
, compound_statement
, assignment_statement
, subprogram_call_statement
, subprogram_call
, parameter_association
, formal_parameter
, actual_parameter
, return_statement
, if_statement
, condition
, case_statement
, loop_statement
, basic_loop
, iteration_specification
, loop_parameter
, exit_statement
, goto_statement
, assert_statement
, declarative_part
, body
, unit_body
, subprogram_declaration
, subprogram_specification
, subprogram_nature
, designator
, formal_part
, parameter_declaration
, mode
, subprogram_body
, block
, module_declaration
, module_specification
, module_nature
, module_body
, private_type_declaration
, visibility_restriction
, visibility_list
, use_clause
, renaming_declaration
, initiate_statement
, task_designator
, entry_declaration
, accept_statement
, delay_statement
, select_statement
, select_alternative
, abort_statement
, compilation
, compilation_unit
, body_stub
, exception_declaration
, exception_handler
, exception_choice
, raise_statement
, generic_clause
, generic_parameter
, generic_instantiation
, generic_association
, representation_specification
, packing_specification
, length_specification
, enumeration_type_representation
, record_type_representation
, location
, alignment_clause
, address_specification
, code_statement
), 0 root (—), 4 top (pragma
, logical_operator
, exponentiating_operator
, compilation
), 17 bottom (module_name
2, exception_name
2, underscore
3, character_literal
, upper_case_letter
, entry_name
, lower_case_letter
, type_name
4, subtype_name
, digit
4, component_name
2, character
, static_expression
4, constant_name
, subprogram_name
, unit_name
2, task_name
).identifier ::= letterunderscore 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 ::= digitunderscore 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 subtype_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 ::= "range" rangetype_mark
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"null" ";"variant_part
variant_part ::= "case" discriminant "of" "when" choice "|" choice "=>" component_list "end" "case" ";"
discriminant ::=
constant_name ".." component_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 "not" "in" range simple_expression "not" "in" type_mark constraintrelational_operator simple_expression simple_expression
simple_expression ::= unary_operatorterm adding_operator term
term ::= factormultiplying_operator factor
factor ::= primary "**" primary
primary ::= literal aggregate variable allocator subprogram_call qualified_expression "(" expression ")"
logical_operator ::= "and" "or" "xor"
relational_operator ::= "=" "/=" "<" "<=" ">" ">="
adding_operator ::= "+" "-" "&"
unary_operator ::= "+" "-" "not"
multiplying_operator ::= "*" "/" "mod"
exponentiating_operator ::=
"**"
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 "(" parameter_association "," parameter_association ")"
parameter_association ::= ":=" actual_parameter formal_parameter "=:" actual_parameter formal_parameter ":=:" actual_parameterformal_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_loopbasic_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_clausedeclaration representation_specification body
body ::=
visibility_restriction
unit_body
body_stubunit_body ::= subprogram_body module_specification module_body
subprogram_declaration ::= subprogram_specification ";" subprogram_nature designator "is" generic_instantiation ";"
subprogram_specification ::= generic_clause"return" type_mark constraintsubprogram_nature designator formal_part
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"(" discrete_range ")" "is" generic_instantiation ";"module_declaration module_nature identifier
module_specification ::= generic_clause"(" discrete_range ")" "is" declarative_part "private" declarative_part "end" identifier ";"module_nature identifier_list
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 "," unit_name ")"
use_clause ::= "use" module_name "," module_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 "(" discrete_range ")"
entry_declaration ::= "entry" identifier "(" discrete_range ")" formal_part ";"
accept_statement ::= "accept" entry_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_statementsdelay_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
"others"
raise_statement ::= "rause" exception_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 "is" name "." designator formal_parameter "is" type_markformal_parameter
representation_specification ::= packing_specification length_specification record_type_representation address_specification enumeration_type_representation
packing_specification ::= "for" type_name "use" "packing" ";"
length_specification ::= "for" name "use" static_expression ";"
enumeration_type_representation ::= "for" type_name "use" aggregate ";"
record_type_representation ::= "for" type_name "use" "record" alignment_clause ";" component_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 ";"