📄 psdl.yy
字号:
%{
// PSDL.yy,v 1.1 2002/07/25 15:25:50 pgontla Exp
// ========================================================================
//
// = LIBRARY
// orbsvcs / Persistent State Definition Language parser.
//
// = FILENAME
// PSDL.yy
//
// = AUTHOR
// Priyanka Gontla <pgontla@doc.ece.uci.edu>
//
// ========================================================================
#include "PSDL_y.h"
#include "PSDL_Node.h"
#include "PSDL_Interpreter.h"
#include "PSDL_Scope.h"
#include "PSDL_Module_Scope.h"
#define YYPARSE_PARAM lex_state
#define YYLEX_PARAM lex_state
//extern int yylex (TAO_PSDL_Node **, void *);
extern int yylex (void);
static void yyerror (const char *error)
{
printf ("Error %s\n", error);
}
%}
%token TAO_PSDL_SEMI TAO_PSDL_MODULE TAO_PSDL_COLON
%token TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
%token TAO_PSDL_OPEN_BRACE TAO_PSDL_CLOSE_BRACE
%token TAO_PSDL_ABSTRACT TAO_PSDL_STORAGETYPE
%token TAO_PSDL_STORAGEHOME
%token TAO_PSDL_CATALOG TAO_PSDL_PROVIDES
%token TAO_PSDL_IMPLEMENTS
%token TAO_PSDL_SCOPE TAO_PSDL_STORES TAO_PSDL_STATE
%token TAO_PSDL_AS TAO_PSDL_PRIMARY
%token TAO_PSDL_STRONG TAO_PSDL_REF TAO_PSDL_OF
%token TAO_PSDL_OPEN_ANGULAR_BRACE TAO_PSDL_CLOSE_ANGULAR_BRACE
%token TAO_PSDL_COMMA TAO_PSDL_KEY TAO_PSDL_READONLY
%token TAO_PSDL_UNION TAO_PSDL_SWITCH TAO_PSDL_CASE
%token TAO_PSDL_WCHAR TAO_PSDL_BOOLEAN TAO_PSDL_OCTET
%token TAO_PSDL_ANY TAO_PSDL_OBJECT TAO_PSDL_STRUCT
%token TAO_PSDL_DEFAULT TAO_PSDL_FLOAT TAO_PSDL_DOUBLE
%token TAO_PSDL_LONG TAO_PSDL_SHORT TAO_PSDL_UNSIGNED
%token TAO_PSDL_CHAR TAO_PSDL_IDENT TAO_PSDL_TYPEDEF
%token TAO_PSDL_NATIVE TAO_PSDL_PLUS TAO_PSDL_MINUS
%token TAO_PSDL_XOR TAO_PSDL_AND TAO_PSDL_MULT
%token TAO_PSDL_RIGHT_SHIFT TAO_PSDL_LEFT_SHIFT
%token TAO_PSDL_DIV TAO_PSDL_PERCENT TAO_PSDL_TILDA
%token TAO_PSDL_ONEWAY TAO_PSDL_CONST TAO_PSDL_EQUAL TAO_PSDL_OR
%token TAO_PSDL_VOID TAO_PSDL_IN TAO_PSDL_OUT TAO_PSDL_INOUT
%token TAO_PSDL_RAISES TAO_PSDL_CONTEXT TAO_PSDL_FIXED
%token TAO_PSDL_VALUEBASE TAO_PSDL_EXCEPTION
%token TAO_PSDL_INTERFACE
%token TAO_PSDL_LOCAL TAO_PSDL_DOUBLE_COLON TAO_PSDL_VALUETYPE
%token TAO_PSDL_CUSTOM TAO_PSDL_TRUNCATABLE TAO_PSDL_SUPPORTS
%token TAO_PSDL_STRING TAO_PSDL_WSTRING TAO_PSDL_ATTRIBUTE
%token TAO_PSDL_OPEN_SQUARE_BRACE TAO_PSDL_CLOSE_SQUARE_BRACE
%token TAO_PSDL_ENUM TAO_PSDL_SEQUENCE
%token TAO_PSDL_TRUE TAO_PSDL_FALSE
%token TAO_PSDL_INTEGER TAO_PSDL_FLOATING
%token TAO_PSDL_PRIVATE TAO_PSDL_PUBLIC TAO_PSDL_FACTORY
%token TAO_PSDL_FLOATING_PT TAO_PSDL_CHAR_LITERAL
%token TAO_PSDL_FIXED_PT
%pure_parser
%start psdl_specification
%%
psdl_specification: psdl_definition
{ $$ = new TAO_PSDL_Specification ($1); }
|
psdl_specification psdl_definition
{ $$ = new TAO_PSDL_Specification ($1, $2); }
;
psdl_definition: type_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
const_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
except_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
interface TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
psdl_module TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
catalog TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
storagehome TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
abstract_storagehome TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
storagetype TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
abstract_storagetype TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
|
value TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Definition ($1); }
;
psdl_module : TAO_PSDL_MODULE identifier
{
int good_module_name = TAO_PSDL_Scope::instance ()->pop_top_scope ()->add_module (TAO_PSDL_Scope::instance ()->get_identifier ());
if (good_module_name == -1)
YYABORT;
}
TAO_PSDL_OPEN_CURLY_BRACE psdl_specification TAO_PSDL_CLOSE_CURLY_BRACE
{
TAO_PSDL_Scope::instance ()->set_module_scope ();
$$ = new TAO_PSDL_Module (TAO_PSDL_MODULE, $2, $5); }
;
abstract_storagetype : abstract_storagetype_dcl
{ TAO_PSDL_Scope::instance ()->set_scope ();
$$ = new TAO_PSDL_Abstract_Storagetype ($1); }
|
abstract_storagetype_fwd_dcl
{ $$ = new TAO_PSDL_Abstract_Storagetype ($1); }
;
abstract_storagetype_dcl: abstract_storagetype_header TAO_PSDL_OPEN_CURLY_BRACE abstract_storagetype_body TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Abstract_Storagetype_Dcl ($1, $3); }
|
abstract_storagetype_header TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Abstract_Storagetype_Dcl ($1); }
;
abstract_storagetype_fwd_dcl: TAO_PSDL_ABSTRACT TAO_PSDL_STORAGETYPE identifier
{ $$ = new TAO_PSDL_Abstract_Storagetype_Fwd_Dcl ($3); }
;
storagetype_identifier: TAO_PSDL_STORAGETYPE identifier
{
int good_storagetype_name = TAO_PSDL_Scope::instance ()->pop_top_scope ()->add_interface (TAO_PSDL_Scope::instance ()->get_identifier ());
if (good_storagetype_name == -1)
YYABORT;
$$ = $2;
}
;
abstract_storagetype_header:
TAO_PSDL_ABSTRACT storagetype_identifier abstract_storagetype_inh_spec
{ $$ = new TAO_PSDL_Abstract_Storagetype_Header ($2, $3); }
|
TAO_PSDL_ABSTRACT storagetype_identifier
{ $$ = new TAO_PSDL_Abstract_Storagetype_Header ($2); }
;
abstract_storagetype_body:
abstract_storagetype_member
{ $$ = new TAO_PSDL_Abstract_Storagetype_Body ($1); }
|
abstract_storagetype_member abstract_storagetype_body
{ $$ = new TAO_PSDL_Abstract_Storagetype_Body ($1, $2); }
;
abstract_storagetype_member:
psdl_state_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Abstract_Storagetype_Member ($1); }
|
local_op_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Abstract_Storagetype_Member ($1); }
;
abstract_storagetype_inh_spec:
TAO_PSDL_COLON abstract_storagetype_name
{ $$ = new TAO_PSDL_Abstract_Storagetype_Inh_Spec ($2); }
;
abstract_storagetype_name:
scoped_name
{ $$ = new TAO_PSDL_Abstract_Storagetype_Name ($1); }
|
scoped_name TAO_PSDL_COMMA abstract_storagetype_name
{ $$ = new TAO_PSDL_Abstract_Storagetype_Name ($1, $3); }
;
psdl_state_dcl : TAO_PSDL_READONLY TAO_PSDL_STATE psdl_state_type_spec simple_declarator
{ $$ = new TAO_PSDL_Psdl_State_Dcl ($1, $3, $4); }
|
TAO_PSDL_STATE psdl_state_type_spec simple_declarator
{ $$ = new TAO_PSDL_Psdl_State_Dcl ($2, $3); }
;
psdl_state_type_spec : base_type_spec
{ $$ = new TAO_PSDL_Psdl_State_Type_Spec ($1); }
|
string_type
{ $$ = new TAO_PSDL_Psdl_State_Type_Spec ($1); }
|
wide_string_type
{ $$ = new TAO_PSDL_Psdl_State_Type_Spec ($1); }
|
abstract_storagetype_ref_type
{ $$ = new TAO_PSDL_Psdl_State_Type_Spec ($1); }
|
scoped_name
{ $$ = new TAO_PSDL_Psdl_State_Type_Spec ($1); }
;
abstract_storagetype_ref_type:
TAO_PSDL_STRONG TAO_PSDL_REF TAO_PSDL_OPEN_ANGULAR_BRACE abstract_storagetype_name TAO_PSDL_CLOSE_ANGULAR_BRACE
{ $$ = new TAO_PSDL_Abstract_Storagetype_Ref_Type ($1, $4); }
|
TAO_PSDL_REF TAO_PSDL_OPEN_ANGULAR_BRACE abstract_storagetype_name TAO_PSDL_CLOSE_ANGULAR_BRACE
{ $$ = new TAO_PSDL_Abstract_Storagetype_Ref_Type ($3); }
;
abstract_storagehome : abstract_storagehome_dcl
{ $$ = new TAO_PSDL_Abstract_Storagehome ($1); }
|
abstract_storagehome_fwd_dcl
{ $$ = new TAO_PSDL_Abstract_Storagehome ($1); }
;
abstract_storagehome_fwd_dcl:
TAO_PSDL_ABSTRACT TAO_PSDL_STORAGEHOME identifier
{ $$ = new TAO_PSDL_Abstract_Storagehome_Fwd_Dcl ($3); }
;
abstract_storagehome_dcl:
abstract_storagehome_header TAO_PSDL_OPEN_CURLY_BRACE abstract_storagehome_body TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Abstract_Storagehome_Dcl ($1, $3); }
|
abstract_storagehome_header TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Abstract_Storagehome_Dcl ($1); }
;
abstract_storagehome_header:
TAO_PSDL_ABSTRACT TAO_PSDL_STORAGEHOME identifier TAO_PSDL_OF abstract_storagetype_name abstract_storagehome_inh_spec
{ $$ = new TAO_PSDL_Abstract_Storagehome_Header ($3, $5, $6); }
|
TAO_PSDL_ABSTRACT TAO_PSDL_STORAGEHOME identifier TAO_PSDL_OF abstract_storagetype_name
{ $$ = new TAO_PSDL_Abstract_Storagehome_Header ($3, $5); }
;
abstract_storagehome_body:
abstract_storagehome_member
{ $$ = new TAO_PSDL_Abstract_Storagehome_Body ($1); }
|
abstract_storagehome_member abstract_storagehome_body
{ $$ = new TAO_PSDL_Abstract_Storagehome_Body ($1, $2); }
;
abstract_storagehome_member:
local_op_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Abstract_Storagehome_Member ($1); }
|
key_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Abstract_Storagehome_Member ($1); }
|
factory_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Abstract_Storagehome_Member ($1); }
;
abstract_storagehome_inh_spec:
TAO_PSDL_COLON abstract_storagehome_name
{ $$ = new TAO_PSDL_Abstract_Storagehome_Inh_Spec ($2); }
;
abstract_storagehome_name:
scoped_name
{ $$ = new TAO_PSDL_Abstract_Storagehome_Name ($1); }
|
scoped_name TAO_PSDL_COMMA abstract_storagehome_name
{ $$ = new TAO_PSDL_Abstract_Storagehome_Name ($1, $3); }
;
local_op_dcl : op_type_spec op_name parameter_dcls raises_expr
{ TAO_PSDL_Scope::instance ()->set_scope ();
$$ = new TAO_PSDL_Op_Dcl ($1, $2, $3, $4); }
|
op_type_spec op_name parameter_dcls
{ TAO_PSDL_Scope::instance ()->set_scope ();
$$ = new TAO_PSDL_Op_Dcl ($1, $2, $3); }
;
key_dcl : TAO_PSDL_KEY identifier TAO_PSDL_OPEN_BRACE simple_declarator_list TAO_PSDL_CLOSE_BRACE
{ $$ = new TAO_PSDL_Key_Dcl ($2, $4); }
|
TAO_PSDL_KEY identifier
{ $$ = new TAO_PSDL_Key_Dcl ($2); }
;
catalog : TAO_PSDL_CATALOG identifier catalog_inh_spec TAO_PSDL_OPEN_CURLY_BRACE catalog_body TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Catalog ($2, $3, $5); }
|
TAO_PSDL_CATALOG identifier TAO_PSDL_OPEN_CURLY_BRACE catalog_body TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Catalog ($2, $4); }
|
TAO_PSDL_CATALOG identifier TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Catalog ($2); }
|
TAO_PSDL_CATALOG identifier catalog_inh_spec TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Catalog ($2, $3); }
;
catalog_inh_spec : TAO_PSDL_COLON catalog_name
{ $$ = new TAO_PSDL_Catalog_Inh_Spec ($2); }
;
catalog_name : scoped_name
{ $$ = new TAO_PSDL_Catalog_Name ($1); }
|
scoped_name TAO_PSDL_COMMA catalog_name
{ $$ = new TAO_PSDL_Catalog_Name ($1, $3); }
;
catalog_body : catalog_member
{ $$ = new TAO_PSDL_Catalog_Body ($1); }
|
catalog_member catalog_body
{ $$ = new TAO_PSDL_Catalog_Body ($1, $2); }
;
catalog_member : provides_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Catalog_Member ($1); }
|
local_op_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Catalog_Member ($1); }
;
provides_dcl : TAO_PSDL_PROVIDES abstract_storagehome_name simple_declarator
{ $$ = new TAO_PSDL_Provides_Dcl ($2, $3); }
;
storagetype : storagetype_dcl
{ $$ = new TAO_PSDL_Storagetype ($1); }
|
storagetype_fwd_dcl
{ $$ = new TAO_PSDL_Storagetype ($1); }
;
storagetype_dcl : storagetype_header TAO_PSDL_OPEN_CURLY_BRACE storagetype_body TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Storagetype_Dcl ($1, $3); }
|
storagetype_header TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Storagetype_Dcl ($1); }
;
storagetype_fwd_dcl : TAO_PSDL_STORAGETYPE identifier
{ $$ = new TAO_PSDL_Storagetype_Fwd_Dcl ($2); }
;
storagetype_header : TAO_PSDL_STORAGETYPE identifier storagetype_inh_spec storagetype_impl_spec
{ $$ = new TAO_PSDL_Storagetype_Header ($2, $3, $4); }
|
TAO_PSDL_STORAGETYPE identifier storagetype_inh_spec
{ $$ = new TAO_PSDL_Storagetype_Header ($2, $3); }
|
TAO_PSDL_STORAGETYPE identifier storagetype_impl_spec
{ $$ = new TAO_PSDL_Storagetype_Header ($2, $3); }
;
storagetype_body : storagetype_member
{ $$ = new TAO_PSDL_Storagetype_Body ($1); }
|
storagetype_member storagetype_body
{ $$ = new TAO_PSDL_Storagetype_Body ($1, $2); }
;
storagetype_member : psdl_state_dcl TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Storagetype_Member ($1); }
|
store_directive TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Storagetype_Member ($1); }
|
ref_rep_directive TAO_PSDL_SEMI
{ $$ = new TAO_PSDL_Storagetype_Member ($1); }
;
storagetype_inh_spec : TAO_PSDL_COLON storagetype_name
{ $$ = new TAO_PSDL_Storagetype_Inh_Spec ($2); }
;
storagetype_name : scoped_name
{ $$ = new TAO_PSDL_Storagetype_Name ($1); }
;
storagetype_impl_spec : TAO_PSDL_IMPLEMENTS abstract_storagetype_name
{ $$ = new TAO_PSDL_Storagetype_Impl_Spec ($2); }
;
storagetype_ref_type : TAO_PSDL_REF TAO_PSDL_OPEN_ANGULAR_BRACE storagetype_name TAO_PSDL_CLOSE_ANGULAR_BRACE
{ $$ = new TAO_PSDL_Storagetype_Ref_Type ($3); }
;
storagehome_scope : TAO_PSDL_SCOPE storagehome_name
{ $$ = new TAO_PSDL_Storagehome_Scope ($2); }
;
store_directive : TAO_PSDL_STORES simple_declarator TAO_PSDL_AS psdl_concrete_state_type storagehome_scope
{ $$ = new TAO_PSDL_Store_Directive ($2, $4, $5); }
|
TAO_PSDL_STORES simple_declarator TAO_PSDL_AS psdl_concrete_state_type
{ $$ = new TAO_PSDL_Store_Directive ($2, $4); }
;
psdl_concrete_state_type:
storagetype_name
{ $$ = new TAO_PSDL_Psdl_Concrete_State_Type ($1); }
|
storagetype_ref_type
{ $$ = new TAO_PSDL_Psdl_Concrete_State_Type ($1); }
;
ref_rep_directive : TAO_PSDL_REF TAO_PSDL_OPEN_BRACE simple_declarator TAO_PSDL_CLOSE_BRACE
{ $$ = new TAO_PSDL_Ref_Rep_Directive ($3); }
;
storagehome : storagehome_header TAO_PSDL_OPEN_CURLY_BRACE storagehome_body TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Storagehome ($1, $3); }
|
storagehome_header TAO_PSDL_OPEN_CURLY_BRACE TAO_PSDL_CLOSE_CURLY_BRACE
{ $$ = new TAO_PSDL_Storagehome ($1); }
;
storagehome_header : TAO_PSDL_STORAGEHOME identifier TAO_PSDL_OF storagetype_name storagehome_inh_spec storagehome_impl_spec
{ $$ = new TAO_PSDL_Storagehome_Header ($2, $4, $5, $6); }
|
TAO_PSDL_STORAGEHOME identifier TAO_PSDL_OF storagetype_name storagehome_inh_spec
{ $$ = new TAO_PSDL_Storagehome_Header ($2, $4, $5); }
|
TAO_PSDL_STORAGEHOME identifier TAO_PSDL_OF storagetype_name storagehome_impl_spec
{ $$ = new TAO_PSDL_Storagehome_Header ($2, $4, $5); }
|
TAO_PSDL_STORAGEHOME identifier TAO_PSDL_OF storagetype_name
{ $$ = new TAO_PSDL_Storagehome_Header ($2, $4); }
;
storagehome_body : storagehome_member
{ $$ = new TAO_PSDL_Storagehome_Body ($1); }
|
storagehome_member storagehome_body
{ $$ = new TAO_PSDL_Storagehome_Body ($1, $2); }
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -