pas.bnf

来自「this is a lp0 compilator new」· BNF 代码 · 共 182 行

BNF
182
字号
program         : PROGRAM /*{its_a = "program"; }*/ newident external_files ';' block '.'external_files  : /*empty*/		| '(' /*{its_a = "external-file";}*/ newident_list ')' block           : opt_declarations statement_partopt_declarations: /*empty*/		| declarationsdeclarations    : declarations declaration		| declarationdeclaration     : label_dcl_part		| const_dcl_part		| type_dcl_part		| var_dcl_part		| proc_dcl_partlabel_dcl_part  : LABEL labels ';'labels          : labels ',' label 		| label label           : UNSIGNED_INT /* 0 <= value <= 9999 [6.1.6] */const_dcl_part  : CONST const_defs ';'const_defs      : const_defs ';' const_def 		| const_defconst_def       : /*{its_a="constant";}*/ newident '=' constantconstant        : unsigned_num 		| '+' unsigned_num		| '-' unsigned_num 		| ident   		| '+' ident 		| '-' ident		| STRING  /*type is char if len=1*/unsigned_num    : UNSIGNED_INT		| UNSIGNED_REALtype_dcl_part   : TYPE type_defs ';'type_defs       : type_defs ';' type_def		| type_deftype_def        : /*{its_a="type";}*/ newident '=' typetype            : simple_type		| PACKED struct_type 		| struct_type		| '^' IDENTIFIER  /*check forward reference semantics*/simple_type     : '(' /*{its_a="enumerated-literal";}*/ newident_list ')'		| constant DOTDOT constant		| identstruct_type     : ARRAY '[' index_t_list ']' OF type		| RECORD /*consider this a scope*/ field_list END		| SET OF simple_type 		| SFILE OF type index_t_list    : index_t_list ',' simple_type 		| simple_type field_list      : fixed_part 		| fixed_part ';' variant_part		| variant_part fixed_part      : fixed_part ';' record_section 		| record_section record_section  : /*{its_a="field";}*/ newident_list ':' type 		| /*empty*/variant_part    : CASE /*{its_a="field";}*/ tag_field OF variants tag_field       : newident ':' ident 		| ident   /*type*/variants        : variants ';' variant 		| variant variant         : case_label_list ':' '(' field_list ')' 		| /*empty*/var_dcl_part    : VAR variable_dcls ';' variable_dcls   : variable_dcls ';' variable_dcl 		| variable_dcl variable_dcl    : newident_list ':' type newident_list   : new_id_list /*{its_a="don't know";}*/new_id_list     : new_id_list ',' newident 		| newident proc_dcl_part   : proc_or_func proc_or_func    : proc_heading ';' body ';'     /*check if forward or fwd refd*/		| func_heading ';' body ';'  /*also func heading may be -type */proc_heading    : PROCEDURE newident formal_params func_heading    : FUNCTION newident formal_paramsfunction_form   : /*empty*/                     /*if forward referenced*/		| formal_params ':' ident body            : block     /* result determined in block */		| IDENTIFIER    /*directive-FORWARD*/ formal_params   : /*empty*/		| '(' {param_level++;} formal_p_sects ')' formal_p_sects  : formal_p_sects ';' formal_p_sect 		| formal_p_sect formal_p_sect   : param_group 		| VAR param_group 		| proc_heading		| /*{its_a="function-parameter";}*/ func_heading  param_group     : newident_list ':' paramtype 	paramtype       : ident 		| ARRAY '[' index_specs ']' OF paramtype 		| PACKED ARRAY '[' index_spec ']' OF ident index_specs     : index_specs ';' index_spec 		| index_spec index_spec      : newident DOTDOT newident ':' ident statement_part  : compound_stmtcompound_stmt   : SBEGIN statements ENDstatements      : statements ';' statement		| statementstatement       : /*empty*/		| label ':' statement		| compound_stmt		| assignment		| procedure_call		| GOTO label		| IF expression THEN statement		| IF expression THEN statement ELSE statement		| CASE expression OF case_list END		| WHILE expression DO statement		| REPEAT statements UNTIL expression		| FOR ident BECOMES simple_expr direction simple_expr DO statement		| WITH rec_var_list DO statement 		;direction       : TO		| DOWNTOassignment      : variable BECOMES expression   /* must test for fn_ident */procedure_call  : ident actual_paramsactual_params   :  /*empty*/		| '(' actuals_list ')'actuals_list    : actuals_list ',' actual_param		| actual_paramactual_param    : expression    /* which could be a variable or a proc/fn id */		| expression colon_things  /* only in i/o */colon_things    : ':' expression        /*integer*/		| ':' expression ':' expression case_list       : case_list ';' case_list_elem		| case_list_elemcase_list_elem  : case_label_list ':' statement		| /*empty*/case_label_list : case_label_list ',' case_label { /*nothing*/ }		| case_label { /*nothing*/ }case_label      : constant { /*nothing*/ }rec_var_list    : rec_var_list ',' record_var { /*nothing*/ }		| record_var { /*nothing*/ }expression      : simple_expr		| simple_expr relational_op simple_exprrelational_op   : '=' { /*nothing*/ }		| '<' { /*nothing*/ } 		| '>' { /*nothing*/ }		| LE  { /*nothing*/ }		| GE  { /*nothing*/ }		| NE  { /*nothing*/ }		| IN  { /*nothing*/ }		;simple_expr     : term		| '+' term		| '-' term		| simple_expr add_op termadd_op          : '+'		| '-'		| OR_TOKterm            : factor		| term mult_op factormult_op         : '*'		| '/'		| DIV		| MOD		| AND_TOKfactor          : variable              /* could be a const_ident of fn_call*/		| unsigned_lit		| '(' expression ')'		| set		| procedure_call		| NOT_TOK factorunsigned_lit    : unsigned_num		| STRING                        /*type is char if len=1*/		| NILset             : '[' member_list ']'member_list     : /*empty*/		| membersmembers         : members ',' member		| membermember          : expression		| expression DOTDOT expressionvariable        : ident		| variable '[' expressions ']'		| variable '.' ident		| variable '^'expressions     : expressions ',' expression		| expressionrecord_var      : variable { /*nothing*/ }ident           : IDENTIFIERnewident        : IDENTIFIER

⌨️ 快捷键说明

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