0% found this document useful (0 votes)
308 views

Ada Syntax Card

The document contains syntax definitions for various elements of the Ada programming language including task types, protected types, subtypes, subprogram specifications, package specifications, and more. It uses "::=" notation to define the expansion or structure of each language element. The definitions are presented in a structured format with indentation to show the relationships between language elements.

Uploaded by

Sneetsher Crispy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
308 views

Ada Syntax Card

The document contains syntax definitions for various elements of the Ada programming language including task types, protected types, subtypes, subprogram specifications, package specifications, and more. It uses "::=" notation to define the expansion or structure of each language element. The definitions are presented in a structured format with indentation to show the relationships between language elements.

Uploaded by

Sneetsher Crispy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

subtype_name; ← DISCRIM ::=

Ada SYNTAX CARD | task type id [discrim] [is (id {,id} : [access] subtype_name [:= expr] {; ...})
bold Ada keyword italic Ada 95 {entry id [(discrete_range)] [formals]; | rep_clause}
[] Optional term {} Repeatable [ private {entry id [(discrete_range)] [formals]; | rep_clause}] ← LIST ::=
end [id]]; id {,id} : [aliased] subtype_id [:= expr]; | rep_clause {...}
| Alternative \\ Choose one
| protected type id [discrim] is | {id {,id} : [aliased] subtype_id [:= expr]; | rep_clause {...}}
... Identical term ::= Expansion term
{ subprogram_spec | entry id [(discrete_range)] [formals]; | rep_clause } case name is
[ private { subprogram_spec | entry id [(discrete_range)] [formals]; | when \expr|discrete_range|others\ {| ...} => list
LIBRARY id {,id} : [aliased] subtype_id [:= expr]; | rep_clause } ] {...}
end [id]; end case;
| null;
← COMPILATION_UNIT ::= | type id [(<>)|discrim];
{with library_unit_name {,...}; | use_clause} library_item | type id [(<>)|discrim] is [[abstract] tagged] [limited] private;
| {with library_unit_name {,...}; | use_clause} separate (parent_name) | type id [(<>)|discrim] is [abstract] new ancestor_subtype_id with private; ← DECLARATIVE_ITEM ::=
basic_declarative_item
\subprogram_body|package_body|task_body|protected_body\ | subtype id is subtype_id;
| subprogram_body | package_body | task_body | protected_body
| id {,id} : [aliased] [constant] subtype_id [:= expr];
| subprogram_spec is separate; | package body id is separate;
← USE_CLAUSE ::= | id {,id} : [aliased] [constant] array_type_defn [:= expr];
| task body id is separate; | protected body id is separate;
use pack_name {,...}; | use type subtype_name {,...}; | task id [is
{entry id [(discrete_range)] [formals]; | rep_clause}
← LIBRARY_ITEM ::= ← BASIC_DECLARATIVE_ITEM ::=
[ private {entry id [(discrete_range)] [formals]; | rep_clause}] basic_declaration | rep_clause | use_clause
[private] subprogram_spec; | [private] package_spec; end [id]];
| [private] generic {generic_formals|use_clause} subprogram_spec; | protected id is ← SUBPROGRAM_SPEC ::=
| [private] generic {generic_formals|use_clause} package_spec; { subprogram_spec | entry id [(discrete_range)] [formals]; | rep_clause } procedure [parent_name.]id [formals]
| [private] package [parent_name.]id is new gen_pack_name [ private { subprogram_spec | entry id [(discrete_range)] [formals]; | | function [parent_name.]id|op [formals] return subtype_name
[generic_actuals]; id {,id} : [aliased] subtype_id [:= expr]; | rep_clause } ]
| [private] procedure [parent_name.]id is new gen_proc_name end [id]; ← FORMALS ::=
[generic_actuals]; | id {,id} : constant := static_expr; ( id {,id} : [in | in out | out | access] subtype_name [:= expr] {; ...})
| [private] function [parent_name.]id|op is new gen_func_name | subprogram_spec [is abstract];
[generic_actuals]; | package_spec; ← SUBPROGRAM_BODY ::=
| subprogram_body; | package_body; | id : subtype_name renames object_name; subprogram_spec is
| [private] package [parent_name.]id renames pack_name; | id : exception renames exception_name; {declarative_item}
| [private] generic package [parent_name.]id renames | package id renames pack_name; begin handled_statements
gen_pack_name; | subprogram_spec renames callable_entity_name; end [id];
| [private] generic procedure [parent_name.]id renames | generic package id renames gen_pack_name;
gen_proc_name; | generic procedure id renames gen_proc_name; ← PACKAGE_SPEC ::=
| [private] generic function [parent_name.]id renames package [parent_name.]id is
| generic function id renames gen_func_name;
gen_func_name; {basic_declarative_item}
| id {,id} : exception;
| [private] subprogram_spec renames callable_entity_name; [private {basic_declarative_item}]
| generic {generic_formals|use_clause} subprogram_spec;
end [[parent_name.]id];
| generic {generic_formals|use_clause} package_spec;
DECLARATIONS | package id is new gen_pack_name [generic_actuals];
← PACKAGE_BODY ::=
| procedure id is new gen_proc_name [generic_actuals]; package body [parent_name.]id is
| function id|op is new gen_func_name [generic_actuals]; {declarative_item}
← BASIC_DECLARATION ::=
[begin handled_statements]
type id is ( \id|'character'\ {,...}); ← SUBTYPE_ID ::= end [[parent_name.]id];
| type id is mod static_expr; subtype_name
| type id is digits static_expr [rangestatic_s_expr .. static_s_expr]; | subtype_name range name'Range[(static_expr)]
| type id is [delta static_expr] range static_s_expr .. static_s_expr; ← TASK_BODY ::=
| subtype_name range s_expr .. s_expr task body id is
| type id is delta static_expr digits static_expr [range | subtype_name [digits|delta] static_expr [range name'Range[(static_expr)] {declarative_item}
static_s_expr .. static_s_expr]; | subtype_name [digits|delta] static_expr [range s_expr .. s_expr] begin
| type id [discrim] is [abstract] new subtype_id [with record list | subtype_name (discrete_range {,...}) handled_statements
end record]; | subtype_name ([selector_name {|...} =>] expr {,...}) end [id];
| type id [discrim] is [abstract] new subtype_id [with null record];
| type id is array_type_defn; ← ARRAY_TYPE_DEFN ::= ← PROTECTED_BODY ::=
| type id [discrim] is [[abstract] tagged] [limited] record list array(subtype_name range <> {,...}) of [aliased] subtype_id protected body id is
end record; | array(discrete_range {,...}) of [aliased] subtype_id { subprogram_spec | subprogram_body |
| type id [discrim] is [abstract] tagged [limited] null record; entry id1 [(for id2 in discrete_range)] [formals] when bool_expr is
| type id is access [all | constant] subtype_id; ← DISCRETE_RANGE ::= {declarative_item}
| type id is access [protected] procedure [formals]; discrete_subtype_id | name'Range[(static_expr)] | s_expr .. s_expr
begin handled_statements
| type id is access [protected] function [formals] return end [id1]; |
rep_clause } | s_expr [not] in subtype_name accept id [(expr)] [formals] [do handled_statements end [id]];
end [id]; [statement {...}]
← S_EXPR ::= | delay_statement [statement {...}]
← GENERIC_FORMALS ::= [+|-] term {\+|-|&\ term} | terminate;
id {,id} : [in] subtype_name [:= expr]; { or
| type id[(<>)|discrim] is [[abstract] tagged] [limited] private; ← TERM ::= [when bool_expr =>]
| type id[(<>)|discrim] is [abstract] new subtype_name [with private]; factor {\*|/|mod|rem\ factor}
accept id [(expr)] [formals] [do handled_statements end [id]];
| type id is (<>); [statement {...}]
| type id is range <>; ← FACTOR ::=
primary [** primary] | abs primary | not primary | delay_statement [statement {...}]
| type id is mod <>; | terminate; }
| type id is digits <>;
← PRIMARY ::= [ else statement {...} ]
| type id is delta <> [digits <>]; numeric_literal | null | string_literal | aggregate | name end select;
| type id is array_type_defn; | subtype_name'(expr) | subtype_name'aggregate | new subtype_id | select
| type id is access [all | constant] subtype_id; | new subtype_name'(expr) | new subtype_name'aggregate | (expr) entry_call_statement [statement {...}]
| type id is access [protected] procedure [formals]; or delay_statement [statement {...}]
| type id is access [protected] function [formals] ← STATEMENT ::= end select;
return subtype_name; [<<label>>] program_statement | select
| with subprogram_spec [is \name|<>\]; entry_call_statement [statement {...}]
| with package id is new gen_pack_name \(<>)|[generic_actuals]\; ← PROGRAM_STATEMENT ::= else statement {...}
| var_name := expr; | exit [loop_name] [when bool_expr]; end select;
← GENERIC_ACTUALS ::= | goto label; | null; | select
([selector_name =>] \expr|var_name|subprog_name|entry_name| | return [expr]; | entry_call_statement \entry_call_statement|delay_statement\ [statement {...}]
subtype_name|pack_inst_name\ {,...}) | delay_statement | requeue entry_name [with abort]; then abort statement {...}
| abort task_name {,...}; | raise [exception_name]; end select;
| subtype_name'(expr); | subtype_name'aggregate;
STATEMENTS, EXPRESSIONS | proc_name [([selector_name =>] \expr|var_name\ {,...})];
| if bool_expr then REPRESENTATION
← NAME ::= statement {...}
id | op | name.all
| name(expr {,...}) | name(discrete_range)
{elsif bool_expr then statement {...}} ← REP_CLAUSE ::=
[else statement {...}] for local_name'attribute_designator use expr;
| name.selector_name | name'attribute_designator end if; | for local_name'attribute_designator use name;
| subtype_name(expr|name) | 'character' | case expr is | for first_subtype_local_name use array_aggregate;
| func_name [([selector_name =>] \expr|var_name\ {,...})] when \expr|discrete_range|others\ {| ...} => statement {...} | for first_subtype_local_name use record [at mod static_expr;]
{...} {component_name at static_expr range static_s_expr..static_s_expr;}
← SELECTOR_NAME ::= end case;
id | 'character' | op end record;
| [id:] [while bool_expr | for id in [reverse] discrete_range] loop | for \id|op\ use at expr;
statement {...}
← ATTRIBUTE_DESIGNATOR ::=
id[(static_expr)] | Access | Delta | Digits end loop [id]; ← LOCAL_NAME ::=
| [id:] [declare {declarative_item}] id['attribute_designator] | op['attribute_designator] | library_unit_name
← AGGREGATE ::= begin handled_statements
array_aggregate end [id];
| ([\expr|subtype_name\ with] [selector_name {|...} => | accept id [(expr)] [formals] [do handled_statements end [id]];
LEXICAL
| others => ] expr {,...}) | select_statement
id ::= identifier_letter {[underline] letter_or_digit}
| ([\expr|subtype_name\ with] null record)
letter_or_digit ::= identifier_letter | digit
← HANDLED_STATEMENTS ::=
numeric_literal ::= numeral [.numeral] [exponent] | numeral
← ARRAY_AGGREGATE ::= statement {...}
(expr, expr {,...}) | (expr {,...}, others => expr) [exception #base [.base] # [exponent]
| (\expr|discrete_range|others\ {|...} => expr {,...}) when [id:] \exception_name|others\ {| ...} => statement {...} numeral ::= digit {[underline] digit}
{...}] exponent ::= E [[+]|-] numeral
← EXPR ::= base ::= extended_digit {[underline] extended_digit}
relation {xor relation} ← ENTRY_CALL_STATEMENT ::= extended_digit ::= digit | A | B | C | D | E | F
| relation {and relation} | relation {and then relation} entry_name [([selector_name =>] \expr|var_name\ {,...})]; string_literal ::= "{"" | non_quote_character}"
| relation {or relation} | relation {or else relation} comment ::= --
← DELAY_STATEMENT ::= op ::= "<" | ">" | "=" | "&" | "<=" | ">=" | "+" | "/" | "*"
← RELATION ::= delay [until] delay_expr; pragma ::= pragma id [([id =>] \name|expr\ {,...})];
s_expr [\= | /= | < | <= | > | >=\ s_expr]
| s_expr [not] in name'Range[(static_expr)] ← SELECT_STATEMENT ::=
| s_expr [not] in s_expr .. s_expr select
[when bool_expr =>] Version 1.3 1995 DAINA. email:[email protected]

You might also like