%{ extern "C" { #include void yyerror(const char*str); int yywrap(); extern int yylineno; extern char* yytext; } int yylex(void); #include #include #include #include #include #include using namespace iwear; using namespace iwear::net; extern char *yytext; #define YYDEBUG_LEXER_TEXT yytext #ifndef IW_SOLARIS #ifndef yyfalse #define yyfalse false #endif #ifndef yytrue #define yytrue true #endif #endif %} %union { int number; char *string; } %token NAMESPACE CLASS ONEWAY CACHED IN OUT INOUT TYPEDEF %token UINT8 UINT16 UINT32 UINT64 INT8 INT16 INT32 INT64 %token LDOUBLE DOUBLE STRING VOID UID PUBLIC PROTECTED PRIVATE %token NUMBER %token IDENTIFIER SET LIST VECTOR MAP PAIR ENUM ADAPT INCLUDE FILENAME %token DEFERRABLE %type call_declaration %type type_declaration %type protection_declaration %type protection_specifier %type container_declaration %type function_parameter %type parameter_direction %type container_type %type container_typelist %type enum_identifier %glr-parser %% declarations: /*empty*/ | declarations declaration { //std::cout << __FFL__ << endl; } ; include_declaration: INCLUDE '"' FILENAME '"' { idl::include($3); } | INCLUDE '<' FILENAME '>' { idl::include($3); } declaration: namespace_definition | include_declaration | class_definition | typedef_declaration | enum_declaration ; typedef_declaration: TYPEDEF type_declaration IDENTIFIER ';' { idl::add_typedef($3,$2); } ; enum_declaration: ENUM IDENTIFIER '{' enum_list '}' ';' { idl::add_enum($2); } enum_list: enum_list ',' enum_identifier | enum_identifier ; enum_identifier: IDENTIFIER { idl::enum_identifier($1); } | IDENTIFIER '=' IDENTIFIER { idl::enum_identifier($1,$3); } |IDENTIFIER '=' NUMBER { idl::enum_identifier($1,$3); } ; namespace_start: NAMESPACE IDENTIFIER '{' { idl::start_namespace($2); } ; namespace_definition: namespace_start namespace_body '}' { idl::end_namespace(); } ; namespace_body: declarations { //std::cout << __FFL__ << endl; } ; class_definition: class_start member_declarations '}' ';' { idl::end_class(); } ; derivation: protection_specifier IDENTIFIER { idl::start_derivation($1,$2); }; derivation_list: derivation_list ',' derivation { idl::end_derivation(); } | derivation { idl::end_derivation(); }; version_specifier: NUMBER { idl::version_specifier($1); } | NUMBER '.' NUMBER { idl::version_specifier($1,$3); } | NUMBER '.' NUMBER '.' NUMBER { idl::version_specifier($1,$3,$5); } class_version: | '[' version_specifier ']' class_start: CLASS IDENTIFIER class_version '{' { idl::start_class($2); } | CLASS IDENTIFIER class_version ':' derivation_list '{' { idl::start_class($2); } ; member_declarations: | member_declarations member_declaration ; protection_specifier: PUBLIC | PROTECTED | PRIVATE ; protection_declaration: protection_specifier ':' ; adapt_declaration: PRIVATE ADAPT IDENTIFIER ';' { idl::adapt_private($2); } | ADAPT IDENTIFIER ';' { idl::adapt($2); } member_declaration: function_declaration | var_declaration | adapt_declaration | protection_declaration { idl::change_protection($1); } | class_definition { std::cout << __FFL__ << std::endl; } ; function_declaration: return_declaration IDENTIFIER '(' function_parameter_list ')' ';' { idl::end_function( $2 ); } | return_declaration IDENTIFIER '[' version_specifier ']' '(' function_parameter_list ')' '=' IDENTIFIER ';' { idl::end_function( $2, $10 ); } ; function_parameter_list: function_parameter_list ',' function_parameter | function_parameter ; function_parameter: parameter_direction type_declaration IDENTIFIER { idl::create_parameter($1,$2,$3); } | parameter_direction type_declaration { idl::create_parameter($1,$2); } | VOID { idl::create_parameter(); } ; parameter_direction: IN | OUT | INOUT ; container_type: LIST { idl::start_container_list(); } | SET { idl::start_container_set(); } | VECTOR { idl::start_container_vector(); } | MAP { idl::start_container_map(); } | PAIR { idl::start_container_pair(); } ; container_typelist: container_typelist ',' type_declaration { idl::add_container_type_x($3); } | type_declaration { idl::add_container_type($1); } ; container_declaration: container_type '<' container_typelist '>' { idl::finish_container(); $$ = strdup(""); } ; type_declaration: UINT8 | UINT16 | UINT32 | UINT64 | INT8 | INT16 | INT32 | INT64 | LDOUBLE { $$ = strdup("long_double"); } | DOUBLE | STRING | VOID | UID | IDENTIFIER | container_declaration { } ; call_declaration: ONEWAY | CACHED | DEFERRABLE ; return_declaration: call_declaration type_declaration { idl::start_function( $1, $2 ); } | type_declaration { idl::start_function( $1 ); } ; var_declaration: type_declaration IDENTIFIER ';' { idl::declare_variable( $1, $2 ); } ; %% void yyerror(const char *str) { if( iwear::net::idl::expected_token ) { THROW(parse_error,((str),yylineno,yytext,i18n::trans(iwear::net::idl::expected_token))); } else { THROW(parse_error,((str),yylineno,yytext)); } } int yywrap() { return 1; }