idl.yy
来自「编译工具」· YY 代码 · 共 1,543 行 · 第 1/3 页
YY
1,543 行
| attr_dcl ';' { $$ = $1; } | op_dcl ';' { $$ = $1; } | pragma { $$ = 0; } | error { IdlSyntaxError(currentFile, yylineno, "Syntax error in interface body"); $$ = 0; } ;interface_inheritance_spec_opt: /* empty */ { $$ = 0; } | interface_inheritance_spec { $$ = $1; } ;interface_inheritance_spec: ':' interface_inheritance_list { $$ = $2; } ;interface_inheritance_list: interface_name pragmas_opt { $$ = new InheritSpec($1, currentFile, yylineno); if (!$$->interface()) { delete $$; $$ = 0; } } | interface_inheritance_list ',' pragmas_opt interface_name pragmas_opt { if ($1) { $1->append(new InheritSpec($4, currentFile, yylineno), currentFile, yylineno); $$ = $1; } else $$ = new InheritSpec($4, currentFile, yylineno); } | error { IdlSyntaxError(currentFile, yylineno, "Syntax error in inheritance list"); $$ = 0; } ;interface_name: scoped_name { $$ = $1; } ;scoped_name: IDENTIFIER { $$ = new ScopedName($1, 0); } | SCOPE_DELIM IDENTIFIER { $$ = new ScopedName($2, 1); } | scoped_name SCOPE_DELIM IDENTIFIER { $1->append($3); $$=$1; } ;/* The obvious way to specify valuetypes isn't LALR(1), but the following is:*/value: value_dcl { $$ = $1; } | value_abs_dcl { $$ = $1; } | value_box_dcl { $$ = $1; } | value_forward_dcl { $$ = $1; } ;value_forward_dcl: VALUETYPE IDENTIFIER { $$ = new ValueForward(currentFile, yylineno, mainFile, 0, $2); } | ABSTRACT VALUETYPE IDENTIFIER { $$ = new ValueForward(currentFile, yylineno, mainFile, 1, $3); } ;value_box_dcl: VALUETYPE IDENTIFIER type_spec { $$ = new ValueBox(currentFile, yylineno, mainFile, $2, $3->type(), $3->constr()); delete $3; } ;value_abs_dcl: ABSTRACT VALUETYPE IDENTIFIER { valueabs_hack = new ValueAbs(currentFile, yylineno, mainFile, $3, 0, 0); } '{' export_star '}' { valueabs_hack->finishConstruction($6); $$ = valueabs_hack; valueabs_hack = 0; } | ABSTRACT VALUETYPE IDENTIFIER value_inheritance_spec { valueabs_hack = new ValueAbs(currentFile, yylineno, mainFile, $3, $4->inherits(), $4->supports()); delete $4; } '{' export_star '}' { valueabs_hack->finishConstruction($7); $$ = valueabs_hack; valueabs_hack = 0; } | error { IdlSyntaxError(currentFile, yylineno, "Syntax error in abstract valuetype"); if (valueabs_hack) { valueabs_hack->finishConstruction(0); $$ = valueabs_hack; valueabs_hack = 0; } else $$ = 0; } ;value_dcl: value_header '{' value_element_star '}' { $1->finishConstruction($3); $$ = $1; } ;value_header: VALUETYPE IDENTIFIER value_inheritance_spec { $$ = new Value(currentFile, yylineno, mainFile, 0, $2, $3->inherits(), $3->supports()); delete $3; } | CUSTOM VALUETYPE IDENTIFIER value_inheritance_spec { $$ = new Value(currentFile, yylineno, mainFile, 1, $3, $4->inherits(), $4->supports()); delete $4; } | VALUETYPE IDENTIFIER { $$ = new Value(currentFile, yylineno, mainFile, 0, $2, 0, 0); } | CUSTOM VALUETYPE IDENTIFIER { $$ = new Value(currentFile, yylineno, mainFile, 1, $3, 0, 0); } ;value_inheritance_spec: ':' value_value_inheritance_spec SUPPORTS interface_inheritance_list { $$ = new ValueInheritSupportSpec($2, $4); } | ':' value_value_inheritance_spec { $$ = new ValueInheritSupportSpec($2, 0); } | SUPPORTS interface_inheritance_list { $$ = new ValueInheritSupportSpec(0, $2); } ;value_value_inheritance_spec: truncatable_opt value_inheritance_list { if ($1) $2->setTruncatable(); $$ = $2; } ;truncatable_opt: /* empty */ { $$ = 0; } | TRUNCATABLE { $$ = 1; } ;value_inheritance_list: value_name { $$ = new ValueInheritSpec($1, currentFile, yylineno); if (!$$->value()) { delete $$; $$ = 0; } } | value_inheritance_list ',' value_name { if ($1) { $1->append(new ValueInheritSpec($3, currentFile, yylineno), currentFile, yylineno); $$ = $1; } else $$ = new ValueInheritSpec($3, currentFile, yylineno); } ;value_name: scoped_name { $$ = $1; } ;value_element_star: /* empty */ { $$ = 0; } | value_element_star value_element { if ($1) { $1->append($2); $$ = $1; } else $$ = $2; } ;value_element: export { $$ = $1; } | state_member { $$ = $1; } | init_dcl { $$ = $1; } ;state_member: member_access type_spec declarators ';' { $$ = new StateMember(currentFile, yylineno, mainFile, $1, $2->type(), $2->constr(), $3); delete $2; } ;member_access: PUBLIC { $$ = 0; } | PRIVATE { $$ = 1; } ;init_dcl: init_dcl_header '(' init_param_decls_opt ')' { $1->closeParens(); } ';' { $1->finishConstruction($3); $$ = $1; } | init_dcl_header '(' error ')' { $1->closeParens(); } ';' { IdlSyntaxError(currentFile, yylineno, "Syntax error in factory parameters"); $1->finishConstruction(0); $$ = $1; } ;init_dcl_header: FACTORY IDENTIFIER { $$ = new Factory(currentFile, yylineno, mainFile, $2); } ;init_param_decls_opt: /* empty */ { $$ = 0; } | init_param_decls { $$ = $1; } ;init_param_decls: init_param_decl { $$ = $1; } | init_param_decls ',' init_param_decl { if ($1) { $1->append($3); $$ = $1; } else $$ = $3; } ;init_param_decl: IN param_type_spec IDENTIFIER { $$ = new Parameter(currentFile, yylineno, mainFile, 0, $2, $3); } ;// End of ValueType nastinessconst_dcl: CONST const_type IDENTIFIER '=' const_exp { $$ = new Const(currentFile, yylineno, mainFile, $2, $3, $5); } ;const_type: integer_type { $$ = $1; } | char_type { $$ = $1; } | wide_char_type { $$ = $1; } | boolean_type { $$ = $1; } | floating_pt_type { $$ = $1; } | string_type { $$ = $1; } | wide_string_type { $$ = $1; } | fixed_pt_const_type { $$ = $1; } | scoped_name { $$ = IdlType::scopedNameToType(currentFile, yylineno, $1); } | octet_type { $$ = $1; } ;const_exp: or_expr { $$ = $1; } ;or_expr: xor_expr { $$ = $1; } | or_expr '|' xor_expr { $$ = new OrExpr(currentFile, yylineno, $1, $3); } ;xor_expr: and_expr { $$ = $1; } | xor_expr '^' and_expr { $$ = new XorExpr(currentFile, yylineno, $1, $3); } ;and_expr: shift_expr { $$ = $1; } | and_expr '&' shift_expr { $$ = new AndExpr(currentFile, yylineno, $1, $3); } ;shift_expr: add_expr { $$ = $1; } | shift_expr RIGHT_SHIFT add_expr { $$ = new RShiftExpr(currentFile, yylineno, $1, $3); } | shift_expr LEFT_SHIFT add_expr { $$ = new LShiftExpr(currentFile, yylineno, $1, $3); } ;add_expr: mult_expr { $$ = $1; } | add_expr '+' mult_expr { $$ = new AddExpr(currentFile, yylineno, $1, $3); } | add_expr '-' mult_expr { $$ = new SubExpr(currentFile, yylineno, $1, $3); } ;mult_expr: unary_expr { $$ = $1; } | mult_expr '*' unary_expr { $$ = new MultExpr(currentFile, yylineno, $1, $3); } | mult_expr '/' unary_expr { $$ = new DivExpr(currentFile, yylineno, $1, $3); } | mult_expr '%' unary_expr { $$ = new ModExpr(currentFile, yylineno, $1, $3); } ;unary_expr: unary_operator primary_expr { if ($1 == '-') $$ = new MinusExpr(currentFile, yylineno, $2); if ($1 == '+') $$ = new PlusExpr(currentFile, yylineno, $2); if ($1 == '~') $$ = new InvertExpr(currentFile, yylineno, $2); } | primary_expr { $$ = $1; } ;unary_operator: '-' { $$ = '-'; } | '+' { $$ = '+'; } | '~' { $$ = '~'; } ;primary_expr: scoped_name { $$ = IdlExpr::scopedNameToExpr(currentFile, yylineno, $1); } | literal { $$ = $1; } | '(' const_exp ')' { $$ = $2; } ;literal: INTEGER_LITERAL { $$ = new IntegerExpr(currentFile, yylineno, $1); } | string_literal_plus { $$ = new StringExpr(currentFile, yylineno, $1); } | wide_string_literal_plus { $$ = new WStringExpr(currentFile, yylineno, $1); } | CHARACTER_LITERAL { $$ = new CharExpr(currentFile, yylineno, $1); } | WIDE_CHARACTER_LITERAL { $$ = new WCharExpr(currentFile, yylineno, $1); } | FIXED_PT_LITERAL { $$ = new FixedExpr(currentFile, yylineno, $1); } | FLOATING_PT_LITERAL { $$ = new FloatExpr(currentFile, yylineno, $1); } | boolean_literal { $$ = new BooleanExpr(currentFile, yylineno, $1); } ;string_literal_plus: STRING_LITERAL { $$ = $1; } | string_literal_plus STRING_LITERAL { $$ = new char [strlen($1) + strlen($2) + 1]; strcpy($$, $1); strcat($$, $2); delete [] $1; delete [] $2; } ;wide_string_literal_plus: WIDE_STRING_LITERAL { $$ = $1; } | wide_string_literal_plus WIDE_STRING_LITERAL { $$ = new IDL_WChar [idl_wstrlen($1) + idl_wstrlen($2) + 1]; idl_wstrcpy($$, $1); idl_wstrcat($$, $2); delete [] $1; delete [] $2; } ;boolean_literal: TRUE_ { $$ = 1; } | FALSE_ { $$ = 0; } ;positive_int_const: const_exp { IdlLongVal v = $1->evalAsLongV(); if (v.negative || v.u == 0) IdlError(currentFile, yylineno, "Size must be at least 1"); $$ = v.u; } ;type_dcl: TYPEDEF type_declarator { $$ = $2; } | struct_type { $$ = $1; } | union_type { $$ = $1; } | enum_type { $$ = $1; } | NATIVE IDENTIFIER { $$ = new Native(currentFile, yylineno, mainFile, $2); } | constr_forward_decl { $$ = $1; } ;type_declarator: type_spec declarators { $$ = new Typedef(currentFile, yylineno, mainFile, $1->type(), $1->constr(), $2); delete $1; } ;type_spec: simple_type_spec { $$ = new TypeSpec($1, 0); } | constr_type_spec { $$ = new TypeSpec($1, 1); } ;simple_type_spec: base_type_spec { $$ = $1; } | template_type_spec { $$ = $1; } | scoped_name { $$ = IdlType::scopedNameToType(currentFile, yylineno, $1); } ;base_type_spec: floating_pt_type { $$ = $1; } | integer_type { $$ = $1; } | char_type { $$ = $1; } | wide_char_type { $$ = $1; } | boolean_type { $$ = $1; } | octet_type { $$ = $1; } | any_type { $$ = $1; } | object_type { $$ = $1; } | value_base_type { $$ = $1; } ;template_type_spec: sequence_type { $$ = $1; } | string_type { $$ = $1; } | wide_string_type { $$ = $1; } | fixed_pt_type { $$ = $1; } ;constr_type_spec: struct_type { $$ = $1->thisType(); } | union_type { $$ = $1->thisType(); } | enum_type { $$ = $1->thisType(); } ;declarators: declarator pragmas_opt { $$ = $1; } | declarators ',' pragmas_opt declarator pragmas_opt { if ($1) { $1->append($4); $$ = $1; } else $$ = $4; } ;declarator: simple_declarator { $$ = $1; } | complex_declarator { $$ = $1; } ;simple_declarator: IDENTIFIER { $$ = new Declarator(currentFile, yylineno, mainFile, $1, 0); } ;complex_declarator: array_declarator { $$ = $1; } ;floating_pt_type: FLOAT { $$ = BaseType::floatType; } | DOUBLE { $$ = BaseType::doubleType; } | LONG DOUBLE { $$ = BaseType::longdoubleType; } ;integer_type: signed_int { $$ = $1; } | unsigned_int { $$ = $1; } ;signed_int: signed_short_int { $$ = $1; } | signed_long_int { $$ = $1; } | signed_long_long_int { $$ = $1; } ;signed_short_int: SHORT { $$ = BaseType::shortType; } ;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?