%{ /* * Copyright (c) 2010 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Apple Inc. ("Apple") nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Portions of this software have been released under the following terms: * * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC. * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION * * To anyone who acknowledges that this file is provided "AS IS" * without any express or implied warranty: * permission to use, copy, modify, and distribute this file for any * purpose is hereby granted without fee, provided that the above * copyright notices and this notice appears in all source code copies, * and that none of the names of Open Software Foundation, Inc., Hewlett- * Packard Company or Digital Equipment Corporation be used * in advertising or publicity pertaining to distribution of the software * without specific, written prior permission. Neither Open Software * Foundation, Inc., Hewlett-Packard Company nor Digital * Equipment Corporation makes any representations about the suitability * of this software for any purpose. * * Copyright (c) 2007, Novell, Inc. All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of Novell Inc. nor the names of its contributors * may be used to endorse or promote products derived from this * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * @APPLE_LICENSE_HEADER_END@ */ /* ** ** NAME: ** ** IDL.Y ** ** FACILITY: ** ** Interface Definition Language (IDL) Compiler ** ** ABSTRACT: ** ** This module defines the main IDL grammar accepted ** by the IDL compiler. ** ** VERSION: DCE 1.0 ** */ #include #include #include #include #include #include #include #define YYDEBUG 1 extern boolean search_attributes_table ; /* ** Local cells used for inter-production communication */ static ASTP_attr_k_t ASTP_bound_type; /* Array bound attribute */ /* An opaque pointer. */ #ifndef YY_TYPEDEF_YY_SCANNER_T #define YY_TYPEDEF_YY_SCANNER_T typedef void* yyscan_t; #endif typedef struct nidl_parser_state_t { yyscan_t nidl_yyscanner; unsigned nidl_yynerrs; parser_location_t nidl_location; } nidl_parser_state_t; static void nidl_yyerror (YYLTYPE *, nidl_parser_p, char const *); %} %locations %defines %error-verbose %pure-parser %name-prefix="nidl_yy" /* Tell Bison that the Flexer takes a yyscan_t parameter. */ %lex-param { void * lexxer } /* Tell Bison that we will pass the yyscan_t scanner into yyparse. */ %parse-param { nidl_parser_state_t * nidl } /* Tell Bison how to get the lexxer argument from the parser state. */ %{ #define lexxer nidl->nidl_yyscanner %} /* Declaration of yylval, yyval */ %union { NAMETABLE_id_t y_id ; /* Identifier */ long y_ptrlevels; /* levels of * for pointers */ long y_ptrclass; /* class of pointer */ STRTAB_str_t y_string ; /* String */ STRTAB_str_t y_float ; /* Float constant */ AST_export_n_t* y_export ; /* an export node */ AST_import_n_t* y_import ; /* Import node */ AST_exception_n_t* y_exception ; /* Exception node */ AST_constant_n_t* y_constant; /* Constant node */ AST_parameter_n_t* y_parameter ; /* Parameter node */ AST_type_n_t* y_type ; /* Type node */ AST_type_p_n_t* y_type_ptr ; /* Type pointer node */ AST_field_n_t* y_field ; /* Field node */ AST_arm_n_t* y_arm ; /* Union variant arm */ AST_operation_n_t* y_operation ; /* Routine node */ AST_interface_n_t* y_interface ; /* Interface node */ AST_case_label_n_t* y_label ; /* Union tags */ ASTP_declarator_n_t* y_declarator ; /* Declarator info */ ASTP_array_index_n_t* y_index ; /* Array index info */ nidl_uuid_t y_uuid ; /* Universal UID */ char y_char; /* character constant */ ASTP_attributes_t y_attributes; /* attributes flags */ AST_cpp_quote_n_t* y_cpp_quote; /* Quoted C within interface treated as one 'kind' of export node + quote outside interfaces */ struct { long int_val ; /* Integer constant */ AST_type_k_t int_size; int int_signed; } y_int_info; /* int size and signedness */ AST_exp_n_t * y_exp; /* constant expression info */ } %{ #include %} /********************************************************************/ /* */ /* Tokens used by the IDL parser. */ /* */ /********************************************************************/ /* Keywords */ %token ALIGN_KW %token BYTE_KW %token CHAR_KW %token CONST_KW %token DEFAULT_KW %token ENUM_KW %token EXCEPTIONS_KW %token FLOAT_KW %token HYPER_KW %token INT_KW %token INTERFACE_KW %token IMPORT_KW %token LIBRARY_KW %token LONG_KW %token PIPE_KW %token REF_KW %token SMALL_KW %token STRUCT_KW %token TYPEDEF_KW %token UNION_KW %token UNSIGNED_KW %token SHORT_KW %token VOID_KW %token DOUBLE_KW %token BOOLEAN_KW %token CASE_KW %token SWITCH_KW %token HANDLE_T_KW %token TRUE_KW %token FALSE_KW %token NULL_KW %token BROADCAST_KW %token COMM_STATUS_KW %token CONTEXT_HANDLE_KW %token FIRST_IS_KW %token HANDLE_KW %token IDEMPOTENT_KW %token IGNORE_KW %token CALL_AS_KW %token IID_IS_KW %token IMPLICIT_HANDLE_KW %token IN_KW %token LAST_IS_KW %token LENGTH_IS_KW %token LOCAL_KW %token MAX_IS_KW %token MAYBE_KW %token MIN_IS_KW %token MUTABLE_KW %token OUT_KW %token OBJECT_KW %token POINTER_DEFAULT_KW %token ENDPOINT_KW %token PTR_KW %token RANGE_KW %token REFLECT_DELETIONS_KW %token REMOTE_KW %token SECURE_KW %token SHAPE_KW %token SIZE_IS_KW %token STRING_KW %token SWITCH_IS_KW %token SWITCH_TYPE_KW %token TRANSMIT_AS_KW %token UNIQUE_KW %token UUID_KW %token VERSION_KW %token V1_ARRAY_KW %token V1_STRING_KW %token V1_ENUM_KW %token V1_STRUCT_KW /* Added by Centeris */ %token CPP_QUOTE_KW /* Non-keyword tokens */ %token UUID_REP /* Punctuation */ %token COLON %token COMMA %token DOTDOT %token EQUAL %token LBRACE %token LBRACKET %token LPAREN %token RBRACE %token RBRACKET %token RPAREN %token SEMI %token STAR %token QUESTION %token BAR %token BARBAR %token LANGLE %token LANGLEANGLE %token RANGLE %token RANGLEANGLE %token AMP %token AMPAMP %token LESSEQUAL %token GREATEREQUAL %token EQUALEQUAL %token CARET %token PLUS %token MINUS %token NOT %token NOTEQUAL %token SLASH %token PERCENT %token TILDE %token POUND %token UNKNOWN /* Something that doesn't fit in any other token class */ /* Tokens setting yylval */ %token IDENTIFIER %token STRING %token INTEGER_NUMERIC %token CHAR %token FLOAT_NUMERIC %start grammar_start %% /********************************************************************/ /* */ /* Syntax description and actions for IDL */ /* */ /********************************************************************/ grammar_start: interfaces cpp_quotes { global_cppquotes_post = (AST_cpp_quote_n_t*)AST_concat_element( (ASTP_node_t*)global_cppquotes_post, (ASTP_node_t*)$2); } | optional_imports_cppquotes | { $$ = (AST_import_n_t *)NULL; } /*{ #if 0 global_imports = (AST_import_n_t*)AST_concat_element( (ASTP_node_t*)global_imports, (ASTP_node_t*)$1); #endif global_cppquotes_post = (AST_cpp_quote_n_t*)AST_concat_element( (ASTP_node_t*)global_cppquotes_post, (ASTP_node_t*)$2); }*/ ; interfaces: interfaces interface_plus | interface_plus ; /*Centeris wfu*/ cpp_quotes: cpp_quote cpp_quotes { $$ = (AST_cpp_quote_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $2); } | /*Nothing*/ { $$ = (AST_cpp_quote_n_t *)NULL; } ; interface_plus: cpp_quotes interface { global_cppquotes = (AST_cpp_quote_n_t*)AST_concat_element( (ASTP_node_t*)global_cppquotes, (ASTP_node_t*)$1); } ; interface: interface_init interface_start interface_ancestor interface_tail { AST_finish_interface_node(nidl_location(nidl), the_interface); } ; interface_start: interface_attributes INTERFACE_KW IDENTIFIER { AST_type_n_t * interface_type = AST_type_node(nidl_location(nidl), AST_interface_k); interface_type->type_structure.interface = the_interface; interface_type->name = $3; the_interface->name = $3; ASTP_add_name_binding (nidl_location(nidl), the_interface->name, interface_type); } ; interface_ancestor: /* Nothing */ { the_interface->inherited_interface_name = NAMETABLE_NIL_ID; } | COLON IDENTIFIER { the_interface->inherited_interface_name = $2; } ; interface_init: /* Always create the interface node and auto-import the system idl */ { STRTAB_str_t nidl_idl_str; nidl_idl_str = STRTAB_add_string (AUTO_IMPORT_FILE); AST_interface_n_t* old = the_interface; the_interface = AST_interface_node(nidl_location(nidl)); the_interface->prev = old; the_interface->exports = NULL; the_interface->imports = AST_import_node(nidl_location(nidl), nidl_idl_str); the_interface->imports->interface = FE_parse_import (nidl_idl_str); if (the_interface->imports->interface != NULL) { AST_CLR_OUT_OF_LINE(the_interface->imports->interface); AST_SET_IN_LINE(the_interface->imports->interface); } } ; interface_tail: LBRACE interface_body RBRACE { $$ = $2; } | error { $$ = NULL; log_error(nidl_yylineno(nidl),NIDL_MISSONINTER, NULL); } | error RBRACE { $$ = NULL; } ; interface_body: optional_imports exports extraneous_semi { /* May already be an import of nbase, so concat */ the_interface->imports = (AST_import_n_t *) AST_concat_element( (ASTP_node_t *) the_interface->imports, (ASTP_node_t *) $1); the_interface->exports = (AST_export_n_t*)AST_concat_element( (ASTP_node_t*)the_interface->exports, (ASTP_node_t*)$2); } ; optional_imports: imports | /* Nothing */ { $$ = (AST_import_n_t *)NULL; } ; optional_imports_cppquotes: imports cpp_quotes { #if 0 global_imports = (AST_import_n_t*)AST_concat_element( (ASTP_node_t*)global_imports, (ASTP_node_t*)$1); #endif global_cppquotes_post = (AST_cpp_quote_n_t*)AST_concat_element( (ASTP_node_t*)global_cppquotes_post, (ASTP_node_t*)$2); } ; imports: import | imports import { $$ = (AST_import_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $2); } ; import: IMPORT_KW error { $$ = (AST_import_n_t *)NULL; } | IMPORT_KW error SEMI { $$ = (AST_import_n_t *)NULL; } | IMPORT_KW import_files SEMI { $$ = $2; } ; import_files: import_file | import_files COMMA import_file { $$ = (AST_import_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3); } ; import_file: STRING { AST_interface_n_t *int_p; int_p = FE_parse_import ($1); if (int_p != (AST_interface_n_t *)NULL) { $$ = AST_import_node(nidl_location(nidl), $1); $$->interface = int_p; } else $$ = (AST_import_n_t *)NULL; } ; exports: export | exports extraneous_semi export { $$ = (AST_export_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3) ; } ; export: type_dcl SEMI { $$ = AST_types_to_exports (nidl_location(nidl), $1); } | const_dcl SEMI { $$ = AST_export_node ( nidl_location(nidl), (ASTP_node_t *) $1, AST_constant_k); } | operation_dcl SEMI { if (ASTP_parsing_main_idl) $$ = AST_export_node ( nidl_location(nidl), (ASTP_node_t *) $1, AST_operation_k); } | cpp_quote { $$ = AST_export_node ( nidl_location(nidl), (ASTP_node_t *) $1, AST_cpp_quote_k); } | error SEMI { $$ = (AST_export_n_t *)NULL; } ; cpp_quote: CPP_QUOTE_KW LPAREN STRING RPAREN { $$ = AST_cpp_quote_node(nidl_location(nidl), $3); } ; const_dcl: CONST_KW type_spec declarator EQUAL const_exp { $$ = AST_finish_constant_node (nidl_location(nidl), $5, $3, $2); } ; const_exp: expression { $$ = AST_constant_from_exp(nidl_location(nidl), $1); if ($$ == NULL) { log_error(nidl_yylineno(nidl), NIDL_EXPNOTCONST, NULL); } } ; type_dcl: TYPEDEF_KW type_declarator { $$ = $2; } ; type_declarator: attributes type_spec declarators extraneous_comma { $$ = AST_declarators_to_types(nidl_location(nidl), the_interface, $2, $3, &$1) ; ASTP_free_simple_list((ASTP_node_t *)$1.bounds); } ; type_spec: simple_type_spec | constructed_type_spec ; simple_type_spec: floating_point_type_spec | integer_type_spec | char_type_spec | boolean_type_spec | byte_type_spec | void_type_spec | named_type_spec | handle_type_spec ; constructed_type_spec: struct_type_spec | union_type_spec | enum_type_spec | pipe_type_spec ; named_type_spec: IDENTIFIER { $$ = AST_lookup_named_type(nidl_location(nidl), $1); } ; floating_point_type_spec: FLOAT_KW { $$ = AST_lookup_type_node(AST_short_float_k); } | DOUBLE_KW { $$ = AST_lookup_type_node(AST_long_float_k); } ; extraneous_comma: /* Nothing */ | COMMA { log_warning(nidl_yylineno(nidl), NIDL_EXTRAPUNCT, ",", NULL);} ; extraneous_semi: /* Nothing */ | SEMI { log_warning(nidl_yylineno(nidl), NIDL_EXTRAPUNCT, ";", NULL);} ; optional_unsigned_kw: UNSIGNED_KW { $$.int_signed = false; } | /* Nothing */ { $$.int_signed = true; } ; integer_size_spec: SMALL_KW { $$.int_size = AST_small_integer_k; $$.int_signed = true; } | SHORT_KW { $$.int_size = AST_short_integer_k; $$.int_signed = true; } | LONG_KW { $$.int_size = AST_long_integer_k; $$.int_signed = true; } | HYPER_KW { $$.int_size = AST_hyper_integer_k; $$.int_signed = true; } ; integer_modifiers: integer_size_spec { $$ = $1; } | UNSIGNED_KW integer_size_spec { $$.int_size = $2.int_size; $$.int_signed = false; } | integer_size_spec UNSIGNED_KW { $$.int_size = $1.int_size; $$.int_signed = false; } ; integer_type_spec: integer_modifiers { $$ = AST_lookup_integer_type_node($1.int_size,$1.int_signed); } | integer_modifiers INT_KW { $$ = AST_lookup_integer_type_node($1.int_size,$1.int_signed); } | optional_unsigned_kw INT_KW { log_warning(nidl_yylineno(nidl),NIDL_INTSIZEREQ, NULL); $$ = AST_lookup_integer_type_node(AST_long_integer_k,$1.int_signed); } ; char_type_spec: optional_unsigned_kw CHAR_KW { $$ = AST_lookup_type_node(AST_character_k); } ; boolean_type_spec: BOOLEAN_KW { $$ = AST_lookup_type_node(AST_boolean_k); } ; byte_type_spec: BYTE_KW { $$ = AST_lookup_type_node(AST_byte_k); } ; void_type_spec: VOID_KW { $$ = AST_lookup_type_node(AST_void_k); } ; handle_type_spec: HANDLE_T_KW { $$ = AST_lookup_type_node(AST_handle_k); } ; push_name_space: LBRACE { NAMETABLE_push_level (); } ; pop_name_space: RBRACE { ASTP_patch_field_reference (nidl_location(nidl)); NAMETABLE_pop_level (); } ; union_type_spec: UNION_KW ne_union_body { $$ = AST_disc_union_node( nidl_location(nidl), NAMETABLE_NIL_ID, /* tag name */ NAMETABLE_NIL_ID, /* union name */ NAMETABLE_NIL_ID, /* discriminant name */ NULL, /* discriminant type */ $2 ); /* the arm list */ } | UNION_KW SWITCH_KW LPAREN simple_type_spec IDENTIFIER RPAREN union_body { $$ = AST_disc_union_node( nidl_location(nidl), NAMETABLE_NIL_ID, /* tag name */ ASTP_tagged_union_id, /* union name */ $5, /* discriminant name */ $4, /* discriminant type */ $7 ); /* the arm list */ } | UNION_KW IDENTIFIER ne_union_body { $$ = AST_disc_union_node( nidl_location(nidl), $2, /* tag name */ NAMETABLE_NIL_ID, /* union name */ NAMETABLE_NIL_ID, /* discriminant name */ NULL, /* discriminant type */ $3 ); /* the arm list */ } | UNION_KW SWITCH_KW LPAREN simple_type_spec IDENTIFIER RPAREN IDENTIFIER union_body { $$ = AST_disc_union_node( nidl_location(nidl), NAMETABLE_NIL_ID, /* tag name */ $7, /* union name */ $5, /* discriminant name */ $4, /* discriminant type */ $8 ); /* the arm list */ } | UNION_KW IDENTIFIER SWITCH_KW LPAREN simple_type_spec IDENTIFIER RPAREN union_body { $$ = AST_disc_union_node( nidl_location(nidl), $2, /* tag name */ ASTP_tagged_union_id, /* union name */ $6, /* discriminant name */ $5, /* discriminant type */ $8 ); /* the arm list */ } | UNION_KW IDENTIFIER SWITCH_KW LPAREN simple_type_spec IDENTIFIER RPAREN IDENTIFIER union_body { $$ = AST_disc_union_node( nidl_location(nidl), $2, /* tag name */ $8, /* union name */ $6, /* discriminant name */ $5, /* discriminant type */ $9 ); /* the arm list */ } | UNION_KW IDENTIFIER { $$ = AST_type_from_tag (nidl_location(nidl), AST_disc_union_k, $2); } ; ne_union_body: push_name_space ne_union_cases pop_name_space { $$ = $2; } ; union_body: push_name_space union_cases pop_name_space { $$ = $2; } ; ne_union_cases: ne_union_case | ne_union_cases extraneous_semi ne_union_case { $$ = (AST_arm_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3); } ; union_cases: union_case | union_cases extraneous_semi union_case { $$ = (AST_arm_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3); } ; ne_union_case: ne_union_member { $$ = $1; } ; union_case: union_case_list union_member { $$ = AST_label_arm($2, $1) ; } ; ne_union_case_list: ne_union_case_label | ne_union_case_list COMMA ne_union_case_label { $$ = (AST_case_label_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3); } ; union_case_list: union_case_label | union_case_list union_case_label { $$ = (AST_case_label_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $2); } ; ne_union_case_label: const_exp { $$ = AST_case_label_node( nidl_location(nidl), $1); } ; union_case_label: CASE_KW const_exp COLON { $$ = AST_case_label_node( nidl_location(nidl), $2); } | DEFAULT_KW COLON { $$ = AST_default_case_label_node( nidl_location(nidl)); } ; ne_union_member: attribute_opener rest_of_attribute_list SEMI { $$ = AST_declarator_to_arm(nidl_location(nidl), NULL, NULL, &$2); ASTP_free_simple_list((ASTP_node_t *)$2.bounds); } | attribute_opener rest_of_attribute_list type_spec declarator SEMI { $$ = AST_declarator_to_arm(nidl_location(nidl), $3, $4, &$2); ASTP_free_simple_list((ASTP_node_t *)$2.bounds); } ; union_member: /* nothing */ SEMI { $$ = AST_arm_node(nidl_location(nidl), NAMETABLE_NIL_ID,NULL,NULL); } | attributes type_spec declarator SEMI { if (ASTP_TEST_ATTR(&$1, ASTP_CASE)) { ASTP_attr_flag_t attr1 = ASTP_CASE; log_error(nidl_yylineno(nidl), NIDL_EUMEMATTR, KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)), NULL); } if (ASTP_TEST_ATTR(&$1, ASTP_DEFAULT)) { ASTP_attr_flag_t attr1 = ASTP_DEFAULT; log_error(nidl_yylineno(nidl), NIDL_EUMEMATTR, KEYWORDS_lookup_text(AST_attribute_to_token(&attr1)), NULL); } $$ = AST_declarator_to_arm(nidl_location(nidl), $2, $3, &$1); ASTP_free_simple_list((ASTP_node_t *)$1.bounds); } ; struct_type_spec: STRUCT_KW push_name_space member_list pop_name_space { $$ = AST_structure_node(nidl_location(nidl), $3, NAMETABLE_NIL_ID) ; } | STRUCT_KW IDENTIFIER push_name_space member_list pop_name_space { $$ = AST_structure_node(nidl_location(nidl), $4, $2) ; } | STRUCT_KW IDENTIFIER { $$ = AST_type_from_tag (nidl_location(nidl), AST_structure_k, $2); } ; member_list: member | member_list extraneous_semi member { $$ = (AST_field_n_t *)AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3) ; } ; member: attributes type_spec old_attribute_syntax declarators SEMI { $$ = AST_declarators_to_fields(nidl_location(nidl), $4, $2, &$1); ASTP_free_simple_list((ASTP_node_t *)$1.bounds); } ; enum_type_spec: ENUM_KW optional_tag enum_body { $$ = AST_enumerator_node(nidl_location(nidl), $3, AST_short_integer_k); } ; optional_tag: IDENTIFIER { } | /* Nothing */ ; enum_body: LBRACE enum_ids extraneous_comma RBRACE { $$ = $2 ; } ; enum_ids: enum_id | enum_ids COMMA enum_id { $$ = (AST_constant_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3) ; } ; enum_id: IDENTIFIER optional_value { $$ = AST_enum_constant(nidl_location(nidl), $1, $2) ; } ; pipe_type_spec: PIPE_KW type_spec { $$ = AST_pipe_node (nidl_location(nidl), $2); } ; optional_value: /* Nothing */ { $$ = AST_exp_integer_constant(nidl_location(nidl), 0, true); } | EQUAL expression { ASTP_validate_integer(nidl_location(nidl), $2); $$ = $2; } ; declarators: declarator { $$ = $1; } | declarators COMMA declarator { $$ = (ASTP_declarator_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3) ; } ; declarator: declarator1 { $$ = $1; } ; declarator1: direct_declarator { $$ = $1; } | pointer direct_declarator { $$ = $2; AST_declarator_operation($$, AST_pointer_k, (ASTP_node_t *)NULL, $1 ); }; pointer : STAR { $$ = 1;} | STAR pointer { $$ = $2 + 1; }; direct_declarator: IDENTIFIER { $$ = AST_declarator_node ( $1 ); } | direct_declarator array_bounds { $$ = $$; AST_declarator_operation($$, AST_array_k, (ASTP_node_t *) $2, 0 ); } | LPAREN declarator RPAREN { $$ = $2; } | direct_declarator parameter_dcls { $$ = $$; AST_declarator_operation($$, AST_function_k, (ASTP_node_t *) $2, 0 ); } ; /* * The following productions use an AST routine with the signature: * * ASTP_array_index_node( AST_constant_n_t * lower_bound, * ASTP_bound_t lower_bound_type, * AST_constant_n_t * upper_bound, * ASTP_bound_t upper_bound_type); * * The type ASTP_bound_t is defined as: * * typedef enum {ASTP_constant_bound, * ASTP_default_bound, * ASTP_open_bound} ASTP_bound_t; * * The bound value passed is only used if the associated bound type is * ASTP_constant_bound. */ array_bounds: LBRACKET RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), NULL, ASTP_default_bound, NULL, ASTP_open_bound); } | LBRACKET STAR RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), NULL, ASTP_default_bound, NULL, ASTP_open_bound); } | LBRACKET const_exp RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), NULL, ASTP_default_bound, $2, ASTP_constant_bound); } | LBRACKET STAR DOTDOT STAR RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), NULL, ASTP_open_bound, NULL, ASTP_open_bound); } | LBRACKET STAR DOTDOT const_exp RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), NULL, ASTP_open_bound, $4, ASTP_constant_bound); } | LBRACKET const_exp DOTDOT STAR RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), $2, ASTP_constant_bound, NULL, ASTP_open_bound); } | LBRACKET const_exp DOTDOT const_exp RBRACKET { $$ = ASTP_array_index_node (nidl_location(nidl), $2, ASTP_constant_bound, $4, ASTP_constant_bound); } ; operation_dcl: attributes type_spec declarators extraneous_comma { if (ASTP_parsing_main_idl) $$ = AST_operation_node ( nidl_location(nidl), $2, /*The type node*/ $3, /* Declarator list */ &$1); /* attributes */ ASTP_free_simple_list((ASTP_node_t *)$1.bounds); } | error declarators { log_error(nidl_yylineno(nidl),NIDL_MISSONOP, NULL); $$ = NULL; } ; parameter_dcls: param_names param_list extraneous_comma end_param_names { $$ = $2; } ; param_names: LPAREN { NAMETABLE_push_level (); } ; end_param_names: RPAREN { ASTP_patch_field_reference (nidl_location(nidl)); NAMETABLE_pop_level (); } ; param_list: param_dcl | param_list COMMA param_dcl { if (ASTP_parsing_main_idl) $$ = (AST_parameter_n_t *) AST_concat_element( (ASTP_node_t *) $1, (ASTP_node_t *) $3); } | /* nothing */ { $$ = (AST_parameter_n_t *)NULL; } ; param_dcl: attributes type_spec old_attribute_syntax declarator_or_null { /* * We have to use special code here to allow (void) as a parameter * specification. If there are no declarators, then we need to * make sure that the type is void and that there are no attributes . */ if ($4 == NULL) { /* * If the type is not void or some attribute is specified, * there is a syntax error. Force a yacc error, so that * we can safely recover from the lack of a declarator. */ if (($2->kind != AST_void_k) || ($1.bounds != NULL) || ($1.attr_flags != 0)) { yywhere(nidl_location(nidl)); /* Issue a syntax error for this line */ YYERROR; /* Allow natural error recovery */ } $$ = (AST_parameter_n_t *)NULL; } else { if (ASTP_parsing_main_idl) $$ = AST_declarator_to_param( nidl_location(nidl), &$1, $2, $4); } ASTP_free_simple_list((ASTP_node_t *)$1.bounds); } | error old_attribute_syntax declarator_or_null { log_error(nidl_yylineno(nidl), NIDL_MISSONPARAM, NULL); $$ = (AST_parameter_n_t *)NULL; } ; declarator_or_null: declarator { $$ = $1; } | /* nothing */ { $$ = NULL; } ; /* * Attribute definitions * * Attributes may appear on types, fields, parameters, operations and * interfaces. Thes productions must be used around attributes in order * for LEX to recognize attribute names as keywords instead of identifiers. * The bounds productions are used in attribute options (such * as size_is) because variable names the may look like attribute names * should be allowed. */ attribute_opener: LBRACKET { search_attributes_table = true; } ; attribute_closer: RBRACKET { search_attributes_table = false; } ; bounds_opener: LPAREN { search_attributes_table = false; } ; bounds_closer: RPAREN { search_attributes_table = true; } ; /* * Production to accept attributes in the old location, and issue a clear error that * the translator should be used. */ old_attribute_syntax: attributes { /* Give an error on notranslated sources */ if (($1.bounds != NULL) || ($1.attr_flags != 0)) { log_error(nidl_yylineno(nidl),NIDL_ATTRTRANS, NULL); ASTP_free_simple_list((ASTP_node_t *)$1.bounds); } } ; /* * Interface Attributes * * Interface attributes are special--there is no cross between interface * attributes and other attributes (for instance on fields or types. */ interface_attributes: attribute_opener interface_attr_list extraneous_comma attribute_closer | attribute_opener error attribute_closer { log_error(nidl_yylineno(nidl),NIDL_ERRINATTR, NULL); } | /* Nothing */ ; interface_attr_list: interface_attr | interface_attr_list COMMA interface_attr | /* nothing */ ; interface_attr: UUID_KW error { log_error(nidl_yylineno(nidl),NIDL_SYNTAXUUID, NULL); } | UUID_KW UUID_REP { { if (ASTP_IF_AF_SET(the_interface,ASTP_IF_UUID)) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); ASTP_SET_IF_AF(the_interface,ASTP_IF_UUID); the_interface->uuid = $2; } } | ENDPOINT_KW LPAREN port_list extraneous_comma RPAREN { if (ASTP_IF_AF_SET(the_interface,ASTP_IF_PORT)) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); ASTP_SET_IF_AF(the_interface,ASTP_IF_PORT); } | EXCEPTIONS_KW LPAREN excep_list extraneous_comma RPAREN { if (ASTP_IF_AF_SET(the_interface, ASTP_IF_EXCEPTIONS)) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); ASTP_SET_IF_AF(the_interface, ASTP_IF_EXCEPTIONS); } | VERSION_KW LPAREN version_number RPAREN { { if (ASTP_IF_AF_SET(the_interface,ASTP_IF_VERSION)) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); ASTP_SET_IF_AF(the_interface,ASTP_IF_VERSION); } } | LOCAL_KW { { if (AST_LOCAL_SET(the_interface)) log_warning(nidl_yylineno(nidl), NIDL_MULATTRDEF, NULL); AST_SET_LOCAL(the_interface); } } | POINTER_DEFAULT_KW LPAREN pointer_class RPAREN { if (the_interface->pointer_default != 0) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); the_interface->pointer_default = $3; } /* extensions to osf */ | OBJECT_KW { if (AST_OBJECT_SET(the_interface)) log_warning(nidl_yylineno(nidl), NIDL_MULATTRDEF, NULL); AST_SET_OBJECT(the_interface); } | acf_interface_attr { /* complain about compat here */ } ; acf_interface_attr: IMPLICIT_HANDLE_KW LPAREN HANDLE_T_KW IDENTIFIER RPAREN { if (the_interface->implicit_handle_name != NAMETABLE_NIL_ID) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); ASTP_set_implicit_handle(the_interface, NAMETABLE_NIL_ID, $4); } | IMPLICIT_HANDLE_KW LPAREN IDENTIFIER IDENTIFIER RPAREN { if (the_interface->implicit_handle_name != NAMETABLE_NIL_ID) log_error(nidl_yylineno(nidl), NIDL_ATTRUSEMULT, NULL); ASTP_set_implicit_handle(the_interface, $3, $4); } ; pointer_class: REF_KW { $$ = ASTP_REF; } | PTR_KW { $$ = ASTP_PTR; } | UNIQUE_KW { $$ = ASTP_UNIQUE; } ; version_number: INTEGER_NUMERIC { the_interface->version = $1.int_val; if (the_interface->version > /*(unsigned int)*/ASTP_C_USHORT_MAX) log_error(nidl_yylineno(nidl), NIDL_MAJORTOOLARGE, ASTP_C_USHORT_MAX, NULL); } | FLOAT_NUMERIC { char const *float_text; unsigned int major_version,minor_version; STRTAB_str_to_string($1, &float_text); sscanf(float_text,"%d.%d",&major_version,&minor_version); if (major_version > (unsigned int)ASTP_C_USHORT_MAX) log_error(nidl_yylineno(nidl), NIDL_MAJORTOOLARGE, ASTP_C_USHORT_MAX, NULL); if (minor_version > (unsigned int)ASTP_C_USHORT_MAX) log_error(nidl_yylineno(nidl), NIDL_MINORTOOLARGE, ASTP_C_USHORT_MAX, NULL); the_interface->version = (minor_version * 65536) + major_version; } ; port_list: port_spec | port_list COMMA port_spec ; excep_list: excep_spec { the_interface->exceptions = $1; } | excep_list COMMA excep_spec { $$ = (AST_exception_n_t *) AST_concat_element( (ASTP_node_t *) the_interface->exceptions, (ASTP_node_t *) $3 ); } ; port_spec: STRING { ASTP_parse_port(the_interface,$1); } ; excep_spec: IDENTIFIER { if (ASTP_parsing_main_idl) { $$ = AST_exception_node(nidl_location(nidl), $1); } else { $$ = NULL; } } ; /* * Attributes that can appear on fields or parameters. These are the array * bounds attributes, i.e., last_is and friends. They are handled differently * from any other attributes. */ fp_attribute: array_bound_type bounds_opener array_bound_id_list bounds_closer { $$.bounds = $3.bounds; $$.attr_flags = 0; } | neu_switch_type bounds_opener neu_switch_id bounds_closer { $$.bounds = $3.bounds; $$.attr_flags = 0; } ; array_bound_type: FIRST_IS_KW { ASTP_bound_type = first_is_k; } | LAST_IS_KW { ASTP_bound_type = last_is_k; } | LENGTH_IS_KW { ASTP_bound_type = length_is_k; } | MAX_IS_KW { ASTP_bound_type = max_is_k; } | MIN_IS_KW { ASTP_bound_type = min_is_k; } | SIZE_IS_KW { ASTP_bound_type = size_is_k; } ; array_bound_id_list: array_bound_id | array_bound_id_list COMMA array_bound_id { $$.bounds = (ASTP_type_attr_n_t *) AST_concat_element ( (ASTP_node_t*) $1.bounds, (ASTP_node_t*) $3.bounds); } ; /* expression conflicts with identifier here */ array_bound_id: expression { $$.bounds = AST_array_bound_from_expr(nidl_location(nidl), $1, ASTP_bound_type); } | /* nothing */ { $$.bounds = AST_array_bound_info (nidl_location(nidl), NAMETABLE_NIL_ID, ASTP_bound_type, FALSE); } ; neu_switch_type: SWITCH_IS_KW { ASTP_bound_type = switch_is_k; } ; neu_switch_id: IDENTIFIER { $$.bounds = AST_array_bound_info(nidl_location(nidl), $1, ASTP_bound_type, FALSE); } | STAR IDENTIFIER { $$.bounds = AST_array_bound_info(nidl_location(nidl), $2, ASTP_bound_type, TRUE); } ; /* * Generalized Attribute processing */ attributes: attribute_opener rest_of_attribute_list { $$ = $2; } | /* nothing */ { $$.bounds = NULL; $$.attr_flags = 0; } ; rest_of_attribute_list: attribute_list extraneous_comma attribute_closer | error attribute_closer { /* * Can't tell if we had any valid attributes in the list, so return * none. */ $$.bounds = NULL; $$.attr_flags = 0; log_error(nidl_yylineno(nidl), NIDL_ERRINATTR, NULL); } | error SEMI { /* * No closer to the attribute, so give a different message. */ $$.bounds = NULL; $$.attr_flags = 0; log_error(nidl_yylineno(nidl), NIDL_MISSONATTR, NULL); search_attributes_table = false; } ; attribute_list: attribute { $$ = $1; } | attribute_list COMMA attribute { /* * If the same bit has been specified more than once, then issue * a message. */ if (($1.attr_flags & $3.attr_flags) != 0) log_warning(nidl_yylineno(nidl), NIDL_MULATTRDEF, NULL); $$.attr_flags = $1.attr_flags | $3.attr_flags; $$.bounds = (ASTP_type_attr_n_t *) AST_concat_element ( (ASTP_node_t*) $1.bounds, (ASTP_node_t*) $3.bounds); } ; attribute: /* bound attributes */ fp_attribute { $$ = $1; } /* Operation Attributes */ | BROADCAST_KW { $$.attr_flags = ASTP_BROADCAST; $$.bounds = NULL; } | MAYBE_KW { $$.attr_flags = ASTP_MAYBE; $$.bounds = NULL; } | IDEMPOTENT_KW { $$.attr_flags = ASTP_IDEMPOTENT; $$.bounds = NULL; } | REFLECT_DELETIONS_KW { $$.attr_flags = ASTP_REFLECT_DELETIONS; $$.bounds = NULL; } | LOCAL_KW { $$.attr_flags = ASTP_LOCAL; $$.bounds = NULL; } | CALL_AS_KW LPAREN IDENTIFIER RPAREN { } /* Parameter-only Attributes */ | PTR_KW { $$.attr_flags = ASTP_PTR; $$.bounds = NULL; } | IN_KW { $$.attr_flags = ASTP_IN; $$.bounds = NULL; } | IN_KW LPAREN SHAPE_KW RPAREN { $$.attr_flags = ASTP_IN | ASTP_IN_SHAPE; $$.bounds = NULL; } | OUT_KW { $$.attr_flags = ASTP_OUT; $$.bounds = NULL; } | OUT_KW LPAREN SHAPE_KW RPAREN { $$.attr_flags = ASTP_OUT | ASTP_OUT_SHAPE; $$.bounds = NULL; } | IID_IS_KW LPAREN IDENTIFIER RPAREN { $$.iid_is_name = $3; $$.bounds = NULL; $$.attr_flags = 0; } | IID_IS_KW LPAREN STAR IDENTIFIER RPAREN /* MIDL extension */ { $$.iid_is_name = $4; $$.bounds = NULL; $$.attr_flags = 0; } /* Type, Field, Parameter Attributes */ | V1_ARRAY_KW { $$.attr_flags = ASTP_SMALL; $$.bounds = NULL; } | STRING_KW { $$.attr_flags = ASTP_STRING; $$.bounds = NULL; } | V1_STRING_KW { $$.attr_flags = ASTP_STRING0; $$.bounds = NULL; } | UNIQUE_KW { $$.attr_flags = ASTP_UNIQUE; $$.bounds = NULL; } | REF_KW { $$.attr_flags = ASTP_REF; $$.bounds = NULL; } | IGNORE_KW { $$.attr_flags = ASTP_IGNORE; $$.bounds = NULL; } | CONTEXT_HANDLE_KW { $$.attr_flags = ASTP_CONTEXT; $$.bounds = NULL; } | RANGE_KW LPAREN expression COMMA expression RPAREN /* MIDL extension */ { $$.attr_flags = ASTP_RANGE; $$.bounds = AST_range_from_expr(nidl_location(nidl), $3, $5); } /* Type-only Attribute(s) */ | V1_STRUCT_KW { $$.attr_flags = ASTP_UNALIGN; $$.bounds = NULL; } | V1_ENUM_KW { $$.attr_flags = ASTP_V1_ENUM; $$.bounds = NULL; } | ALIGN_KW LPAREN SMALL_KW RPAREN { $$.attr_flags = ASTP_ALIGN_SMALL; $$.bounds = NULL; } | ALIGN_KW LPAREN SHORT_KW RPAREN { $$.attr_flags = ASTP_ALIGN_SHORT; $$.bounds = NULL; } | ALIGN_KW LPAREN LONG_KW RPAREN { $$.attr_flags = ASTP_ALIGN_LONG; $$.bounds = NULL; } | ALIGN_KW LPAREN HYPER_KW RPAREN { $$.attr_flags = ASTP_ALIGN_HYPER; $$.bounds = NULL; } | HANDLE_KW { $$.attr_flags = ASTP_HANDLE; $$.bounds = NULL; } | TRANSMIT_AS_KW LPAREN simple_type_spec RPAREN { $$.attr_flags = ASTP_TRANSMIT_AS; $$.bounds = NULL; ASTP_transmit_as_type = $3; } | SWITCH_TYPE_KW LPAREN simple_type_spec RPAREN { $$.attr_flags = ASTP_SWITCH_TYPE; $$.bounds = NULL; ASTP_switch_type = $3; } /* Arm-only Attribute(s) */ | CASE_KW LPAREN ne_union_case_list RPAREN { $$.attr_flags = ASTP_CASE; $$.bounds = NULL; ASTP_case = $3; } | DEFAULT_KW { $$.attr_flags = ASTP_DEFAULT; $$.bounds = NULL; } | IDENTIFIER /* Not an attribute, so give an error */ { char const *identifier; /* place to receive the identifier text */ NAMETABLE_id_to_string ($1, &identifier); log_error (nidl_yylineno(nidl), NIDL_UNKNOWNATTR, identifier, NULL); $$.attr_flags = 0; $$.bounds = NULL; } ; /********************************************************************/ /* */ /* Compiletime Integer expression evaluation */ /* */ /********************************************************************/ expression: conditional_expression {$$ = $1;} ; conditional_expression: logical_OR_expression {$$ = $1;} | logical_OR_expression QUESTION expression COLON conditional_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_TERNARY_OP, $1, $3, $5); } ; logical_OR_expression: logical_AND_expression {$$ = $1;} | logical_OR_expression BARBAR logical_AND_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_LOG_OR, $1, $3, NULL); } ; logical_AND_expression: inclusive_OR_expression {$$ = $1;} | logical_AND_expression AMPAMP inclusive_OR_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_LOG_AND, $1, $3, NULL); } ; inclusive_OR_expression: exclusive_OR_expression {$$ = $1;} | inclusive_OR_expression BAR exclusive_OR_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_OR, $1, $3, NULL); } ; exclusive_OR_expression: AND_expression {$$ = $1;} | exclusive_OR_expression CARET AND_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_XOR, $1, $3, NULL); } ; AND_expression: equality_expression {$$ = $1;} | AND_expression AMP equality_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_AND, $1, $3, NULL); } ; equality_expression: relational_expression {$$ = $1;} | equality_expression EQUALEQUAL relational_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_EQUAL, $1, $3, NULL); } | equality_expression NOTEQUAL relational_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_NE, $1, $3, NULL); } ; relational_expression: shift_expression {$$ = $1;} | relational_expression LANGLE shift_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_LT, $1, $3, NULL); } | relational_expression RANGLE shift_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_GT, $1, $3, NULL); } | relational_expression LESSEQUAL shift_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_LE, $1, $3, NULL); } | relational_expression GREATEREQUAL shift_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_GE, $1, $3, NULL); } ; shift_expression: additive_expression {$$ = $1;} | shift_expression LANGLEANGLE additive_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_LSHIFT, $1, $3, NULL); } | shift_expression RANGLEANGLE additive_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_RSHIFT, $1, $3, NULL); } ; additive_expression: multiplicative_expression {$$ = $1;} | additive_expression PLUS multiplicative_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_PLUS, $1, $3, NULL); } | additive_expression MINUS multiplicative_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_MINUS, $1, $3, NULL); } ; multiplicative_expression: cast_expression {$$ = $1;} | multiplicative_expression STAR cast_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_STAR, $1, $3, NULL); /* if (($$.exp.constant.val.integer < $1.exp.constant.val.integer) && ($$.exp.constant.val.integer < $3.exp.constant.val.integer)) log_error (nidl_yylineno(nidl), NIDL_INTOVERFLOW, KEYWORDS_lookup_text(LONG_KW), NULL); */ } | multiplicative_expression SLASH cast_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_SLASH, $1, $3, NULL); } | multiplicative_expression PERCENT cast_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_BINARY_PERCENT, $1, $3, NULL); /* log_error (nidl_yylineno(nidl), NIDL_INTDIVBY0, NULL); */ } ; cast_expression: unary_expression {$$ = $1;} ; unary_expression: primary_expression {$$ = $1;} | PLUS primary_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_UNARY_PLUS, $2, NULL, NULL); } | MINUS primary_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_UNARY_MINUS, $2, NULL, NULL); } | TILDE primary_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_UNARY_TILDE, $2, NULL, NULL); } | NOT primary_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_UNARY_NOT, $2, NULL, NULL); } | STAR primary_expression { $$ = AST_expression(nidl_location(nidl), AST_EXP_UNARY_STAR, $2, NULL, NULL); } ; primary_expression: LPAREN expression RPAREN { $$ = $2; } | INTEGER_NUMERIC { $$ = AST_exp_integer_constant( nidl_location(nidl), $1.int_val, $1.int_signed); } | CHAR { $$ = AST_exp_char_constant(nidl_location(nidl), $1); } | IDENTIFIER { $$ = AST_exp_identifier(nidl_location(nidl), $1); } | STRING { $$ = AST_exp_string_constant( nidl_location(nidl), $1); } | NULL_KW { $$ = AST_exp_null_constant(nidl_location(nidl)); } | TRUE_KW { $$ = AST_exp_boolean_constant(nidl_location(nidl), true); } | FALSE_KW { $$ = AST_exp_boolean_constant(nidl_location(nidl), false); } | FLOAT_NUMERIC { $$ = AST_exp_integer_constant(nidl_location(nidl), 0,0); log_error(nidl_yylineno(nidl), NIDL_FLOATCONSTNOSUP, NULL); } ; %% nidl_parser_p nidl_parser_alloc ( boolean *cmd_opt_arr, /* [in] Array of command option flags */ void **cmd_val_arr, /* [in] Array of command option values */ char *nidl_file /* [in] ACF file name */ ) { nidl_parser_state_t * nidl; nidl = NEW(nidl_parser_state_t); /* Set global (STRTAB_str_t error_file_name_id) for error processing. */ set_name_for_errors(nidl_file); nidl->nidl_location.fileid = STRTAB_add_string(nidl_file); // XXX save file name ID in parser state return nidl; } void nidl_parser_destroy ( nidl_parser_p nidl ) { FREE(nidl); yyin_p = NULL; yylineno_p = NULL; } void nidl_parser_input ( nidl_parser_p nidl, FILE * in ) { assert(nidl->nidl_yyscanner == NULL); nidl_yylex_init(&nidl->nidl_yyscanner); nidl_yyset_in(in, nidl->nidl_yyscanner); yyin_p = in; yylineno_p = &nidl->nidl_location.lineno; } const parser_location_t * nidl_location ( nidl_parser_p nidl ) { /* Update the current location before handing it back ... */ nidl->nidl_location.lineno = nidl_yylineno(nidl); nidl->nidl_location.location = *nidl_yyget_lloc(nidl->nidl_yyscanner); nidl->nidl_location.text = nidl_yyget_text(nidl->nidl_yyscanner); return &nidl->nidl_location; } unsigned nidl_yylineno ( nidl_parser_p nidl ) { return nidl_yyget_lineno(nidl->nidl_yyscanner); } unsigned nidl_errcount ( nidl_parser_p nidl ) { return nidl->nidl_yynerrs; } static void nidl_yyerror ( YYLTYPE * yylloc ATTRIBUTE_UNUSED, nidl_parser_p nidl, char const * message ) { const struct parser_location_t * loc; loc = nidl_location(nidl); idl_yyerror(loc, message); } /* preserve coding style vim: set tw=78 sw=3 ts=3 et : */