⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ada.y

📁 现将本人搜集常用的程序设计语言的词法和形式文法提供给大家。其中
💻 Y
📖 第 1 页 / 共 2 页
字号:
	condal_ent_call |
	timed_ent_call;


/* 9.7.1 */
selec_wait	:
	SELECT_
	  select_alt
	..OR__select_alt..
	.ELSE__seq_of_stmts.
	END_ SELECT_ ';';

select_alt	:
	.WHEN__condARROW.selec_wait_alt;

selec_wait_alt	:
	accept_alt |
	delay_alt |
	terminate_alt;

accept_alt	: accept_stmt.seq_of_stmts.;

delay_alt	: delay_stmt.seq_of_stmts.;

terminate_alt	: TERM_stmt;


/* 9.7.2 */
condal_ent_call	:
	SELECT_
	  ent_call_stmt
	  .seq_of_stmts.
	ELSE_
	  seq_of_stmts
	END_ SELECT_ ';';


/* 9.7.3 */
timed_ent_call	:
	SELECT_
	  ent_call_stmt
	  .seq_of_stmts.
	OR_
	  delay_alt
	END_ SELECT_ ';';


/* 9.10 */
abort_stmt	: ABORT_ name ...name.. ';';


/* 10.1 */
compilation	: ..compilation_unit..;

compilation_unit	:
	context_cl library_unit |
	context_cl secondary_unit;

library_unit	:
	subprg_d |
	pkg_d |
	gen_d |
	gen_inst |
	subprg_body;

secondary_unit	:
	library_unit_body |
	subunit;

library_unit_body	: pkg_body_or_subprg_body;


/* 10.1.1 */
context_cl	: ..with_cl..use_cl....;

with_cl	: WITH_ sim_n ...sim_n.. ';';


/* 10.2 */
body_stub	:
	subprg_spec IS_ SEPARATE_ ';' |
	PACKAGE_ BODY_ sim_n IS_ SEPARATE_ ';' |
	TASK_ BODY_ sim_n IS_ SEPARATE_ ';';

subunit	: SEPARATE_ '(' expanded_n ')' proper_body;


/* 11.1 */
excptn_d	: idents ':' EXCEPTION_ ';';


/* 11.2 */
excptn_handler	:
	WHEN_ excptn_choice ..or_excptn_choice.. ARROW_
	  seq_of_stmts;

excptn_choice	:
	expanded_n |
	OTHERS_	;


/* 11.3 */
raise_stmt	: RAISE_ .expanded_n. ';';


/* 12.1 */
gen_d	: gen_spec ';';

gen_spec	:
	gen_fml_part subprg_spec |
	gen_fml_part pkg_spec;

gen_fml_part	: GENERIC_ ..gen_prm_d..;

gen_prm_d	:
	idents ':' .IN.OUT.. ty_mk ._ASN_expr. ';' |
	TYPE_ identifier IS_ gen_ty_def ';' |
	priv_ty_d |
	WITH_ subprg_spec .IS_BOX_. ';';
/*
 * this rule is included in the previous one
 *	WITH_ subprg_spec .IS_ name. ';'
 */

gen_ty_def	:
	'(' BOX_ ')' |
	RANGE_ BOX_ |
	DIGITS_ BOX_ |
	DELTA_ BOX_ |
	array_ty_def |
	access_ty_def;


/* 12.3 */
gen_inst	:
	PACKAGE_ identifier IS_ NEW_ expanded_n .gen_act_part. ';' |
	PROCEDURE__ident__IS_ NEW_ expanded_n .gen_act_part. ';' |
	FUNCTION_ designator IS_ NEW_ expanded_n .gen_act_part. ';';

gen_act_part	: '(' gen_asc ...gen_asc.. ')';

gen_asc	: .gen_fml_prmARROW.gen_act_prm;

gen_fml_prm	:
	sim_n |
	op_symbol;

gen_act_prm	: expr_or_name_or_subprg_n_or_ent_n_or_ty_mk;


/* 13.1 */
rep_cl	:
	ty_rep_cl |
	address_cl;

ty_rep_cl	:
	length_cl |
	enum_rep_cl |
	rec_rep_cl;


/* 13.2 */
length_cl	: FOR_ attribute USE_ sim_expr ';';


/* 13.3 */
enum_rep_cl	: FOR__ty_sim_n__USE_ aggr ';';


/* 13.4 */
rec_rep_cl	:
	FOR__ty_sim_n__USE_ RECORD_ .algt_cl.
	  ..cmpon_cl..
	END_ RECORD_ ';';

algt_cl	: AT_ MOD_ sim_expr ';';

cmpon_cl	: name AT_ sim_expr RANGE_ rng ';';


/* 13.5 */
address_cl	: FOR_ sim_n USE_ AT_ sim_expr ';';


/* 13.8 */
code_stmt	: ty_mk_rec_aggr ';';


/*
 * The following rules define semantically qualified symbols under more
 * general categories.
 *
 * ty_n_or_subty_n	: expanded_n;
 *
 * An expanded_n is used for names that can be written using only selectors.
 *
 * ... these have been replaced logically to reduce the number of YACC_
 * nonterminal "rules".
 *
 * The following rules expand the concatenated constructs and define the
 * specially added syntactical classes.
 */


/* 2.1 */
..prag..	:
	/* empty */ |
	..prag.. prag;

.arg_ascs	:
	/* empty */ |
	'(' arg_ascs ')';

arg_ascs	:
	arg_asc |
	arg_ascs ',' arg_asc;

/* name is included under expr */


/* 3.1 */

/* defer_const_d is included under object_d */

._ASN_expr.	:
	/* empty */ |
	ASSIGN_ expr;

...ident..	:
	/* empty */ |
	...ident.. ',' identifier;

.constrt.	:
	/* empty */ |
	constrt;

/* idx_cg and discr_c are included under aggr */

expanded_n	:
	identifier |
	expanded_n '.' identifier;

/*
 * This expansion generalizes rng so that it may include ty and
 * subty names.
 */

...enum_lit_spec..	:
	/* empty */ |
	...enum_lit_spec.. ',' enum_lit_spec;
.rng_c.	:
	/* empty */ |
	rng_c;

/* To avoid conflicts, the more general class name is used. */
...idx_subty_def..	:
	/* empty */ |
	...idx_subty_def.. ',' idx_subty_def;

/* A_ dscr subty ind given as a ty mk is included under rng */
...dscr_rng..	:
	/* empty */ |
	...dscr_rng.. ',' dscr_rng;

..cmpon_d..	:
	/* empty */ |
	..cmpon_d.. cmpon_d ..prag..;

...discr_spec..	:
	/* empty */ |
	...discr_spec.. ';' discr_spec;

/*
 * Pragmas that can appear between two consecutive variants are
 * picked up in the cmpons part of the variants themselves.
 */

..variant..	:
	/* empty */ |
	..variant.. variant;

..or_choice..	:
	/* empty */ |
	..or_choice.. '|' choice;

/*
 * The sim_expr by itself may be a dscr_rng or a "cmpon_sim_n".
 *
 * A_ body is the only later_decl_item that is not also a
 * basic_decl_item. It is therefore used as the dividing
 * point between the two lists of decl items.
 */

..basic_decl_item..	:
	..prag.. |
	..basic_decl_item.. basic_decl_item ..prag..;

..later_decl_item..	:
	..prag.. |
	..later_decl_item.. later_decl_item ..prag..;


/* 4.1 */

/* slice is included under idxed_cmpon */

/*
 * The def of name includes func_call.
 *
 * A prmless func call is recognized as a sim name or a selected cmpon.
 * A func call with prms is recognized as an idxed cmpon.
 *
 * Reserved word attribute designators are included in the rules as a
 * convenience. Alternativly, since an attribute designator is always preceded
 * by an apostrophe, as noted in the RR_ 4.1.4, such usage may be detected
 * during lexical analysis thus obviating the need for special rules.
 *
 * The univ static expr of an attribute designator is reduced as an idxed_cmpon.
 */

/*
 * Component ascs are generalized to include dscr rngs.
 * Thus, an aggr can be used for slices and idx and discr constrts.
 */
...cmpon_asc..	:
	/* empty */ |
	...cmpon_asc.. ',' cmpon_asc;

rel..AND__rel..	:
	rel AND_ rel |
	rel..AND__rel.. AND_ rel;

rel..OR__rel..	:
	rel OR_ rel |
	rel..OR__rel.. OR_ rel;

rel..XOR__rel..	:
	rel |
	..XOR__rel..;

..XOR__rel..	:
	rel XOR_ rel |
	..XOR__rel.. XOR_ rel;

rel..AND__THEN__rel..	:
	rel AND_ THEN_ rel |
	rel..AND__THEN__rel.. AND_ THEN_ rel;

rel..OR__ELSE__rel..	:
	rel OR_ ELSE_ rel |
	rel..OR__ELSE__rel.. OR_ ELSE_ rel;

.relal_op__sim_expr.	:
	/* empty */ |
	relal_op sim_expr;

/* ty_mk is included under rng */
sim_expr.NOT.IN__rng_or_sim_expr.NOT.IN__ty_mk	: sim_expr .NOT. IN_ rng;

.NOT.	:
	/* empty */ |
	NOT_;

.unary_add_op.term..binary_add_op__term..	:
	term |
	unary_add_op term |
	.unary_add_op.term..binary_add_op__term.. binary_add_op term;

factor..mult_op__factor..	:
	factor |
	factor..mult_op__factor.. mult_op factor;

/* stringsit is included under name as op_symbol */
/* func_call is included under name */
/* ty_cnvr is included under name */
._EXP___pri.	:
	/* empty */ |
	EXP_ pri;

/* The "prefix must be a "ty_mk". The "PexprP_" is an "aggr". */
ty_mkaggr_or_ty_mkPexprP_	: prefix '\'' aggr;

/*
 * Here the qualified_expr can be given exactly
 *
 * We use the fact that the constrt must be an idx or discr
 * constrt.
 */


/* 5.1 */
..stmt..	:
	..prag.. |
	..stmt.. stmt ..prag..;

..label..	:
	/* empty */ |
	..label.. label;

..ELSIF__cond__THEN__seq_of_stmts..	:
	/* empty */ |
	..ELSIF__cond__THEN__seq_of_stmts..
	ELSIF_ cond THEN_
	  seq_of_stmts;

.ELSE__seq_of_stmts.	:
	/* empty */ |
	ELSE_
	  seq_of_stmts;

case_stmt_alt..case_stmt_alt..	:
	..prag..
	case_stmt_alt
	..case_stmt_alt..;

..case_stmt_alt..	:
	/* empty */ |
	..case_stmt_alt.. case_stmt_alt;

.sim_nC.	:
	/* empty */ |
	sim_n ':';

.sim_n.	:
	/* empty */ |
	sim_n;

.iteration_scheme.	:
	/* empty */ |
	iteration_scheme;

.REVERSE.	:
	/* empty */ |
	REVERSE_;

.DECLARE__decl_part.	:
	/* empty */ |
	DECLARE_
	  decl_part;

.EXCEPTION__excptn_handler..excptn_handler...	:
	/* empty */ |
	EXCEPTION_
	  ..prag.. excptn_handlers;

excptn_handlers	:
	excptn_handler |
	excptn_handlers excptn_handler;

.expanded_n.	:
	/* empty */ |
	expanded_n;

.WHEN__cond.	:
	/* empty */ |
	WHEN_ cond;

.expr.	:
	/* empty */ |
	expr;


/* 6.1 */
.fml_part.	:
	/* empty */ |
	fml_part;

.._.prm_spec..	:
	/* empty */ |
	.._.prm_spec.. ';' prm_spec;

.IN.	:
	/* empty */ |
	IN_;

/* A "decl_part" may be empty.	*/
.decl_part.	: decl_part;

.designator.	:
	/* empty */ |
	designator;


/* 7.1	*/
.PRIVATE..basic_decl_item...	:
	/* empty */ |
	PRIVATE_
	  ..basic_decl_item..;

.BEGIN__seq_of_stmts.EXCEPTION__excptn_handler..excptn_handler...	:
	/* empty */ |
	BEGIN_
	  seq_of_stmts
	.EXCEPTION__excptn_handler..excptn_handler...;

.LIMITED.	:
	/* empty */ |
	LIMITED_;

...expanded_n..	:
	/* empty */ |
	...expanded_n.. ',' expanded_n;


/* 9.1 */
.TYPE.	:
	/* empty */ |
	TYPE_;

.IS..ent_d_..rep_cl_END.sim_n.	:
	/* empty */ |
	IS_
	  ..ent_d..
	  ..rep_cl..
	END_ .sim_n.;

..ent_d..	:
	..prag.. |
	..ent_d.. ent_d ..prag..;

..rep_cl..	:
	/* empty */ |
	..rep_cl.. rep_cl ..prag..;

.Pent_idx_P..fml_part.	:
	.fml_part. |
	'(' ent_idx ')' .fml_part.;

.DO__seq_of_stmts__END.sim_n..	:
	/* empty */ |
	DO_
	  seq_of_stmts
	END_ .sim_n.;

..OR__select_alt..	:
	/* empty */ |
	..OR__select_alt.. OR_ select_alt;

.WHEN__condARROW.selec_wait_alt	:
	selec_wait_alt |
	WHEN_ cond ARROW_ selec_wait_alt;

accept_stmt.seq_of_stmts.	: ..prag.. accept_stmt .seq_of_stmts.;

delay_stmt.seq_of_stmts.	: ..prag.. delay_stmt .seq_of_stmts.;

TERM_stmt	: ..prag.. TERMINATE_ ';' ..prag..;

.seq_of_stmts.	:
	..prag.. |
	seq_of_stmts;

...name..	:
	/* empty */ |
	...name.. ',' name;


/* 10.1 */
..compilation_unit..	:
	..prag.. |
	..compilation_unit..
	compilation_unit ..prag..;

/* "subprg_body" is already contained in the class "library_unit". */
pkg_body_or_subprg_body	: pkg_body;

..with_cl..use_cl....	:
	/* empty */ |
	..with_cl..use_cl.... with_cl use_cls;

use_cls	:
	..prag.. |
	use_cls use_cl ..prag..;

...sim_n..	:
	/* empty */ |
	...sim_n.. ',' sim_n;


/* 11.1 */
..or_excptn_choice..	:
	/* empty */ |
	..or_excptn_choice.. '|' excptn_choice;


/* 12.1 */
..gen_prm_d..	:
	/* empty */ |
	..gen_prm_d.. gen_prm_d;

.IN.OUT..	:
	.IN. |
	IN_ OUT_;

.IS_BOX_.	:
	/* empty */ |
	IS_ name |
	IS_ BOX_;

/* To avoid conflicts, the more general "subprg_spec" is used. */
PROCEDURE__ident__IS_	: subprg_spec IS_;

.gen_act_part.	:
	/* empty */ |
	gen_act_part;

...gen_asc..	:
	/* empty */ |
	...gen_asc.. ',' gen_asc;

.gen_fml_prmARROW.gen_act_prm	:
	gen_act_prm |
	gen_fml_prm ARROW_ gen_act_prm;

/* The below alts are included under expr */
expr_or_name_or_subprg_n_or_ent_n_or_ty_mk	: expr;


/* 13.1 */
/* The "sim_n" must be a "ty_sim_n". */
FOR__ty_sim_n__USE_	: FOR_ sim_n USE_;

.algt_cl.	:
	..prag.. |
	..prag.. algt_cl ..prag..;

..cmpon_cl..	:
	/* empty */ |
	..cmpon_cl.. cmpon_cl ..prag..;

/* The qualified expr must contain a rec aggr. */
ty_mk_rec_aggr	: qualified_expr;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -