From a6edca027c78cecfa45bf15d3d5484d55c79871f Mon Sep 17 00:00:00 2001 From: cas Date: Fri, 22 Oct 1999 18:05:40 +0000 Subject: [PATCH] Initial revision --- src/CDLFront/CDL.lex | 240 +++ src/CDLFront/CDL.yacc | 900 ++++++++++ src/CDLFront/CDLFront.cxx | 2711 ++++++++++++++++++++++++++++++ src/CDLFront/CDLFront.hxx | 21 + src/CDLFront/CDLFront_CMPLRS.edl | 14 + src/CDLFront/FILES | 8 + src/CDLFront/cdl_defines.hxx | 13 + src/CDLFront/cdl_rules.h | 153 ++ 8 files changed, 4060 insertions(+) create mode 100755 src/CDLFront/CDL.lex create mode 100755 src/CDLFront/CDL.yacc create mode 100755 src/CDLFront/CDLFront.cxx create mode 100755 src/CDLFront/CDLFront.hxx create mode 100755 src/CDLFront/CDLFront_CMPLRS.edl create mode 100755 src/CDLFront/FILES create mode 100755 src/CDLFront/cdl_defines.hxx create mode 100755 src/CDLFront/cdl_rules.h diff --git a/src/CDLFront/CDL.lex b/src/CDLFront/CDL.lex new file mode 100755 index 0000000..13d66dd --- /dev/null +++ b/src/CDLFront/CDL.lex @@ -0,0 +1,240 @@ +/*======================================================*/ +/*== CDL lexical analyzer. +/*======================================================*/ + +%{ + +#include +#include + + +#include +void add_cpp_comment(int,char*); +#define yylval CDLlval +#include +int CDLlineno; +%} + + +/* The specials key words */ + +COMMENTER [-][-] +FCPLUSPLUS [-][-][-][C][+][+][ \t]* +CPLUSPLUS [-][-][-][C][+][+][ \t]*[:][ \t]* +FCPLUSPLUSD [-][-][-][C][+][+][ \t]*[2][.][0][ \t]* +CPLUSPLUSD [-][-][-][C][+][+][ \t]*[2][.][0][ \t]*[:][ \t]* +FCPLUSPLUSD1 [-][-][-][C][+][+][ \t]*[2][.][1][ \t]* +CPLUSPLUSD1 [-][-][-][C][+][+][ \t]*[2][.][1][ \t]*[:][ \t]* +OPERATOR [-][-][-][C][+][+][ \t]*[:][ \t]*[a][l][i][a][s][ \t]*[o][p][e][r][a][t][o][r] +INLINE [-][-][-][C][+][+][ \t]*[:][ \t]*[i][n][l][i][n][e][ \t]* +DESTRUCTOR [-][-][-][C][+][+][ \t]*[:][ \t]*[a][l][i][a][s][ \t]*['~'][ \t]* +CONSTREF [-][-][-][C][+][+][ \t]*[:][ \t]*[r][e][t][u][r][n][ \t]*[c][o][n][s][t][ \t]*['&'][ \t]* +CONSTRET [-][-][-][C][+][+][ \t]*[:][ \t]*[r][e][t][u][r][n][ \t]*[c][o][n][s][t][ \t]* +REF [-][-][-][C][+][+][ \t]*[:][ \t]*[r][e][t][u][r][n][ \t]*['&'][ \t]* +HARDALIAS [-][-][-][C][+][+][ \t]*[:][ \t]*[a][l][i][a][s][ \t]*\"(\\\"|[^"])*\"[ \t]* +FUNCTIONCALL [-][-][-][C][+][+][ \t]*[:][ \t]*[f][u][n][c][t][i][o][n][ \t]*[c][a][l][l][ \t]* + +/* The identifiers without underscore at begining and end */ + +IDENTIFIER [A-Za-z][A-Za-z0-9_]*[A-Za-z0-9] + + +/* Integer and real */ + +INTEGER [+-]?[0-9]+ +REAL [+-]?[0-9]+"."[0-9]+([Ee][+-]?[0-9]+)? + +/* Literal and string */ + +LITERAL "'"."'" +STRING \"(\\\"|[^"])*\" + +/* The LEX directives. */ + +/* %p 5000 */ +/* %a 9000 */ +/* %o 10000 */ + +/* The rules section execfile { return(execfile); }*/ + +%% + +{REF}\n { add_cpp_comment(CDL_REF,CDLtext); CDLlineno++; } +{CONSTREF}\n { add_cpp_comment(CDL_CONSTREF,CDLtext); CDLlineno++; } +{CONSTRET}\n { add_cpp_comment(CDL_CONSTRET,CDLtext); CDLlineno++; } +{DESTRUCTOR}\n { add_cpp_comment(CDL_DESTRUCTOR,CDLtext); CDLlineno++; } +{INLINE}\n { add_cpp_comment(CDL_INLINE,CDLtext); CDLlineno++; } +{OPERATOR}.*\n { add_cpp_comment(CDL_OPERATOR,CDLtext); CDLlineno++; } +{HARDALIAS}\n { add_cpp_comment(CDL_HARDALIAS,CDLtext); CDLlineno++; } +{FUNCTIONCALL}\n { add_cpp_comment(CDL_FUNCTIONCALL,CDLtext); CDLlineno++; } +{CPLUSPLUSD}.*\n { CDLlineno++; CDLerror("C++2.0 directive no more supported."); } +{FCPLUSPLUSD}.*\n { CDLlineno++; CDLerror("C++2.0 directive no more supported (':' missing)."); } +{CPLUSPLUSD1}.*\n { CDLlineno++; CDLerror("C++2.1 directive no more supported."); } +{FCPLUSPLUSD1}.*\n { CDLlineno++; CDLerror("C++2.1 directive no more supported (':' missing)."); } +{CPLUSPLUS}\n { CDLlineno++; CDLerror("Empty C++ directive."); } +{FCPLUSPLUS}.*\n { CDLlineno++; CDLerror("C++ directive without ':'."); } +{COMMENTER}.*\n { CDLlineno++; } + + +alias { return(alias); } +any { return(any); } +asynchronous { return(asynchronous); } +as { return(as); } +class { return(class); } +client { return(client); } +component { return(component); } +deferred { return(deferred); } +schema { return(schema); } +end { return(end); } +engine { return(engine); } +enumeration { return(enumeration); } +exception { return(exception); } +executable { return(executable); } +fields { return(fields); } +friends { return(friends); } +from { return(CDL_from); } +generic { return(generic); } +immutable { return(immutable); } +imported { return(imported); } +in { return(in); } +inherits { return(inherits); } +instantiates { return(instantiates); } +interface { return(interface); } +is { return(is); } +like { return(like); } +me { return(me); } +mutable { return(mutable); } +myclass { return(myclass); } +out { return(out); } +package { return(package); } +pointer { return(pointer); } +private { return(private); } +primitive { return(primitive); } +protected { return(protected); } +raises { return(raises); } +redefined { return(redefined); } +returns { return(returns); } +static { return(statiC); } +to { return(CDL_to); } +uses { return(uses); } +virtual { return(virtual); } +library { return(library); } +external { return(external); } +as[ \t]*[c][+][+] { return(cpp); } +as[ \t]*c { return(krc); } +as[ \t]*fortran { return(fortran); } +as[ \t]*object { return(object); } + +{IDENTIFIER} | +[A-Za-z] { strncpy(CDLlval.str,CDLtext,MAX_CHAR); + return(IDENTIFIER); } + +{INTEGER} { strncpy (CDLlval.str,CDLtext,MAX_CHAR); + return(INTEGER); } + +{REAL} { strncpy(CDLlval.str,CDLtext,MAX_CHAR); + return(REAL); } + + +{LITERAL} { strncpy(CDLlval.str,CDLtext,MAX_CHAR); + return(LITERAL); } + +{STRING} { strncpy(CDLlval.str,CDLtext,MAX_STRING); + return(STRING) ;} + +; { return(';'); } +: { return(':'); } +"(" { return('('); } +")" { return(')'); } +"," { return(','); } +"[" { return('['); } +"]" { return(']'); } +"=" { return('='); } + +[ \t] { /* We don't take care of line feed, space or tabulation */ } +[\n] { CDLlineno++; } +. { return(INVALID); } + +%% +/* +static char comment[MAX_COMMENT + 1]; +static int comment_nb = 0; +static int new_comment = 0; + + Returns the last identifier + +static Comment() +{ + int size; + size = strlen(CDLtext); + if(comment_nb <= MAX_COMMENT - (size+1)) { + + + + strcpy(&comment[comment_nb],CDLtext); + comment_nb += size; + new_comment = 1; + } +} + + Returns the last identifier +static EndComment() +{ + int size; + size = strlen(ENDOFCOMMENT); + if(new_comment && (comment_nb <= MAX_COMMENT - (size+1))) { + + + + strcpy(&comment[comment_nb], ENDOFCOMMENT); + comment_nb += size; + new_comment = 0; + } +} +*/ + +/* Returns the last identifier */ + +char* YYident(){ + +} + +/* Returns the last integer */ + +char* YYinteger(){ + +} + +/* Returns the last real */ + +char* YYreal(){ + +} + +/* Returns the last literal */ + +char* YYliteral(){ + +} + +/* Returns the last String */ + +char* YYstring(){ + +} + +/* Returns the last comment + +char* YYcomment(){ + + comment[comment_nb] = 0; + comment_nb = 0; + return(comment); +} +*/ + +int CDLwrap() +{ + return 1; +} + diff --git a/src/CDLFront/CDL.yacc b/src/CDLFront/CDL.yacc new file mode 100755 index 0000000..2c50d02 --- /dev/null +++ b/src/CDLFront/CDL.yacc @@ -0,0 +1,900 @@ +/*==========================================================================*/ +/*== CDL Translater Version 1.2 +/*== +/*== SCCS Date: 17/11/93 +/*== Information: @(#)cdl.yacc 1.2 +/*==========================================================================*/ + +/*=-=-=-= The needed includes and variabels =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +%{ +/* all parser must define this variable */ + +#define yyv CDLv + +#define MAX_CHAR 256 /* The limit of a identifier. */ +#define MAX_STRING (MAX_CHAR * 10) /* The limit of a string. */ +#define MAX_COMMENT (MAX_CHAR * 300) /* The limit of comment line */ +#define ENDOFCOMMENT "\n%\n" /* The marque of end of coment */ + +#define CDL_CPP 1 +#define CDL_FOR 2 +#define CDL_C 3 +#define CDL_OBJ 4 +#define CDL_LIBRARY 5 +#define CDL_EXTERNAL 6 +%} +/*=-=-=-= End of The needed includes and variabels =-=-=-=-=-=-=-=-=-=-=-=*/ + +%token krc +%token cpp +%token fortran +%token object +%token library +%token external +%token alias +%token any +%token asynchronous +%token as +%token class +%token client +%token component +%token deferred +%token schema +%token end +%token engine +%token enumeration +%token exception +%token executable +%token execfile +%token extends +%token fields +%token friends +%token CDL_from +%token generic +%token immutable +%token imported +%token in +%token inherits +%token instantiates +%token interface +%token is +%token like +%token me +%token mutable +%token myclass +%token out +%token package +%token pointer +%token private +%token primitive +%token protected +%token raises +%token redefined +%token returns +%token statiC +%token CDL_to +%token uses +%token virtual +%token ')' +%token '(' +%token ']' +%token '[' +%token ':' +%token ';' +%token ',' +%token '=' +%token IDENTIFIER +%token INTEGER +%token LITERAL +%token REAL +%token STRING +%token INVALID +%union { + char str[MAX_STRING]; +} + +%type __Package_Name Package_Name Interface_Name __Interface_Name __Schema_Name __ExecFile_Name IDENTIFIER INTEGER REAL STRING LITERAL Schema_Name ExecFile_Name Empty_Str Engine_Name __Engine_Name Component_Name __Component_Name + +%start __Cdl_Declaration_List +%% + +/*==========================================================================*/ +/*==== CDL Definition ======================================================*/ +/*==========================================================================*/ +__Cdl_Declaration_List : Empty + | Cdl_Declaration_List + ; +Cdl_Declaration_List : Cdl_Declaration + | Cdl_Declaration_List Cdl_Declaration + ; +Cdl_Declaration : Package_Declaration + | Interface_Declaration + | Schema_Declaration + | Engine_Declaration + | Client_Declaration + | Executable_Declaration + | Component_Declaration + | Separated_Declaration + + /*======= The declaration error ====================*/ + | error + ; +/*==========================================================================*/ +/*==== Package definition ==================================================*/ +/*==========================================================================*/ +Package_Declaration : package Package_Name { Pack_Begin($2); } + __Packages_Uses + is + Package_Definition + end __Package_Name ';' { Pack_End(); } + ; +__Package_Name : Empty_Str + | Package_Name + ; +Package_Name : IDENTIFIER + ; +__Packages_Uses : Empty + | uses Package_List + ; +Package_List : Package_Name { Pack_Use($1); } + | Package_List ',' Package_Name { Pack_Use($3); } + ; +Package_Definition : __Pack_Declaration_List + __Extern_Method_List + ; +/*==========================================================================*/ +/*==== Interface definition ===============================================*/ +/*==========================================================================*/ +Interface_Declaration : interface Interface_Name { Interface_Begin($2); } + __Interfaces_Uses + is + __Interface_Definitions + end __Interface_Name ';' + dollardInterface_End + ; +__Interface_Name : Empty_Str + | IDENTIFIER + ; +Interface_Name : IDENTIFIER + ; +__Interfaces_Uses : Empty + | uses InterfaceUse_List + ; +InterfaceUse_List : Package_Name {Interface_Use($1);} + | InterfaceUse_List ',' Package_Name { Interface_Use($3); } + ; +__Interface_Definitions : Empty + | Interface_Definitions + ; +Interface_Definitions : Interface_Definition + | Interface_Definitions Interface_Definition + ; +Interface_Definition : package Package_Name ';' { Interface_Package($2); } + | class Type_Name ';' dollardInterface_Class + | Interface_Method_Dec ';' + ; + +Interface_Method_Dec : Method_Name Interface_Method + ; +Interface_Method : CDL_from __Class Type_Name { Method_TypeName(); } Interface_Method_Class_Dec + | CDL_from package IDENTIFIER Friend_ExtMet_Header Interface_returns_error {Interface_Method($3);} + ; + +Interface_Method_Class_Dec: Friend_InstMet_Header Interface_returns_error {Interface_Method("");} + | Friend_ClassMet_Header Interface_returns_error {Interface_Method("");} + | Friend_Const_Header Interface_returns_error {Interface_Method("");} + ; + +Interface_returns_error: Empty + | returns Type_Name { CDLerror("in interface, method declaration can not have a 'returns' clause"); } +/*==========================================================================*/ +/*==== Schema definition ==================================================*/ +/*==========================================================================*/ +Schema_Declaration : schema Schema_Name { Schema_Begin($2); } + is + __Schema_Packages + end __Schema_Name ';' { Schema_End(); } + ; +__Schema_Name : Empty_Str + | Schema_Name + ; +Schema_Name : IDENTIFIER + ; +__Schema_Packages : Empty + | Schema_Packages + ; +Schema_Packages : Schema_Package + | Schema_Packages Schema_Package + ; +Schema_Package : package Package_Name ';' { Schema_Package($2); } + | class Type_Name ';' { Schema_Class(); } + ; +/*==========================================================================*/ +/*==== Engine definition ==================================================*/ +/*==========================================================================*/ +Engine_Declaration : engine Engine_Name { Engine_Begin($2); } __Engine_Schema + is + __Engine_Interfaces + end __Engine_Name ';' + dollardEngine_End + ; + +__Engine_Name : Empty_Str + | IDENTIFIER + ; + +Engine_Name : IDENTIFIER + ; + +__Engine_Schema : Empty + | CDL_from __schema IDENTIFIER { Engine_Schema($3); } + ; +__schema : Empty + | schema + ; +__Engine_Interfaces : Empty + | Engine_Interfaces + ; +Engine_Interfaces : Engine_Interface + | Engine_Interfaces Engine_Interface + ; +Engine_Interface : interface IDENTIFIER ';' { Engine_Interface($2); } + ; +/*==========================================================================*/ +/*==== Component definition ==================================================*/ +/*==========================================================================*/ +Component_Declaration : component Component_Name { Component_Begin($2); } + is + __Component_Interfaces + end __Component_Name ';' + { Component_End(); } + ; + +__Component_Name : Empty_Str + | IDENTIFIER + ; + +Component_Name : IDENTIFIER + ; + +__Component_Interfaces : Empty + | Component_Interfaces + ; +Component_Interfaces : Component_Interface + | Component_Interfaces Component_Interface + ; +Component_Interface : interface IDENTIFIER CDL_from IDENTIFIER ';' { Component_Interface($2,$4); } + ; + +/*==========================================================================*/ +/*==== Client definition ==================================================*/ +/*==========================================================================*/ +Client_Declaration : client Client_Name + is + __Client_Definitions + end __Client_End ';' + ; + +Client_Name : IDENTIFIER { Client_Begin($1); } + ; + +__Client_End : Empty + | IDENTIFIER { Client_End(); } + ; + +__Client_Definitions : Empty + | Client_Definitions + ; + +Client_Definitions : Client_Definition + | Client_Definitions Client_Definition + +Client_Definition : interface IDENTIFIER ';' { Client_Interface($2); } + | Method_Name Client_Method ';' + ; + +Client_Method : CDL_from __Class Type_Name { Method_TypeName(); } Client_Method_Class_Dec + | CDL_from package IDENTIFIER Friend_ExtMet_Header Client_returns_error {Client_Method($3,1);} + | CDL_from package IDENTIFIER Friend_ExtMet_Header Client_returns_error is asynchronous {Client_Method($3,1);} + ; + +Client_Method_Class_Dec: Friend_InstMet_Header Client_returns_error {Client_Method("",1);} + | Friend_InstMet_Header Client_returns_error is asynchronous {Client_Method("",1);} + | Friend_ClassMet_Header Client_returns_error {Client_Method("",1);} + | Friend_ClassMet_Header Client_returns_error is asynchronous {Client_Method("",1);} + | Friend_Const_Header Client_returns_error {Client_Method("",-1);} + | Friend_Const_Header Client_returns_error is asynchronous {Client_Method("",-1);} + ; + +Client_returns_error: Empty + | returns Type_Name { CDLerror("in client, method declaration can not have a 'returns' clause"); } +/*==========================================================================*/ +/*==== Executable definition ==================================================*/ +/*==========================================================================*/ +Executable_Declaration : executable IDENTIFIER is { Executable_Begin($2); } + __ExecFileDeclaration + end __ExecutableName ';' + +__ExecFileDeclaration : Empty + | ExecFile_DeclarationList + ; + +__ExecutableName : Empty { Executable_End(); } + | IDENTIFIER { Executable_End(); } + ; + +ExecFile_DeclarationList: ExecFile_Declaration + | ExecFile_DeclarationList ExecFile_Declaration + ; + +ExecFile_Declaration : executable ExecFile_Name { ExecFile_Begin($2); } __ExecFile_Schema + __ExecFile_Uses + is + __ExecFile_Components + end __ExecFile_Name ';' { ExecFile_End(); } + ; + +__ExecFile_Name : Empty_Str + | ExecFile_Name + ; + +ExecFile_Name : IDENTIFIER + ; + +__ExecFile_Schema : Empty + | CDL_from __schema Schema_Name { ExecFile_Schema($3); } + ; + +__ExecFile_Uses : Empty + | uses ExecFile_List + ; + +ExecFile_List : ExecFile_Use + | ExecFile_List ',' ExecFile_Use + ; + +ExecFile_Use : IDENTIFIER as ExecFile_UseType {ExecFile_AddUse($1);} + ; + +ExecFile_UseType : library {ExecFile_SetUseType(CDL_LIBRARY); } + | external {ExecFile_SetUseType(CDL_EXTERNAL); } + ; + +__ExecFile_Components : Empty + | ExecFile_Components + ; + +ExecFile_Components : ExecFile_Component + | ExecFile_Components ExecFile_Component + ; + +ExecFile_Component : IDENTIFIER __ExecFile_ComponentType ';' { ExecFile_AddComponent($1); } + +__ExecFile_ComponentType : Empty { ExecFile_SetLang(CDL_CPP); } + | ExecFile_ComponentType + ; + +ExecFile_ComponentType: cpp { ExecFile_SetLang(CDL_CPP); } + | fortran { ExecFile_SetLang(CDL_FOR); } + | krc { ExecFile_SetLang(CDL_C); } + | object { ExecFile_SetLang(CDL_OBJ); } + ; + +/*==========================================================================*/ +/*==== Type Declaration ====================================================*/ +/*==========================================================================*/ +__Pack_Declaration_List : Empty + | Pack_Declaration_List + ; +Pack_Declaration_List : Pack_Declaration + | Pack_Declaration_List Pack_Declaration + ; +Pack_Declaration : Pack_Declaration_1 + | private dollardSet_Priv Pack_Declaration_1 + ; +Pack_Declaration_1 : Pack_Class_Declaration + | Exception_Declaration + | Enumeration_Declaration + | Alias_Declaration + | Imported_Declaration + | Primitive_Declaration + | Pointer_Declaration + ; +Separated_Declaration : Seper_Class_Declaration + | private dollardSet_Priv Seper_Class_Declaration + ; +/*==========================================================================*/ +/*==== Class Definition ====================================================*/ +/*==========================================================================*/ +Seper_Class_Declaration : Sep_Class_Declaration_1 + | deferred dollardSet_Defe Sep_Class_Declaration_1 + ; +Sep_Class_Declaration_1 : Generic_C_Declaration + | Generic_C_Instanciation + | NoGeneric_C_Declaration + ; +Pack_Class_Declaration : Pac_Class_Declaration_1 + | deferred dollardSet_Defe Pac_Class_Declaration_1 + ; +Pac_Class_Declaration_1 : Inc_NoGeneric_Class + | Inc_Generic_Class + | Generic_C_Instanciation + ; +/*==== Incomplete Class ====================================================*/ +Inc_NoGeneric_Class : class dollardset_inc_state Type_Name dollardrestore_state ';' dollardInc_Class_Dec + ; + +Inc_Generic_Class : generic class dollardset_inc_state Type_List dollardrestore_state ';' dollardInc_GenClass_Dec + ; +/*==== Generic Class =======================================================*/ +Generic_C_Declaration : generic class Type_Name dollardGenClass_Begin + '(' Generic_Type_List ')' + __Inherits_Classes { Add_Std_Ancestors(); } + __Uses_Classes { Add_Std_Uses(); } + __Raises_Exception + __Embeded_Class_List + is + Class_Definition + end __Class_Name ';' + dollardGenClass_End + ; +/*==== Instanciation Class =================================================*/ +Generic_C_Instanciation : class dollardset_inc_state Type_Name dollardrestore_state + instantiates dollardInstClass_Begin Type_Name dollardAdd_Gen_Class + '(' Type_List ')' dollardAdd_InstType + ';' + dollardInstClass_End + ; +/*==== No Generic Class ====================================================*/ +NoGeneric_C_Declaration : class dollardset_inc_state Type_Name dollardrestore_state dollardStdClass_Begin + __Inherits_Classes { Add_Std_Ancestors(); } + __Uses_Classes { Add_Std_Uses(); } + __Raises_Exception + is + Class_Definition + end __Class_Name ';' + dollardStdClass_End + ; +/*==== Embeded Class =======================================================*/ +Embeded_C_Declaration : Embeded_C_Declaration_1 + | private dollardSet_Priv Embeded_C_Declaration_1 + | protected dollardSet_Prot Embeded_C_Declaration_1 + ; +Embeded_C_Declaration_1 : Generic_C_Instanciation + | NoGeneric_C_Declaration + | Inc_NoGeneric_Class + ; +/*==== Class Definition ====================================================*/ +Class_Definition : __Member_Method_List + __Field_Declaration + __Friends_Declaration + ; + +Generic_Type_List : Generic_Type + | Generic_Type_List ';' Generic_Type + ; + +Generic_Type : IDENTIFIER { Set_Item($1); } as Type_Constraint + ; + +Type_Constraint : any dollardSet_Any dollardAdd_GenType + | Type_Name dollardAdd_GenType + | Type_Name '(' dollardDynaType_Begin Type_List ')' + dollardAdd_InstType dollardAdd_DynaGenType + ; +__Inherits_Classes : Empty + | inherits Type_List + ; +__Uses_Classes : Empty + | uses Type_List + ; +__Raises_Exception : Empty + | raises Type_List dollardAdd_Raises + ; +__Embeded_Class_List : Empty + | Embeded_Class_List + ; +Embeded_Class_List : Embeded_C_Declaration dollardAdd_Embeded + | Embeded_Class_List Embeded_C_Declaration dollardAdd_Embeded + ; +__Class_Name : Empty + | Type_Name + ; +Type_List : Type_Name { Add_Type(); } + | Type_List ',' Type_Name { Add_Type(); } + ; +Type_Name : IDENTIFIER { Type_Name($1); Type_Pack_Blanc(); } + | IDENTIFIER CDL_from { Type_Name($1); } Package_Name { Type_Pack($4); } + ; + +/*==========================================================================*/ +/*==== Exception Definition ================================================*/ +/*==========================================================================*/ +Exception_Declaration : exception dollardset_inc_state Type_Name dollardrestore_state dollardExcept_Begin + inherits + Type_List + ';' + dollardExcept_End + ; + +/*==========================================================================*/ +/*==== Alias Definition ====================================================*/ +/*==========================================================================*/ +Alias_Declaration : alias dollardset_inc_state Type_Name dollardrestore_state dollardAlias_Begin + is + Type_Name dollardAlias_Type + ';' + dollardAlias_End + ; + +/*==========================================================================*/ +/*==== Pointer Definition ====================================================*/ +/*==========================================================================*/ +Pointer_Declaration : pointer dollardset_inc_state Type_Name dollardrestore_state dollardPointer_Begin + CDL_to + Type_Name dollardPointer_Type + ';' + dollardPointer_End + ; + +/*==========================================================================*/ +/*==== Imported Definition =================================================*/ +/*==========================================================================*/ +Imported_Declaration : imported dollardset_inc_state Type_Name dollardrestore_state dollardImported_Begin ';' dollardImported_End + ; + +/*==========================================================================*/ +/*==== Imported Definition =================================================*/ +/*==========================================================================*/ +Primitive_Declaration : primitive dollardset_inc_state Type_Name dollardrestore_state dollardPrim_Begin + __Inherits_Classes + ';' + dollardPrim_End + ; + +/*==========================================================================*/ +/*==== Enumeration Definition ==============================================*/ +/*==========================================================================*/ +Enumeration_Declaration : enumeration dollardset_inc_state Type_Name dollardrestore_state dollardEnum_Begin + is + Enum_Item_List + __Enumeration_End + ';' + dollardEnum_End + ; +__Enumeration_End : Empty + | Enumeration_End + ; +Enumeration_End : end + | end Type_Name + ; +Enum_Item_List : IDENTIFIER { Add_Enum($1); } + | Enum_Item_List ',' IDENTIFIER { Add_Enum($3); } + ; +/*==========================================================================*/ +/*==== Method Definition ===================================================*/ +/*==========================================================================*/ +__Member_Method_List : Empty + | Member_Method_List { add_cpp_comment_to_method(); } + ; +Member_Method_List : Member_Method + | Member_Method_List Member_Method + ; +Member_Method : Method_Name Method_Definition + ; +Method_Name : IDENTIFIER { Set_Method($1); } + ; +Method_Definition : Constructor + | Instance_Method + | Class_Method + ; +__Extern_Method_List : Empty + | Extern_Method_List { add_cpp_comment_to_method(); } + ; +Extern_Method_List : Extern_Method + | Extern_Method_List Extern_Method + ; +Extern_Method : Method_Name Extern_Met_Definition + ; +Extern_Met_Definition : Extern_Met + ; +/*==== Methods definitions =================================================*/ +Constructor : Constructor_Header + __Constructed_Type_Dec + __Errors_Declaration + __Scoop_Declaration + ';' + dollardMemberMet_End + ; +Instance_Method : Instance_Method_Header + __Returnrd_Type_Dec + __Errors_Declaration + __Inst_Met_Attr_Dec + ';' + dollardMemberMet_End + ; +Class_Method : Class_Method_Header + __Returnrd_Type_Dec + __Errors_Declaration + __Scoop_Declaration + ';' + dollardMemberMet_End + ; +Extern_Met : Extern_Method_Header + __Returnrd_Type_Dec + __Errors_Declaration + __Scoop_Declaration + ';' + dollardExternMet_End + ; +/*==== The Headers =========================================================*/ +Constructor_Header : Empty dollardConstruct_Begin + | '(' dollardConstruct_Begin Parameter_List ')' + ; +Extern_Method_Header : Empty dollardExtMet_Begin dollardEnd + | '(' dollardExtMet_Begin Parameter_List ')' + ; +Instance_Method_Header : '(' me dollardInstMet_Begin __Me_Mode dollardAdd_Me + __S_Parameter_List ')' + ; +Class_Method_Header : '(' myclass dollardClassMet_Begin __S_Parameter_List ')' + ; + +Friend_Const_Header : Empty dollardFriend_Construct_Begin + | '(' dollardFriend_Construct_Begin Parameter_List ')' + ; +Friend_ExtMet_Header : Empty dollardFriend_ExtMet_Begin dollardEnd + | '(' dollardFriend_ExtMet_Begin Parameter_List ')' + ; +Friend_InstMet_Header : '(' me dollardFriend_InstMet_Begin __Me_Mode dollardAdd_Me + __S_Parameter_List ')' + ; +Friend_ClassMet_Header : '(' myclass dollardFriend_ClassMet_Begin + __S_Parameter_List ')' + ; + +/*==========================================================================*/ +/*==== Parameter Definition ================================================*/ +/*==========================================================================*/ +__S_Parameter_List : Empty + | ';' Parameter_List + ; +Parameter_List : Parameter + | Parameter_List ';' Parameter + ; +Parameter : Name_List ':' Passage_Mode + Transmeted_Type dollardParam_Begin + ; +/*==== The Parameter Mode ==================================================*/ +Passage_Mode : __In + | out dollardSet_Out + | in out dollardSet_InOut + ; +__In : Empty + | in dollardSet_In + ; +__Me_Mode : Empty + | ':' Passage_Mode __Acces_Mode + ; +__Acces_Mode : Empty + | Acces_Mode + ; +Acces_Mode : mutable dollardSet_Mutable + | any dollardSet_Mutable_Any + | immutable dollardSet_Immutable + ; + + +/*==========================================================================*/ +/*==== Type Definition =====================================================*/ +/*==========================================================================*/ +/* | like IDENTIFIER dollardSet_Like_Type; */ + +Transmeted_Type : __Acces_Mode Associated_Type + | __Acces_Mode Type_Name __Initial_Value + ; +Constructed_Type : __Acces_Mode Type_Name dollardAdd_Returns + ; +Returned_Type : __Acces_Mode Type_Name dollardAdd_Returns + | __Acces_Mode Associated_Type dollardAdd_Returns + ; +Associated_Type : like me dollardSet_Like_Me + ; +__Initial_Value : Empty + |'=' Initial_Value + ; +Initial_Value : INTEGER { Add_Value($1,INTEGER); } + | REAL { Add_Value($1,REAL); } + | STRING { Add_Value($1,STRING); } + | LITERAL { Add_Value($1,LITERAL); } + | IDENTIFIER { Add_Value($1,IDENTIFIER); } + ; + +__Returnrd_Type_Dec : Empty + | returns Returned_Type + ; +__Constructed_Type_Dec : Empty + | returns Constructed_Type + ; +__Errors_Declaration : Empty + | raises Type_List dollardAdd_MetRaises + ; +__Inst_Met_Attr_Dec : Empty dollardSet_Static + | is Inst_Met_Attr_Dec + ; +Inst_Met_Attr_Dec : Scoop + | Definition_Level __Scoop + ; +Definition_Level : Redefinition + | redefined dollardSet_Redefined __Redefinition + ; +__Redefinition : Empty dollardSet_Virtual + | Redefinition + ; +Redefinition : statiC dollardSet_Static + | deferred dollardSet_Defe dollardSet_Virtual + | virtual dollardSet_Virtual + ; + +/*==========================================================================*/ +/*==== Field Definition ====================================================*/ +/*==========================================================================*/ +__Field_Declaration : Empty + | fields + Field_List + ; +Field_List : Field + | Field_List Field + ; +Field : Name_List ':' Type_Name + __Field_Dimension + __Scoop_Pro_Declaration + ';' dollardAdd_Field + ; +__Field_Dimension : Empty + | '[' Integer_List ']' + ; + +Integer_List : INTEGER { Begin_List_Int($1); } + | Integer_List ',' INTEGER { Make_List_Int($3); } + ; +/*==========================================================================*/ +/*==== Friend Definition ===================================================*/ +/*==========================================================================*/ +__Friends_Declaration : Empty + | friends { CDL_MustNotCheckUses(); } Friend_List { CDL_MustCheckUses(); } + ; +Friend_List : Friend + | Friend_List ',' Friend + ; +Friend : Friend_Method_Dec + | class Type_Name dollardAdd_Friend_Class + ; +Friend_Method_Dec : Method_Name Friend_Method + ; +Friend_Method : CDL_from __Class Type_Name { Method_TypeName(); } Friend_Method_Type_Dec + | CDL_from package IDENTIFIER Friend_ExtMet_Header + { Add_FriendExtMet($3); } + ; + +Friend_Method_Type_Dec : Friend_InstMet_Header dollardAdd_FriendMet + | Friend_ClassMet_Header dollardAdd_FriendMet + | Friend_Const_Header dollardAdd_FriendMet + ; +__Class : Empty + | class + ; + +/*==========================================================================*/ +/*==== Scoop Definition ====================================================*/ +/*==========================================================================*/ +__Scoop_Declaration : Empty + | is Scoop + ; +__Scoop_Pro_Declaration : Empty + | is protected dollardSet_Prot + ; +__Scoop : Empty + | Scoop + ; +Scoop : private dollardSet_Priv + | protected dollardSet_Prot + ; +/*==========================================================================*/ +/*==== Others ==============================================================*/ +/*==========================================================================*/ +Name_List : IDENTIFIER { add_name_to_list($1); } + | Name_List ',' IDENTIFIER { add_name_to_list($3); } + ; +Empty : + ; +Empty_Str : {$$[0] = '\0';} + ; +/*==========================================================================*/ +/*==== The actions =========================================================*/ +/*==========================================================================*/ + +/*=-=-=-=-=-=-=-=-= Manage the names and the lists =-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardset_inc_state : {set_inc_state();} +dollardrestore_state : {restore_state();} +/*=-=-=-=-=-=-=-=-= The actions for the Interface =-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardInterface_Class : {Interface_Class();} +dollardInterface_End : {Interface_End();} +/*=-=-=-=-=-=-=-=-= The actions for the Engine =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardEngine_End : {Engine_End();} +/*=-=-=-=-=-=-=-=-= The actions for the classes =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardAlias_Begin : {Alias_Begin();} +dollardAlias_Type : {Alias_Type();} +dollardAlias_End : {Alias_End();} +/*--------------------------------------------------------------------------*/ +dollardPointer_Begin : {Pointer_Begin();} +dollardPointer_Type : {Pointer_Type();} +dollardPointer_End : {Pointer_End();} +/*--------------------------------------------------------------------------*/ +dollardImported_Begin : {Imported_Begin();} +dollardImported_End : {Imported_End();} +/*--------------------------------------------------------------------------*/ +dollardPrim_Begin : {Prim_Begin();} +dollardPrim_End : {Prim_End();} +/*--------------------------------------------------------------------------*/ +dollardExcept_Begin : {Except_Begin();} +dollardExcept_End : {Except_End();} +/*--------------------------------------------------------------------------*/ +dollardEnum_Begin : {Enum_Begin();} +dollardEnum_End : {Enum_End();} +/*--------------------------------------------------------------------------*/ +dollardInc_Class_Dec : {Inc_Class_Dec();} +dollardInc_GenClass_Dec : {Inc_GenClass_Dec();} +/*--------------------------------------------------------------------------*/ +dollardGenClass_Begin : {GenClass_Begin();} +dollardAdd_GenType : {Add_GenType();} +dollardAdd_DynaGenType : {Add_DynaGenType();} +dollardAdd_Embeded : {Add_Embeded();} +dollardGenClass_End : {GenClass_End();} +/*--------------------------------------------------------------------------*/ +dollardInstClass_Begin : {InstClass_Begin();} +dollardAdd_Gen_Class : {Add_Gen_Class();} +dollardAdd_InstType : {Add_InstType();} +dollardInstClass_End : {InstClass_End();} +dollardDynaType_Begin : {DynaType_Begin();} +/*--------------------------------------------------------------------------*/ +dollardStdClass_Begin : {StdClass_Begin();} +dollardStdClass_End : {StdClass_End();} +/*--------------------------------------------------------------------------*/ +dollardAdd_Raises : {Add_Raises();} +dollardAdd_Field : {Add_Field();} +dollardAdd_FriendMet : {Add_FriendMet();} +dollardAdd_Friend_Class : {Add_Friend_Class();} +/*=-=-=-=-=-=-=-=-= The actions for the Methods =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardConstruct_Begin : {Construct_Begin();} +dollardInstMet_Begin : {InstMet_Begin();} +dollardClassMet_Begin : {ClassMet_Begin();} +dollardExtMet_Begin : {ExtMet_Begin();} +dollardFriend_Construct_Begin : {Friend_Construct_Begin();} +dollardFriend_InstMet_Begin : {Friend_InstMet_Begin();} +dollardFriend_ClassMet_Begin : {Friend_ClassMet_Begin();} +dollardFriend_ExtMet_Begin : {Friend_ExtMet_Begin();} +dollardAdd_Me : {Add_Me();} +dollardAdd_MetRaises : {Add_MetRaises();} +dollardAdd_Returns : {Add_Returns();} +dollardMemberMet_End : {MemberMet_End();} +dollardExternMet_End : {ExternMet_End();} +/*=-=-=-=-=-=-=-=-= The actions for Parameteres =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardParam_Begin : {Param_Begin();} +/*=-=-=-=-=-=-=-=-= The general actions =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +dollardEnd : {End();} +dollardSet_In : {Set_In();} +dollardSet_Out : {Set_Out();} +dollardSet_InOut : {Set_InOut();} +dollardSet_Mutable : {Set_Mutable();} +dollardSet_Mutable_Any : {Set_Mutable_Any();} +dollardSet_Immutable : {Set_Immutable();} +dollardSet_Priv : {Set_Priv();} +dollardSet_Defe : {Set_Defe();} +dollardSet_Redefined : {Set_Redefined();} +dollardSet_Prot : {Set_Prot();} +dollardSet_Static : {Set_Static();} +dollardSet_Virtual : {Set_Virtual();} +dollardSet_Like_Me : {Set_Like_Me();} +dollardSet_Any : {Set_Any();} +%% diff --git a/src/CDLFront/CDLFront.cxx b/src/CDLFront/CDLFront.cxx new file mode 100755 index 0000000..3d30d98 --- /dev/null +++ b/src/CDLFront/CDLFront.cxx @@ -0,0 +1,2711 @@ +// CDL cdl.cxx Version 1.1 +// +// Date: 06/04/1995 +// +// +// +#include +#include +// Standard includes +// +#include + +// MS includes +// +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +// instantiations +// +#include +#include +#include +#include +#include +#include +#include +#include + +// Collections includes +// +#include +#include +#include + +// CDLFront include +#include + +// lex and yacc glue includes +// +extern "C" { +#include +} +#include +#include + +void CDL_InitVariable(); + +static char *YY_fileName=""; +static int YY_nb_error; +static int YY_nb_warning; +static Handle(TCollection_HAsciiString) CDLFileName; + +extern "C" { + void CDLerror(char* text) + { + extern int CDLlineno; + + // The unix like error declaration + // + if (text == NULL) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": syntax error..." << endm; + CDL_InitVariable(); + MS_TraductionError::Raise("Syntax error"); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << text << endm; + YY_nb_error++; + } + } + +// int yyparse(); + +#ifdef YYDEBUG + extern int yydebug = 1; +#endif +} + +// line number of method definition (for C++ directive error) +// +static Standard_Integer methodlineno = 0; + +#define MAX_CHAR 256 + +// type of the current entity +// +#define CDL_NULL 0 +#define CDL_PACKAGE 1 +#define CDL_STDCLASS 2 +#define CDL_GENCLASS 3 +#define CDL_NESCLASS 4 +#define CDL_INCDECL 5 +#define CDL_GENTYPE 6 +#define CDL_INTERFACE 7 +#define CDL_EXECUTABLE 8 +#define CDL_CLIENT 9 + +#define CDL_CPP 1 +#define CDL_FOR 2 +#define CDL_C 3 +#define CDL_OBJ 4 +#define CDL_LIBRARY 5 +#define CDL_EXTERNAL 6 + +#define CDL_MUSTNOTCHECKUSES 0 +#define CDL_MUSTCHECKUSES 1 + +// because we don't check uses for friends +// +static Standard_Integer CheckUsesForClasses = CDL_MUSTCHECKUSES; + +static Standard_Integer Current_Entity = CDL_NULL; +static Standard_Integer SaveState = CDL_NULL; + +// lex variable +// line number +// +#ifndef WNT +extern int CDLlineno; +#else +extern "C" int CDLlineno; +#endif // WNT + +// The Flags +// +static Standard_Boolean Private = Standard_False, + Protected = Standard_False, + Static = Standard_True, + Deferred = Standard_False, + Redefined = Standard_False, + Like = Standard_False, + Any = Standard_False, + CPPReturnRef = Standard_False, + CPPReturnConst = Standard_False, + CPPOperator = Standard_False, + CPPAlias = Standard_False, + CPPInline = Standard_False; + +static Standard_Boolean DynaType = Standard_False; + + +// The Identifiers +// +static char thetypename [MAX_CHAR + 1], // The name of the current type + Pack_Name [MAX_CHAR + 1]; // The Name of package + +// The Classes +// +static Standard_Integer Mutable = 0, + InOrOut = MS_IN; + +// Container : an entity where type are declared or defined +// ex.: a package, an interface,... +// +Handle(TCollection_HAsciiString) Container = new TCollection_HAsciiString; + +// The variables representing the analyze of current object +// The Conventions: +// Begining of analyse: a new object is creating. +// End of analyse: the variable is nullified +// + +// The Schema variables +// +static Handle(MS_Schema) Schema; // The current Schema + +// The Engine variables +// +static Handle(MS_Engine) Engine; // The current Engine + +// The Component variables +// +static Handle(MS_Component) Component; // The current Component + +// The Executable variables +// +static Handle(MS_Executable) Executable; // The current Executable +static Handle(MS_ExecPart) ExecPart; // The current ExePart +static Handle(MS_HSequenceOfExecPart) ExecTable; +static int ExecutableLanguage; +static int ExecutableUseType; + +// The Client variables +// +static Handle(MS_Client) Client; // The current Client + +// The Interface variables +// +static Handle(MS_Interface) Interface; // The current Interface + +// The Package variables +// +static Handle(MS_Package) Package; // The current package + +// The Alias variables +// +static Handle(MS_Alias) Alias; // The current Alias + +// The Pointer variables +// +static Handle(MS_Pointer) Pointer; // The current Pointer + +// The Imported variables +// +static Handle(MS_Imported) Imported; // The current Imported + +// The primitive variables +// +static Handle(MS_PrimType) Primitive; // The current Primitive + +// The Enum variables +// +static Handle(MS_Enum) Enum; // The current enum + +// The Error (exception) class +// +static Handle(MS_Error) Exception; + +// For dynamic generic instantiation like +// generic class toto (item1, this one --> item2 as list from TCollection(item1)) +// +static Handle(MS_GenType) DynType; + +// The Class variables +// +static Handle(MS_Class) SimpleClass; + +static Handle(MS_StdClass) Class; // The current class + +static Handle(MS_StdClass) StdClass; // The current class is + // a Standard Class + +static Handle(MS_StdClass) GenStdClass;// The current class + // descipt a Generic Class + +static Handle(MS_Error) Error; // The current class is + // a Exception + +static Handle(MS_GenClass) GenClass; // The current class is + // a Generic class + +static Handle(MS_InstClass) InstClass; // The current class is + // a instanciated class + +static Handle(MS_GenClass) Embeded; // The current class is + // embeded class + +// The Method variables +// +static Handle(TCollection_HAsciiString) MethodName = new TCollection_HAsciiString; + +static Handle(MS_Method) Method; // The current method + +static Handle(MS_MemberMet) MemberMet; // The Membermethod + +static Handle(MS_ExternMet) ExternMet; // The current metod is + // a method of package +static Handle(MS_Construc) Construc; // The current metod is + // a constructeur +static Handle(MS_InstMet) InstMet; // The current metod is + // a method of instance +static Handle(MS_ClassMet) ClassMet; // The current metod is + // a method of class + +static Handle(MS_HSequenceOfParam) MethodParams; // The current method parameters + +// The most important : the meta-schema +// +Handle(MS_MetaSchema) theMetaSchema; + +// The Field variables +// +static Handle(MS_Field) Field; + + +static Handle(TCollection_HAsciiString) DefCons = new TCollection_HAsciiString("Initialize"); +static Handle(TCollection_HAsciiString) NorCons = new TCollection_HAsciiString("Create"); + +// The Parameter variables +// +static Handle(MS_Param) Param; +static Standard_Integer ParamType = 0; +static Handle(TCollection_HAsciiString) ParamValue; + +// for clause like : type1,type2,type3, ... ,typen +// +Handle(TColStd_HSequenceOfHAsciiString) ListOfTypes = new TColStd_HSequenceOfHAsciiString; +Handle(TColStd_HSequenceOfHAsciiString) ListOfPackages = new TColStd_HSequenceOfHAsciiString; + +// for generic classes (generic item1, ... ,generic itemn) +// +Handle(TColStd_HSequenceOfHAsciiString) ListOfItem = new TColStd_HSequenceOfHAsciiString; +Handle(TColStd_HSequenceOfHAsciiString) ListOfName = new TColStd_HSequenceOfHAsciiString; +Handle(TColStd_HSequenceOfHAsciiString) ListOfCplusplus = new TColStd_HSequenceOfHAsciiString; +Handle(TColStd_HSequenceOfInteger) ListOfCPPType = new TColStd_HSequenceOfInteger; +Handle(TColStd_HSequenceOfHAsciiString) ListOfInteger = new TColStd_HSequenceOfHAsciiString; + +// this is a dummy package name for generic type (item, etc...) +// +const char *aDummyPackageName = "___D"; +const char *theRootPack = "Standard"; +char thePackNameFound[128]; + +Handle(TColStd_HSequenceOfHAsciiString) ListOfGlobalUsed; +Handle(TColStd_HSequenceOfHAsciiString) ListOfTypeUsed; +Handle(TColStd_HSequenceOfHAsciiString) ListOfInst; +Handle(TColStd_HSequenceOfHAsciiString) ListOfGen; + +void CDL_MustNotCheckUses() +{ + CheckUsesForClasses = CDL_MUSTNOTCHECKUSES; +} + +void CDL_MustCheckUses() +{ + CheckUsesForClasses = CDL_MUSTCHECKUSES; +} + +void CDL_InitVariable() +{ + CheckUsesForClasses = CDL_MUSTCHECKUSES; + Current_Entity = CDL_NULL; + SaveState = CDL_NULL; + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; + Any = Standard_False; + CPPReturnRef = Standard_False; + CPPReturnConst = Standard_False; + CPPOperator = Standard_False; + CPPAlias = Standard_False; + CPPInline = Standard_False; + YY_nb_error = 0; + YY_nb_warning = 0; + + DynaType = Standard_False; + Mutable = 0; + InOrOut = MS_IN; + Container = new TCollection_HAsciiString; + Schema.Nullify(); + Engine.Nullify(); + Component.Nullify(); + Executable.Nullify(); + ExecPart.Nullify(); + ExecTable.Nullify(); + ExecutableLanguage = CDL_CPP; + ExecutableUseType = CDL_LIBRARY; + Interface.Nullify(); + Package.Nullify(); + Alias.Nullify(); + Pointer.Nullify(); + Imported.Nullify(); + Primitive.Nullify(); + Enum.Nullify(); + Exception.Nullify(); + DynType.Nullify(); + SimpleClass.Nullify(); + Class.Nullify(); + StdClass.Nullify(); + GenStdClass.Nullify(); + Error.Nullify(); + GenClass.Nullify(); + InstClass.Nullify(); + Embeded.Nullify(); + MethodName = new TCollection_HAsciiString; + Method.Nullify(); + MemberMet.Nullify(); + ExternMet.Nullify(); + Construc.Nullify(); + MethodParams.Nullify(); + InstMet.Nullify(); + ClassMet.Nullify(); + theMetaSchema.Nullify(); + Field.Nullify(); + Param.Nullify(); + ParamType = 0; + ParamValue.Nullify(); + Client.Nullify(); + ListOfTypes = new TColStd_HSequenceOfHAsciiString; + ListOfPackages = new TColStd_HSequenceOfHAsciiString; + ListOfItem = new TColStd_HSequenceOfHAsciiString; + ListOfName = new TColStd_HSequenceOfHAsciiString; + ListOfCplusplus = new TColStd_HSequenceOfHAsciiString; + ListOfCPPType = new TColStd_HSequenceOfInteger; + ListOfInteger = new TColStd_HSequenceOfHAsciiString; + ListOfGlobalUsed.Nullify(); + ListOfTypeUsed.Nullify(); + ListOfInst.Nullify(); + ListOfGen.Nullify(); +} + +// //////////////////////////////////////// +// Implementation // +// //////////////////////////////////////// +void Clear_ListOfItem() +{ + ListOfItem->Clear(); +} + +void set_inc_state() +{ + SaveState = Current_Entity; + Current_Entity = CDL_INCDECL; +} + +void restore_state() +{ + Current_Entity = SaveState; +} + +void Type_Name(char *aName) +{ + strncpy(thetypename,aName,MAX_CHAR); +} + +// WARNING : dirty code : look at "Standard_" (but faster than build a string from MS::RootPackageName() + "_") +// +Standard_Boolean VerifyClassUses(const Handle(TCollection_HAsciiString)& thetypename) +{ + if ((Current_Entity == CDL_STDCLASS || Current_Entity == CDL_GENCLASS) && CheckUsesForClasses == CDL_MUSTCHECKUSES) { + // WARNING : dirty code -> here is !!! (sorry for future hacker, guilty : CLE) + // + if (strncmp("Standard_",thetypename->ToCString(),9) == 0) { + if (theMetaSchema->IsDefined(thetypename)) { + ListOfTypeUsed->Append(thetypename); + + return Standard_True; + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The package Standard has no declaration of " << "'" << thetypename << "'" << endm; + YY_nb_error++; + return Standard_True; + } + } + + if (thetypename->IsSameString(SimpleClass->FullName())) return Standard_True; + + if (Current_Entity == CDL_GENCLASS) { + if (thetypename->IsSameString(GenClass->FullName())) return Standard_True; + + Standard_Integer i; + Handle(TColStd_HSequenceOfHAsciiString) seqascii = GenClass->GetNestedName(); + Handle(TCollection_HAsciiString) nestname, + nestnestname = new TCollection_HAsciiString; + + if (theMetaSchema->IsDefined(thetypename)) { + Handle(MS_Type) theType = theMetaSchema->GetType(thetypename); + + if (theType->IsKind(STANDARD_TYPE(MS_Class))) { + Handle(MS_Class) inst = *((Handle(MS_Class)*)&theType); + + if (!inst->GetNestingClass().IsNull()) { + if (GenClass->FullName()->IsSameString(inst->GetNestingClass())) return Standard_True; + nestnestname = inst->GetNestingClass(); + } + } + } + + for (i = 1; i <= seqascii->Length(); i++) { + nestname = MS::BuildFullName(Container,seqascii->Value(i)); + + if (thetypename->IsSameString(nestname) || nestnestname->IsSameString(nestname)) { + return Standard_True; + } + } + + Handle(MS_HSequenceOfGenType) genericitems = GenClass->GenTypes(); + + for (i = 1; i <= genericitems->Length(); i++) { + if (genericitems->Value(i)->Name()->IsSameString(thetypename)) { + return Standard_True; + } + } + } + + Handle(TColStd_HSequenceOfHAsciiString) seqOfType = SimpleClass->GetUsesNames(); + + for (Standard_Integer i = 1; i <= seqOfType->Length(); i++) { + if (seqOfType->Value(i)->IsSameString(thetypename)) { + return Standard_True; + } + } + + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The 'uses' statement of your class has no declaration of : " << thetypename << endm; + YY_nb_error++; + } + else return Standard_True; + + return Standard_False; +} + +Standard_Boolean VerifyUses(char* used) +{ + if (Current_Entity == CDL_PACKAGE || Current_Entity == CDL_INTERFACE || Current_Entity == CDL_EXECUTABLE) { + Handle(TColStd_HSequenceOfHAsciiString) aSeqOfPackage; + Handle(MS_Package) aPackage; + Handle(MS_Interface) anInterface; + Handle(MS_Engine) anEngine; + Handle(MS_Component) aComponent; + Standard_Boolean status = Standard_False; + + if (theMetaSchema->IsPackage(Container)) { + aPackage = theMetaSchema->GetPackage(Container); + aSeqOfPackage = aPackage->Uses(); + } + else if (theMetaSchema->IsInterface(Container)) { + anInterface = theMetaSchema->GetInterface(Container); + aSeqOfPackage = anInterface->Uses(); + } + else if (theMetaSchema->IsEngine(Container)) { + anEngine = theMetaSchema->GetEngine(Container); + aSeqOfPackage = anEngine->Uses(); + } + else if (theMetaSchema->IsComponent(Container)) { + aComponent = theMetaSchema->GetComponent(Container); + aSeqOfPackage = aComponent->Uses(); + } + + for (Standard_Integer i = 1; i <= aSeqOfPackage->Length() && (status == 0); i++) { + if (strcmp(aSeqOfPackage->Value(i)->ToCString(),used) == 0) { + status = Standard_True; + } + } + + return status; + } + else return Standard_True; +} + +void Type_Pack(char *aName) +{ + if (!VerifyUses(aName)) { + Handle(TCollection_HAsciiString) msg = new TCollection_HAsciiString("the entity : "); + msg->AssignCat(aName); + msg->AssignCat(" is not in the 'uses' clause of "); + msg->AssignCat(Container); + CDLerror(msg->ToCString()); + } + strncpy(Pack_Name,aName,MAX_CHAR); +} + +char *TypeCompletion(char *aName) +{ + Handle(TColStd_HSequenceOfHAsciiString) aSeqOfPackage; + Handle(TCollection_HAsciiString) aFullName = new TCollection_HAsciiString; + Standard_Integer i,pos; + + if (Current_Entity == CDL_GENCLASS || Current_Entity == CDL_STDCLASS) { + Handle(TCollection_HAsciiString) aPackageName, thethetypename = new TCollection_HAsciiString(aName); + + + if (SimpleClass->Name()->IsSameString(thethetypename)) { + return Container->ToCString(); + } + + aSeqOfPackage = SimpleClass->GetUsesNames(); + + for (i = 1; i <= aSeqOfPackage->Length(); i++) { + aPackageName = aSeqOfPackage->Value(i)->Token("_"); + if (aSeqOfPackage->Value(i)->IsSameString(MS::BuildFullName(aPackageName,thethetypename))) { + strcpy(thePackNameFound,aPackageName->ToCString()); + return thePackNameFound; + } + } + + if (theMetaSchema->IsDefined(MS::BuildFullName(MS::GetPackageRootName(),thethetypename))) return (char *)theRootPack; + + if (Current_Entity == CDL_GENCLASS) { + for (i = 1; i <= ListOfItem->Length(); i++) { + if (strcmp(ListOfItem->Value(i)->ToCString(),aName) == 0) { + return (char *)aDummyPackageName; + } + } + } + } + + Handle(MS_Package) aPackage; + Handle(MS_Interface) anInterface; + Handle(MS_Engine) anEngine; + Handle(MS_Component) aComponent; + + if (theMetaSchema->IsPackage(Container)) { + aPackage = theMetaSchema->GetPackage(Container); + aSeqOfPackage = aPackage->Uses(); + } + else if (theMetaSchema->IsInterface(Container)) { + anInterface = theMetaSchema->GetInterface(Container); + aSeqOfPackage = anInterface->Uses(); + } + else if (theMetaSchema->IsEngine(Container)) { + anEngine = theMetaSchema->GetEngine(Container); + aSeqOfPackage = anEngine->Uses(); + } + else if (theMetaSchema->IsComponent(Container)) { + aComponent = theMetaSchema->GetComponent(Container); + aSeqOfPackage = aComponent->Uses(); + } + else { + aSeqOfPackage = new TColStd_HSequenceOfHAsciiString; + aSeqOfPackage->Append(MS::GetPackageRootName()); + } + + for (i = 1; i <= aSeqOfPackage->Length(); i++) { + aFullName->AssignCat(aSeqOfPackage->Value(i)); + aFullName->AssignCat("_"); + aFullName->AssignCat(aName); + + if (theMetaSchema->IsDefined(aFullName)) { + return aSeqOfPackage->Value(i)->ToCString(); + } + + aFullName->Clear(); + } + + + return NULL; +} + +void Type_Pack_Blanc() +{ + char *thePackName; + + // we check if we are able to use incomplete declaration + // + if (Current_Entity == CDL_PACKAGE || Current_Entity == CDL_INTERFACE || Current_Entity == CDL_EXECUTABLE || Current_Entity == CDL_CLIENT) { + Handle(TCollection_HAsciiString) aFullName = new TCollection_HAsciiString; + aFullName->AssignCat(Container); + aFullName->AssignCat("_"); + aFullName->AssignCat(thetypename); + + if (!theMetaSchema->IsDefined(aFullName)) { + aFullName->Clear(); + aFullName->AssignCat(MS::GetPackageRootName()); + aFullName->AssignCat("_"); + aFullName->AssignCat(thetypename); + + if (!theMetaSchema->IsDefined(aFullName)) { + Handle(TCollection_HAsciiString) msg = new TCollection_HAsciiString("the type '"); + msg->AssignCat(thetypename); + msg->AssignCat("' must be followed by a package name."); + CDLerror(msg->ToCString()); + } + } + } + + if (Current_Entity != CDL_INCDECL && Current_Entity != CDL_GENTYPE) { + thePackName = TypeCompletion(thetypename); + + if (thePackName == NULL) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "the type '" << thetypename << "' is not defined." << endm; + YY_nb_error++; + } + else { + Type_Pack(thePackName); + } + } + else { + Type_Pack(Container->ToCString()); + } +} + +void Add_Type() +{ + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + Handle(TCollection_HAsciiString) athetypename = new TCollection_HAsciiString(thetypename); + + ListOfTypes->Append(athetypename); + ListOfPackages->Append(aPackName); +} + +void add_cpp_comment(int cpptype, char *comment) +{ + Handle(TCollection_HAsciiString) aComment; + Handle(TCollection_HAsciiString) aRealComment; + + if (Method.IsNull()) { + WarningMsg << "CDL" << "line " << CDLlineno << " : " << "C++ directive outside method definition : " << comment << endm; + YY_nb_warning++; + } + else { + // cout << Method->Name()->ToCString() << " " << comment << endl; + if (cpptype == CDL_HARDALIAS || cpptype == CDL_OPERATOR) { + Standard_Integer pos; + aComment = new TCollection_HAsciiString(comment), + + pos = aComment->Location(1,':',1,aComment->Length()); + aRealComment = aComment->SubString(pos + 1,aComment->Length()); + aRealComment->LeftAdjust(); + } + + ListOfCplusplus->Append(aRealComment); + ListOfCPPType->Append(cpptype); + } +} + +void add_name_to_list(char *name) +{ + Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(name); + + ListOfName->Append(aName); +} + +void Begin_List_Int(char *anInt) +{ + Handle(TCollection_HAsciiString) Int = new TCollection_HAsciiString(anInt); + + ListOfInteger->Clear(); + ListOfInteger->Append(Int); +} + +void Make_List_Int(char *anInt) +{ + Handle(TCollection_HAsciiString) Int = new TCollection_HAsciiString(anInt); + + ListOfInteger->Append(Int); +} + +// The actions for the Schema +// +void Schema_Begin(char *name) +{ + Handle(TCollection_HAsciiString) aSchemaName = new TCollection_HAsciiString(name); + + Schema = new MS_Schema(aSchemaName); + Schema->MetaSchema(theMetaSchema); + Container = aSchemaName; + + if (!theMetaSchema->AddSchema(Schema)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Schema : " << aSchemaName << " is already defined." << endm; + YY_nb_error++; + } +} + +void Schema_Package(char *name) +{ + Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(name); + + Schema->Package(aName); +} + +void Schema_Class() +{ + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackageName = new TCollection_HAsciiString(Pack_Name); + + Schema->Class(MS::BuildFullName(aPackageName,aClassName)); +} + +void Schema_End() +{ + Schema.Nullify(); + Container.Nullify(); +} + +// The actions for the Engine +// +void Engine_Begin(char *engineName) +{ + Handle(TCollection_HAsciiString) anEngineName = new TCollection_HAsciiString(engineName); + + Engine = new MS_Engine(anEngineName); + Engine->MetaSchema(theMetaSchema); + Container = anEngineName; + + if (!theMetaSchema->AddEngine(Engine)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Engine : " << anEngineName << " is already defined." << endm; + YY_nb_error++; + } + + Engine->Use(MS::GetPackageRootName()); +} + +void Engine_Schema(char *name) +{ + Handle(TCollection_HAsciiString) sname = new TCollection_HAsciiString(name); + + Engine->Schema(sname); + ListOfGlobalUsed->Append(sname); +} + +void Engine_Interface(char *inter) +{ + Handle(TCollection_HAsciiString) sname = new TCollection_HAsciiString(inter); + + Engine->Interface(sname); + ListOfGlobalUsed->Append(sname); +} + +void Engine_End() +{ + Engine.Nullify(); + Container.Nullify(); +} + +// The actions for the Component +// +void Component_Begin(char *ComponentName) +{ + Handle(TCollection_HAsciiString) anComponentName = new TCollection_HAsciiString(ComponentName); + + Component = new MS_Component(anComponentName); + Component->MetaSchema(theMetaSchema); + Container = anComponentName; + + if (!theMetaSchema->AddComponent(Component)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Component : " << anComponentName << " is already defined." << endm; + YY_nb_error++; + } + + Component->Use(MS::GetPackageRootName()); +} + +void Component_Interface(char *inter, char *udname) +{ + Handle(TCollection_HAsciiString) uname = new TCollection_HAsciiString(udname); + Handle(TCollection_HAsciiString) sname = new TCollection_HAsciiString(inter); + + sname = MS::BuildFullName(uname,sname); + Component->Interface(sname); + ListOfGlobalUsed->Append(sname); +} + +void Component_End() +{ + Component.Nullify(); + Container.Nullify(); +} + +// UD : stub client +// +void Client_Begin(char *clientName) +{ + Handle(TCollection_HAsciiString) aClientName = new TCollection_HAsciiString(clientName); + + Client = new MS_Client(aClientName); + Client->MetaSchema(theMetaSchema); + Container = aClientName; + + if (!theMetaSchema->AddClient(Client)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Client : " << clientName << " is already defined." << endm; + YY_nb_error++; + } + + Current_Entity = CDL_CLIENT; +} + +void Client_Interface(char *inter) +{ + Handle(TCollection_HAsciiString) aIName = new TCollection_HAsciiString(inter); + + Client->Interface(aIName); +} + +void Client_Method(char *entity, int execmode) +{ + if (execmode == 1) { + if (entity != NULL && !ExternMet.IsNull()) { + ExternMet->Package(new TCollection_HAsciiString(entity)); + } + Method->Params(MethodParams); + MethodParams.Nullify(); + Method->CreateFullName(); + + Client->Method(Method->FullName()); + } + else if (execmode < 0) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "constructor cannot have the asynchronous execution mode." << endm; + YY_nb_error++; + } + + Method.Nullify(); + MemberMet.Nullify(); + ExternMet.Nullify(); + Construc.Nullify(); + InstMet.Nullify(); + ClassMet.Nullify(); +} + + +void Client_End() +{ + Method.Nullify(); + MemberMet.Nullify(); + ExternMet.Nullify(); + Construc.Nullify(); + InstMet.Nullify(); + ClassMet.Nullify(); + Interface.Nullify(); + Container.Nullify(); + Client.Nullify(); + + Current_Entity = CDL_NULL; + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +// The actions for the Executable + +void Executable_Begin(char *name) +{ + ExecutableLanguage = CDL_CPP; + ExecutableUseType = 0; + + Handle(TCollection_HAsciiString) anExecName = new TCollection_HAsciiString(name); + + Executable = new MS_Executable(anExecName); + Executable->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddExecutable(Executable)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Executable : " << anExecName << " is already defined." << endm; + YY_nb_error++; + } + + ExecTable = new MS_HSequenceOfExecPart; + + Current_Entity = CDL_EXECUTABLE; +} + +void ExecFile_Begin(char *name) +{ + ExecutableLanguage = CDL_CPP; + ExecutableUseType = 0; + + Handle(TCollection_HAsciiString) anExecName = new TCollection_HAsciiString(name); + + ExecPart = new MS_ExecPart(anExecName); + ExecPart->MetaSchema(theMetaSchema); + ExecTable->Append(ExecPart); +} + + +void ExecFile_Schema(char *name) +{ + Handle(TCollection_HAsciiString) a = new TCollection_HAsciiString(name); + + ExecPart->Schema(a); +} + +void ExecFile_AddUse(char *name) +{ + Handle(TCollection_HAsciiString) a = new TCollection_HAsciiString(name); + + if (ExecutableUseType == CDL_LIBRARY) { + ExecPart->AddLibrary(a); + } + else { + ExecPart->AddExternal(a); + } +} + +void ExecFile_SetUseType(int t) +{ + ExecutableUseType = t; +} + +void ExecFile_AddComponent(char *name) +{ + Handle(TCollection_HAsciiString) a = new TCollection_HAsciiString(name); + Handle(MS_ExecFile) aFile; + + aFile = new MS_ExecFile(a); + + switch (ExecutableLanguage) { + case CDL_CPP : aFile->SetLanguage(MS_CPP); + break; + case CDL_FOR : aFile->SetLanguage(MS_FORTRAN); + break; + case CDL_C : aFile->SetLanguage(MS_C); + break; + case CDL_OBJ : aFile->SetLanguage(MS_OBJECT); + break; + default : aFile->SetLanguage(MS_CPP); + break; + } + + ExecPart->AddFile(aFile); +} + +void ExecFile_SetLang(int l) +{ + ExecutableLanguage = l; +} + +void ExecFile_End() +{ + ExecPart.Nullify(); +} + +void Executable_End() +{ + Executable->AddParts(ExecTable); + + ExecTable.Nullify(); + Method.Nullify(); + MemberMet.Nullify(); + ExternMet.Nullify(); + Construc.Nullify(); + InstMet.Nullify(); + ClassMet.Nullify(); + Interface.Nullify(); + Executable.Nullify(); + Client.Nullify(); + + Current_Entity = CDL_NULL; + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +// The actions for the Interface + +void Interface_Begin(char *anInterName) +{ + Handle(TCollection_HAsciiString) anInterfaceName = new TCollection_HAsciiString(anInterName); + + Interface = new MS_Interface(anInterfaceName); + Interface->MetaSchema(theMetaSchema); + Container = anInterfaceName; + + if (!theMetaSchema->AddInterface(Interface)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Interface : " << anInterName << " is already defined." << endm; + YY_nb_error++; + } + + Interface->Use(MS::GetPackageRootName()); + Current_Entity = CDL_INTERFACE; +} + +void Interface_Use(char*aPackageName) +{ + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(aPackageName); + + ListOfGlobalUsed->Append(aPackName); + Interface->Use(aPackName); +} + +void Interface_Package(char *aPackageName) +{ + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(aPackageName); + + Interface->Package(aPackName); +} + +void Interface_Class() +{ + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackageName = new TCollection_HAsciiString(Pack_Name); + + Interface->Class(MS::BuildFullName(aPackageName,aClassName)); + ListOfTypeUsed->Append(MS::BuildFullName(aPackageName,aClassName)); +} + +void Method_TypeName() +{ + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackageName = new TCollection_HAsciiString(Pack_Name); + + ListOfTypeUsed->Append(MS::BuildFullName(aPackageName,aClassName)); +} + +void Interface_Method(char *entityName) +{ + if (entityName != NULL && !ExternMet.IsNull()) { + ExternMet->Package(new TCollection_HAsciiString(entityName)); + } + + Method->Params(MethodParams); + MethodParams.Nullify(); + Method->CreateFullName(); + Interface->Method(Method->FullName()); + + Method.Nullify(); + MemberMet.Nullify(); + ExternMet.Nullify(); + Construc.Nullify(); + InstMet.Nullify(); + ClassMet.Nullify(); +} + +void Interface_End() +{ + Method.Nullify(); + MemberMet.Nullify(); + ExternMet.Nullify(); + Construc.Nullify(); + InstMet.Nullify(); + ClassMet.Nullify(); + Interface.Nullify(); + Container.Nullify(); + Client.Nullify(); + + Current_Entity = CDL_NULL; + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +// The actions for the Package +// +void Pack_Begin(char *aPackageName) +{ + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(aPackageName); + + Container = aPackName; + + Package = new MS_Package(aPackName); + + Package->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddPackage(Package)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Package : " << aPackageName << " is already defined." << endm; + YY_nb_error++; + } + Package->Use(MS::GetPackageRootName()); + Current_Entity = CDL_PACKAGE; +} + +void Pack_Use(char *aPackageName) +{ + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(aPackageName); + + ListOfGlobalUsed->Append(aPackName); + Package->Use(aPackName); + +} + +void Pack_End() +{ + add_cpp_comment_to_method(); + Package.Nullify(); + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +// The actions for the classes + +void Alias_Begin() +{ + Handle(TCollection_HAsciiString) anAliasName = new TCollection_HAsciiString(thetypename); + + Alias = new MS_Alias(anAliasName,Container,Container,Private); + + Alias->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddType(Alias)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Alias : " << Alias->FullName() << " is already defined." << endm; + YY_nb_error++; + } + + Private = Standard_False; +} + +void Alias_Type() +{ + Handle(TCollection_HAsciiString) anAliasName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackageName = new TCollection_HAsciiString(Pack_Name); + + + Alias->Type(anAliasName,aPackageName); + ListOfTypeUsed->Append(Alias->Type()); +} + +void Alias_End() +{ + Package->Alias(Alias->Name()); + Alias.Nullify(); +} + +// Pointer type +// +void Pointer_Begin() +{ + Handle(TCollection_HAsciiString) aPointerName = new TCollection_HAsciiString(thetypename); + + Pointer = new MS_Pointer(aPointerName,Container,Container,Private); + + Pointer->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddType(Pointer)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Pointer : " << Pointer->FullName() << " is already defined." << endm; + YY_nb_error++; + } + + Private = Standard_False; +} + +void Pointer_Type() +{ + Handle(TCollection_HAsciiString) athetypename = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackageName = new TCollection_HAsciiString(Pack_Name); + + Pointer->Type(athetypename,aPackageName); + ListOfTypeUsed->Append(Pointer->Type()); +} + +void Pointer_End() +{ + Package->Pointer(Pointer->Name()); + Pointer.Nullify(); +} + + +void Imported_Begin() +{ + Handle(TCollection_HAsciiString) anImportedName = new TCollection_HAsciiString(thetypename); + + Imported = new MS_Imported(anImportedName,Container,Container,Private); + + Imported->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddType(Imported)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Imported : " << Imported->FullName() << " is already defined." << endm; + YY_nb_error++; + } + + Private = Standard_False; +} + +void Imported_End() +{ + Package->Imported(Imported->Name()); + Imported.Nullify(); +} + + +void Prim_Begin() +{ + Handle(TCollection_HAsciiString) aPrimName = new TCollection_HAsciiString(thetypename); + + Primitive = new MS_PrimType(aPrimName,Container,Container,Private); + + Primitive->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddType(Primitive)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Primitive : " << Primitive->FullName() << " is already defined." << endm; + YY_nb_error++; + } + + Private = Standard_False; +} + +void Prim_End() +{ + Standard_Integer i; + Handle(TCollection_HAsciiString) iName; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + iName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + + if (i > 1) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Type " << Primitive->FullName() << " uses multiple inheritance." << endm; + YY_nb_error++; + } + else if (!iName->IsSameString(Primitive->FullName())) { + Primitive->Inherit(ListOfTypes->Value(i),ListOfPackages->Value(i)); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Primitive : " << Primitive->FullName() << " can not inherits from itself." << endm; + YY_nb_error++; + } + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); + + Package->Primitive(Primitive->Name()); + Primitive.Nullify(); +} + + +void Except_Begin() +{ + Handle(TCollection_HAsciiString) anExceptName = new TCollection_HAsciiString(thetypename); + + Exception = new MS_Error(anExceptName,Container); + + Exception->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddType(Exception)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Exception : " << Exception->FullName() << " is already defined." << endm; + YY_nb_error++; + } +} + +void Except_End() +{ + Standard_Integer i; + Handle(TCollection_HAsciiString) iName; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + iName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + + if (i > 1) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Exception " << Exception->FullName() << " uses multiple inheritance." << endm; + YY_nb_error++; + } + else if (!iName->IsSameString(Exception->FullName())) { + Exception->Inherit(ListOfTypes->Value(i),ListOfPackages->Value(i)); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Exception : " << Exception->FullName() << " can not inherits from itself." << endm; + YY_nb_error++; + } + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); + + Package->Except(Exception->Name()); + Exception.Nullify(); +} + +void Inc_Class_Dec() +{ + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + + StdClass = new MS_StdClass(aClassName,Container); + + StdClass->MetaSchema(theMetaSchema); + + if (!theMetaSchema->AddType(StdClass)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class : " << StdClass->FullName() << " is already defined." << endm; + YY_nb_error++; + } + + StdClass->Private(Private); + StdClass->Deferred(Deferred); + StdClass->Incomplete(Standard_True); + Package->Class(StdClass->Name()); + StdClass->Package(Package->FullName()); + + ListOfTypeUsed->Append(StdClass->FullName()); + + StdClass.Nullify(); + + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +void Inc_GenClass_Dec() +{ + Standard_Integer i; + Handle(MS_GenClass) theClass; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + GenClass = new MS_GenClass(ListOfTypes->Value(i),ListOfPackages->Value(i)); + GenClass->MetaSchema(theMetaSchema); + + if (i == 1) { + theClass = GenClass; + } + else { + theClass->AddNested(GenClass->Name()); + GenClass->Mother(theClass->FullName()); + GenClass->NestingClass(theClass->FullName()); + } + + if (!theMetaSchema->AddType(GenClass)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Generic class : " << GenClass->FullName() << " is already defined." << endm; + YY_nb_error++; + } + + GenClass->Private(Private); + GenClass->Deferred(Deferred); + GenClass->Incomplete(Standard_True); + + Package->Class(GenClass->Name()); + GenClass->Package(Package->FullName()); + } + + ListOfGen->Append(theClass->FullName()); + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; + + ListOfTypes->Clear(); + ListOfPackages->Clear(); + + GenClass.Nullify(); +} + +// Generic type processing +// +void GenClass_Begin() +{ + Handle(MS_Package) aPackage; + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + Handle(MS_Type) aType; + + if (Current_Entity == CDL_GENCLASS) { + aPackName = GenClass->Package()->Name(); + } + else { + Container = aPackName; + } + + if (!theMetaSchema->IsPackage(Container)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Unknown package " << Container << endm; + YY_nb_error++; + CDL_InitVariable(); + MS_TraductionError::Raise("Unknown package."); + } + + GenClass = new MS_GenClass(aClassName,aPackName); + + if (!theMetaSchema->IsDefined(GenClass->FullName())) { + GenClass->MetaSchema(theMetaSchema); + + GenClass->Private(Private); + GenClass->Deferred(Deferred); + GenClass->Incomplete(Standard_False); + + theMetaSchema->AddType(GenClass); + } + else { + GenClass = Handle(MS_GenClass)::DownCast(theMetaSchema->GetType(GenClass->FullName())); + + if (GenClass.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class : " << GenClass->FullName() << " already declared but not as a generic class." << endm; + CDL_InitVariable(); + MS_TraductionError::Raise("Class already defined but as generic."); + } + + if (Private != GenClass->Private()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << GenClass->FullName() << " has not the same visibility keyword in package declaration and in class definition." << endm; + YY_nb_error++; + } + + if (Deferred != GenClass->Deferred()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << GenClass->FullName() << " is "; + + if (Deferred) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << GenClass->FullName() << " is declared 'deferred' in class definition but not in package declaration." << endm; + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << GenClass->FullName() << " is declared 'deferred' in package declaration but not in class definition." << endm; + } + YY_nb_error++; + } + GenClass->GetNestedName()->Clear(); + } + + GenClass->Package(aPackName); + + Current_Entity = CDL_GENCLASS; + + SimpleClass = GenClass; + + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +void Add_GenType() +{ + if (Any) { + GenClass->GenType(ListOfItem->Value(ListOfItem->Length())); + Any = Standard_False; + } + else { + Handle(TCollection_HAsciiString) aTName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPName = new TCollection_HAsciiString(Pack_Name); + + GenClass->GenType(ListOfItem->Value(ListOfItem->Length()),MS::BuildFullName(aPName,aTName)); + } +} + +void Add_DynaGenType() +{ + GenClass->GenType(DynType); + + DynType.Nullify(); + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void Add_Embeded() +{ + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void GenClass_End() +{ + ListOfTypes->Clear(); + ListOfPackages->Clear(); + Clear_ListOfItem(); + + GenClass->Incomplete(Standard_False); + + if (!StdClass.IsNull()) { + StdClass->Incomplete(Standard_False); + } + + GenClass.Nullify(); + StdClass.Nullify(); + + Current_Entity = CDL_NULL; +} + + +void InstClass_Begin() +{ + Handle(TCollection_HAsciiString) aPackName = Container; + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + + if (Current_Entity == CDL_GENCLASS) { + aPackName = GenClass->Package()->Name(); + } + + if (Current_Entity != CDL_PACKAGE) { + if (!theMetaSchema->IsPackage(aPackName)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Package : " << Pack_Name << " is not defined." << endm; + CDL_InitVariable(); + MS_TraductionError::Raise("Package not defined."); + } + } + + + InstClass = new MS_InstClass(aClassName,aPackName); + + if (theMetaSchema->IsDefined(InstClass->FullName()) && Current_Entity == CDL_PACKAGE) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Instantiation class " << InstClass->Name() << " is already declared in package " << aPackName << endm; + YY_nb_error++; + } + + InstClass->MetaSchema(theMetaSchema); + + if (!theMetaSchema->IsDefined(InstClass->FullName()) || Current_Entity == CDL_GENCLASS) { + if (Current_Entity == CDL_GENCLASS && theMetaSchema->IsDefined(InstClass->FullName())) { + theMetaSchema->RemoveType(InstClass->FullName(),Standard_False); + GenClass->NestedInsClass(InstClass->Name()); + InstClass->Mother(GenClass->FullName()); + } + else if (Current_Entity == CDL_GENCLASS) { + Handle(MS_Package) aPackage = theMetaSchema->GetPackage(aPackName); + + if (!aPackage->HasClass(aClassName)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Nested instantiation class : " << InstClass->Name() << " is not declared in package " << aPackName << endm; + YY_nb_error++; + CDL_InitVariable(); + MS_TraductionError::Raise("Instantiation not defined."); + } + } + + if (Current_Entity == CDL_GENCLASS) { + InstClass->NestingClass(GenClass->FullName()); + GenClass->AddNested(InstClass->Name()); + } + + InstClass->MetaSchema(theMetaSchema); + InstClass->Package(aPackName); + InstClass->Private(Private); + + theMetaSchema->AddType(InstClass); + Private = Standard_False; + } + else { + Handle(MS_Type) aType = theMetaSchema->GetType(InstClass->FullName()); + + InstClass = Handle(MS_InstClass)::DownCast(aType); + + if (InstClass.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The instantiation " << aClassName << " was not declared..." << endm; + YY_nb_error++; + CDL_InitVariable(); + MS_TraductionError::Raise("Instantiation not defined."); + } + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void Add_Gen_Class() +{ + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + + InstClass->GenClass(aClassName,aPackName); +} + +void Add_InstType() +{ + Standard_Integer i; + Handle(MS_Type) aType; + Handle(TCollection_HAsciiString) aFullName; + Standard_Boolean ComeFromDynaType = Standard_False; + + if (Current_Entity == CDL_GENTYPE) { + ComeFromDynaType = Standard_True; + restore_state(); + } + + for (i = 1; i <= ListOfTypes->Length(); i++) { + aFullName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + + if (theMetaSchema->IsDefined(aFullName)) { + aType = theMetaSchema->GetType(aFullName); + } + else { + char *athetypename = TypeCompletion(ListOfTypes->Value(i)->ToCString()); + + if (athetypename == aDummyPackageName) { + ListOfPackages->Value(i)->Clear(); + } + } + + if (!ComeFromDynaType) { + InstClass->InstType(ListOfTypes->Value(i),ListOfPackages->Value(i)); + } + else { + if (ListOfPackages->Value(i)->IsEmpty()) { + DynType->InstType(ListOfTypes->Value(i)); + } + else { + DynType->InstType(MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i))); + } + } + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void InstClass_End() +{ + if (Current_Entity == CDL_GENCLASS) { + InstClass->Instantiates(); + } + else if (Current_Entity == CDL_PACKAGE) { + Package->Class(InstClass->Name()); + } + + if (Current_Entity != CDL_GENCLASS) { + ListOfInst->Append(InstClass->FullName()); + } + + + InstClass->Incomplete(Standard_False); + ListOfGen->Append(InstClass->GenClass()); + InstClass.Nullify(); + ListOfTypes->Clear(); + ListOfPackages->Clear(); + + + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +void DynaType_Begin() +{ + Handle(MS_Package) aPackage; + Handle(TColStd_HSequenceOfHAsciiString) aSeqOfPackage; + + SaveState = Current_Entity; + Current_Entity = CDL_GENTYPE; + + + if (! ListOfItem->IsEmpty()) { + Standard_Integer i; + Handle(TCollection_HAsciiString) aPackName; + Handle(TCollection_HAsciiString) aGenName = new TCollection_HAsciiString(thetypename); + + if (strcmp(aDummyPackageName,Pack_Name)) { + aPackName = new TCollection_HAsciiString(Pack_Name); + } + else { + aPackage = theMetaSchema->GetPackage(Container); + aSeqOfPackage = aPackage->Uses(); + + for (i = 1; i <= aSeqOfPackage->Length(); i++) { + if (theMetaSchema->IsDefined(MS::BuildFullName(aSeqOfPackage->Value(i),aGenName))) { + aPackName = aSeqOfPackage->Value(i); + } + } + + if (aPackName.IsNull()) { + aPackName = new TCollection_HAsciiString; + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "constraint type " << thetypename << " comes from a package not declared in 'uses' clause of the package " << Container << endm; + YY_nb_error++; + } + } + + DynType = new MS_GenType(GenClass,ListOfItem->Value(ListOfItem->Length()),MS::BuildFullName(aPackName,aGenName)); + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + + +void StdClass_Begin() +{ + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + + if (Current_Entity == CDL_GENCLASS) { + aPackName = GenClass->Package()->Name(); + } + + Container = aPackName; + + if (!theMetaSchema->IsPackage(Container)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Unknown package " << Container << endm; + YY_nb_error++; + CDL_InitVariable(); + MS_TraductionError::Raise("Unknown package."); + } + + // si la classe n a pas ete cree par une dec incomplete + // + StdClass = new MS_StdClass(aClassName,aPackName); + + StdClass->MetaSchema(theMetaSchema); + + if (!theMetaSchema->IsDefined(StdClass->FullName()) || Current_Entity == CDL_GENCLASS) { + if (Current_Entity == CDL_GENCLASS && theMetaSchema->IsDefined(StdClass->FullName())) { + theMetaSchema->RemoveType(StdClass->FullName(),Standard_False); + GenClass->NestedStdClass(StdClass->Name()); + StdClass->Mother(GenClass->FullName()); + } + else if (Current_Entity == CDL_GENCLASS) { + Handle(MS_Package) aPackage = theMetaSchema->GetPackage(aPackName); + + if (!aPackage->HasClass(aClassName)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class : " << StdClass->Name() << " is not declared in package " << aPackName << endm; + YY_nb_error++; + CDL_InitVariable(); + MS_TraductionError::Raise("Class not defined."); + } + GenClass->NestedStdClass(StdClass->Name()); + StdClass->Mother(GenClass->FullName()); + } + + if (Current_Entity == CDL_GENCLASS) { + StdClass->SetGenericState(Standard_True); + StdClass->NestingClass(GenClass->FullName()); + GenClass->AddNested(StdClass->Name()); + } + + StdClass->MetaSchema(theMetaSchema); + + StdClass->Private(Private); + StdClass->Deferred(Deferred); + StdClass->Incomplete(Standard_False); + + theMetaSchema->AddType(StdClass); + + StdClass->Package(aPackName); + } + else { + Handle(MS_Type) aType = theMetaSchema->GetType(StdClass->FullName()); + + StdClass = Handle(MS_StdClass)::DownCast(aType); + + if (StdClass.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The class " << aClassName << " was not declared..." << endm; + CDL_InitVariable(); + MS_TraductionError::Raise("Class not defined."); + } + + if (Private != StdClass->Private()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << StdClass->FullName() << " has not the same visibility keyword in package declaration and in class definition." << endm; + YY_nb_error++; + } + + if (Deferred != StdClass->Deferred()) { + if (Deferred) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << StdClass->FullName() << " is declared 'deferred' in class definition but not in package declaration." << endm; + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << StdClass->FullName() << " is declared 'deferred' in package declaration but not in class definition." << endm; + } + YY_nb_error++; + } + } + + if (Current_Entity != CDL_GENCLASS) { + Current_Entity = CDL_STDCLASS; + } + + SimpleClass = StdClass; + + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void Add_Std_Ancestors() +{ + Standard_Integer i; + Handle(TCollection_HAsciiString) aFullName; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + aFullName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + + if (theMetaSchema->IsDefined(aFullName)) { + Handle(MS_Class) aClass = Handle(MS_Class)::DownCast(theMetaSchema->GetType(aFullName)); + if (aClass.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class : " << aFullName << " must not be a normal class." << endm; + YY_nb_error++; + } + + if (i > 1) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << SimpleClass->FullName() << " uses multiple inheritance." << endm; + YY_nb_error++; + } + else if (!SimpleClass->FullName()->IsSameString(aClass->FullName())) { + SimpleClass->Inherit(aClass); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class " << SimpleClass->FullName() << " can not inherits from itself." << endm; + YY_nb_error++; + } + + SimpleClass->Use(ListOfTypes->Value(i),ListOfPackages->Value(i)); + + ListOfTypeUsed->Append(aFullName); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Class : " << aFullName << " not defined, can't be in inherits clause." << endm; + YY_nb_error++; + } + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void Add_Std_Uses() +{ + Standard_Integer i; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + Handle(TCollection_HAsciiString) aFullName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + + if (Current_Entity != CDL_GENCLASS && !theMetaSchema->IsDefined(aFullName)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The 'uses' statement of your class has a type : " << aFullName << " from a package not declared in the 'uses' statement of the package " << Container << endm; + YY_nb_error++; + } + else if (Current_Entity != CDL_GENCLASS) { + if (!SimpleClass->Package()->IsUsed(ListOfPackages->Value(i))) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The 'uses' statement of your class has a type : " << aFullName << " from a package not declared in the 'uses' statement of the package " << Container << endm; + YY_nb_error++; + } + } + + SimpleClass->Use(ListOfTypes->Value(i),ListOfPackages->Value(i)); + + ListOfTypeUsed->Append(aFullName); + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void StdClass_End() +{ + if (Current_Entity == CDL_GENCLASS) { + SimpleClass = GenClass; + } + + StdClass->Incomplete(Standard_False); + + StdClass.Nullify(); + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + + +void Add_Raises() +{ + Standard_Integer i; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + Handle(TCollection_HAsciiString) aFullName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + if (theMetaSchema->IsDefined(aFullName)) { + SimpleClass->Raises(ListOfTypes->Value(i),ListOfPackages->Value(i)); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "the exception " << "'" << aFullName << "'" << " is not defined." << endm; + YY_nb_error++; + } + } + + ListOfTypes->Clear(); + ListOfPackages->Clear(); +} + +void Add_Field() +{ + Standard_Integer i,j; + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + + for (i = 1; i <= ListOfName->Length(); i++) { + Field = new MS_Field(SimpleClass,ListOfName->Value(i)); + + Field->MetaSchema(theMetaSchema); + + for (j = 1; j <= ListOfInteger->Length(); j++) { + Field->Dimension(ListOfInteger->Value(j)->IntegerValue()); + } + + if (strcmp(Pack_Name,aDummyPackageName) == 0) { + aPackName->Clear(); + } + else { + VerifyClassUses(MS::BuildFullName(aPackName,aClassName)); + } + + Field->TYpe(aClassName,aPackName); + + + Field->Protected(Protected); + + SimpleClass->Field(Field); + } + + Private = Standard_False; + Protected = Standard_False; + ListOfInteger->Clear(); + ListOfName->Clear(); +} + +void Add_RedefField() +{ + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Fields redefinition no more supported..." << endm; + YY_nb_error++; +} + +void Add_FriendMet() +{ + Method->Params(MethodParams); + MethodParams.Nullify(); + Method->CreateFullName(); + SimpleClass->FriendMet(Method->FullName()); +} + +void Add_FriendExtMet(char *aPackName) +{ + Handle(TCollection_HAsciiString) apack = new TCollection_HAsciiString(aPackName); + + ExternMet->Package(apack); + Method->Params(MethodParams); + MethodParams.Nullify(); + Method->CreateFullName(); + SimpleClass->FriendMet(Method->FullName()); +} + +void Add_Friend_Class() +{ + Handle(TCollection_HAsciiString) aClassName = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + Handle(TCollection_HAsciiString) thetypename = MS::BuildFullName(aPackName,aClassName); + + if (theMetaSchema->IsDefined(thetypename)) { + SimpleClass->Friend(aClassName,aPackName); + ListOfTypeUsed->Append(thetypename); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "friend class " << thetypename->ToCString() << " is not defined." << endm; + YY_nb_error++; + } +} + +WOKTools_MapOfHAsciiString anEnumMap; + +// The actions for the Enumeration +// +void Enum_Begin() +{ + Handle(TCollection_HAsciiString) anEnumName = new TCollection_HAsciiString(thetypename); + + anEnumMap.Clear(); + + Enum = new MS_Enum(anEnumName,Container,Container,Private); + + Enum->MetaSchema(theMetaSchema); + Enum->Package(Package->FullName()); + + if (!theMetaSchema->AddType(Enum)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Enumeration : " << Enum->FullName() << " is already defined." << endm; + YY_nb_error++; + } +} + + +void Add_Enum(char *aValue) +{ + Handle(TCollection_HAsciiString) anEnumValue = new TCollection_HAsciiString(aValue); + + if (!anEnumMap.Contains(anEnumValue)) { + anEnumMap.Add(anEnumValue); + Enum->Enum(anEnumValue); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Enumeration value " << aValue << " in " << Enum->FullName() << " is already defined." << endm; + YY_nb_error++; + } +} + +void Enum_End() +{ + //Enum->Check(); + Package->Enum(Enum->Name()); + Enum.Nullify(); + anEnumMap.Clear(); + + Private = Standard_False; +} + +// The actions for the Methods +// +void get_cpp_commentalias(const Handle(TCollection_HAsciiString)& aComment) +{ + Handle(TCollection_HAsciiString) aToken1, + aToken2; + + aToken1 = aComment->Token(); + + aToken1->LeftAdjust(); + aToken1->RightAdjust(); + + aComment->Remove(1,aToken1->Length()); + aComment->LeftAdjust(); + aComment->RightAdjust(); +} + +void add_cpp_comment_to_method() +{ + if (Method.IsNull()) { + if (ListOfCplusplus->Length() > 0) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "C++ directive outside method definition." << endm; + YY_nb_error++; + } + } + else { + int aCommentType; + Standard_Integer i; + Handle(TCollection_HAsciiString) aCP; + + for(i = 1; i <= ListOfCplusplus->Length(); i++) { + aCommentType = ListOfCPPType->Value(i); + + switch (aCommentType) { + case CDL_HARDALIAS: + get_cpp_commentalias(ListOfCplusplus->Value(i)); + Method->Alias(ListOfCplusplus->Value(i)); + Method->SetAliasType(Standard_False); + break; + case CDL_OPERATOR: + get_cpp_commentalias(ListOfCplusplus->Value(i)); + Method->Alias(ListOfCplusplus->Value(i)); + Method->SetAliasType(Standard_True); + break; + case CDL_INLINE: + Method->Inline(Standard_True); + break; + case CDL_DESTRUCTOR: + if (Method->IsFunctionCall()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << methodlineno << ": " << "C++ directive 'alias ~' cannot be used with 'function call'." << endm; + YY_nb_error++; + } + Method->Destructor(Standard_True); + break; + case CDL_CONSTREF: + if (!Method->Returns().IsNull()) { + Method->ConstReturn(Standard_True); + Method->RefReturn(Standard_True); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << methodlineno << ": " << "C++ directive 'return const &' cannot be used without 'returns' clause." << endm; + YY_nb_error++; + } + break; + case CDL_REF: + if (!Method->Returns().IsNull()) { + Method->RefReturn(Standard_True); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << methodlineno << ": " << "C++ directive 'return &' cannot be used without 'returns' clause." << endm; + YY_nb_error++; + } + break; + case CDL_CONSTRET: + if (!Method->Returns().IsNull()) { + Method->ConstReturn(Standard_True); + } + else { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << methodlineno << ": " << "C++ directive 'return const' cannot be used without 'returns' clause." << endm; + YY_nb_error++; + } + break; + case CDL_FUNCTIONCALL: + if (Method->IsDestructor()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << methodlineno << ": " << "C++ directive 'function call' cannot be used with 'alias ~'." << endm; + YY_nb_error++; + } + Method->FunctionCall(Standard_True); + break; + default: + break; + } + } + ListOfCplusplus->Clear(); + ListOfCPPType->Clear(); + theMetaSchema->AddMethod(Method); + } +} + +void Construct_Begin() +{ + if (SimpleClass->Deferred()) { + if (!MethodName->IsSameString(DefCons)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "A deferred class must not have a constructor with name 'Create' or no 'me' or 'myclass' present for the method." << endm; + YY_nb_error++; + } + } + else { + if (!MethodName->IsSameString(NorCons)) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "A class must have a constructor with name 'Create' or no 'me' or 'myclass' present for the method." << endm; + YY_nb_error++; + } + } + + if (!Method.IsNull()) { + add_cpp_comment_to_method(); + } + methodlineno = CDLlineno; + Construc = new MS_Construc(MethodName,SimpleClass->FullName()); + Method = Construc; + MemberMet = Construc; + Method->MetaSchema(theMetaSchema); +} + +void Friend_Construct_Begin() +{ + Construc = new MS_Construc(MethodName,ListOfTypeUsed->Value(ListOfTypeUsed->Length())); + Method = Construc; + MemberMet = Construc; + Method->MetaSchema(theMetaSchema); +} + +void InstMet_Begin() +{ + if (!Method.IsNull()) { + add_cpp_comment_to_method(); + } + methodlineno = CDLlineno; + InstMet = new MS_InstMet(MethodName,SimpleClass->FullName()); + Method = InstMet; + Method->MetaSchema(theMetaSchema); + MemberMet = InstMet; +} + +void Friend_InstMet_Begin() +{ + InstMet = new MS_InstMet(MethodName,ListOfTypeUsed->Value(ListOfTypeUsed->Length())); + Method = InstMet; + MemberMet = InstMet; + Method->MetaSchema(theMetaSchema); +} + +void ClassMet_Begin() +{ + if (!Method.IsNull()) { + add_cpp_comment_to_method(); + } + methodlineno = CDLlineno; + ClassMet = new MS_ClassMet(MethodName,SimpleClass->FullName()); + Method = ClassMet; + Method->MetaSchema(theMetaSchema); + MemberMet = ClassMet; +} + +void Friend_ClassMet_Begin() +{ + ClassMet = new MS_ClassMet(MethodName,ListOfTypeUsed->Value(ListOfTypeUsed->Length())); + Method = ClassMet; + MemberMet = ClassMet; + Method->MetaSchema(theMetaSchema); +} + +void ExtMet_Begin() +{ + if (!Method.IsNull()) { + add_cpp_comment_to_method(); + } + methodlineno = CDLlineno; + ExternMet = new MS_ExternMet(MethodName,Package->Name()); + Method = ExternMet; + Method->MetaSchema(theMetaSchema); +} + +void Friend_ExtMet_Begin() +{ + ExternMet = new MS_ExternMet(MethodName); + Method = ExternMet; + Method->MetaSchema(theMetaSchema); +} + +void Add_Me() +{ + if (Mutable == MS_MUTABLE) { + InstMet->ConstMode(MSINSTMET_MUTABLE); + } + else if (InOrOut == MS_INOUT || InOrOut == MS_OUT) { + InstMet->ConstMode(MSINSTMET_OUT); + } + else { + InstMet->Const(Standard_True); + } + + Mutable = 0; + InOrOut = MS_IN; +} + +void Add_MetRaises() +{ + Standard_Integer i,j; + Handle(TCollection_HAsciiString) aName; + + for (i = 1; i <= ListOfTypes->Length(); i++) { + aName = MS::BuildFullName(ListOfPackages->Value(i),ListOfTypes->Value(i)); + if (theMetaSchema->IsDefined(aName)) { + if (Current_Entity == CDL_STDCLASS || Current_Entity == CDL_GENCLASS) { + Handle(TColStd_HSequenceOfHAsciiString) seq = SimpleClass->GetRaises(); + Standard_Boolean isFound = Standard_False; + + for (j = 1; j <= seq->Length() && !isFound; j++) { + if (seq->Value(j)->IsSameString(aName)) { + isFound = Standard_True; + } + } + + if (!isFound) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "the exception " << "'" << aName << "'" << " is not declared in 'raises' clause of the class: " << SimpleClass->FullName() << endm; + YY_nb_error++; + } + else { + Method->Raises(aName); + } + } + else { + Method->Raises(aName); + } + } + else { + // si on est dans les methodes de package on ne verifie pas les raises + // + if (ExternMet.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "the exception " << "'" << aName << "'" << " is not defined." << endm; + YY_nb_error++; + } + else { + Method->Raises(aName); + } + } + } + + ListOfPackages->Clear(); + ListOfTypes->Clear(); +} + +void Add_Returns() +{ + Handle(TCollection_HAsciiString) athetypename = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + Handle(MS_Param) aParam; + Standard_Boolean isGenType = Standard_False; + + aParam = new MS_Param(Method,athetypename); + + aParam->Like(Like); + aParam->AccessMode(Mutable); + aParam->AccessMode(InOrOut); + aParam->MetaSchema(theMetaSchema); + + if (strcmp(Pack_Name,aDummyPackageName) == 0) { + aPackName->Clear(); + isGenType = Standard_True; + } + else { + VerifyClassUses(MS::BuildFullName(aPackName,athetypename)); + } + + + aParam->Type(athetypename,aPackName); + + if (!Construc.IsNull()) { + if (!aParam->TypeName()->IsSameString(Construc->Class())) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "The constructor must return " << Construc->Class() << " not " << aParam->TypeName() << endm; + YY_nb_error++; + } + } + + Method->Returns(aParam); + + Mutable = 0; + InOrOut = MS_IN; + Like = Standard_False; + + ListOfName->Clear(); +} + +void MemberMet_End() +{ + SimpleClass->Method(MemberMet); + Method->Params(MethodParams); + MethodParams.Nullify(); + MemberMet->CreateFullName(); + MemberMet->Private(Private); + MemberMet->Protected(Protected); + + if (!InstMet.IsNull()) { + InstMet->Deferred(Deferred); + InstMet->Redefined(Redefined); + InstMet->Static(Static); + } + + MemberMet.Nullify(); + InstMet.Nullify(); + Construc.Nullify(); + ClassMet.Nullify(); + + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +void ExternMet_End() +{ + Package->Method(ExternMet); + Method->Params(MethodParams); + MethodParams.Nullify(); + ExternMet->CreateFullName(); + ExternMet->Private(Private); + ExternMet.Nullify(); + Private = Standard_False; + Protected = Standard_False; + Static = Standard_True; + Deferred = Standard_False; + Redefined = Standard_False; + Like = Standard_False; +} + +// The actions for Parameters +// +void Param_Begin() +{ + Standard_Integer i; + Handle(MS_Param) aParam; + Handle(TCollection_HAsciiString) athetypename = new TCollection_HAsciiString(thetypename); + Handle(TCollection_HAsciiString) aPackName = new TCollection_HAsciiString(Pack_Name); + Standard_Boolean isGenType = Standard_False; + + for (i = 1; i <= ListOfName->Length(); i++) { + if (ParamValue.IsNull()) { + aParam = new MS_Param(Method,ListOfName->Value(i)); + } + else { + aParam = new MS_ParamWithValue(Method,ListOfName->Value(i)); + } + + aParam->AccessMode(Mutable); + aParam->AccessMode(InOrOut); + aParam->MetaSchema(theMetaSchema); + + if (strcmp(Pack_Name,aDummyPackageName) == 0) { + aPackName->Clear(); + isGenType = Standard_True; + } + else { + VerifyClassUses(MS::BuildFullName(aPackName,athetypename)); + } + + aParam->Like(Like); + aParam->Type(athetypename,aPackName); + + if (!ParamValue.IsNull()) { + MS_TypeOfValue pt; + MS_ParamWithValue *pwv; + + switch (ParamType) { + case INTEGER: pt = MS_INTEGER; + break; + case REAL: pt = MS_REAL; + break; + case STRING: pt = MS_STRING; + break; + case LITERAL: pt = MS_CHAR; + break; + case IDENTIFIER: pt = MS_ENUM; + break; + default: ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "Type of default value unknown." << endm; + YY_nb_error++; + break; + } + + pwv = (MS_ParamWithValue *)aParam.operator->(); + pwv->Value(ParamValue,pt); + } + + //Method->Param(aParam); + if(MethodParams.IsNull()) MethodParams = new MS_HSequenceOfParam; + MethodParams->Append(aParam); + } + + ParamValue.Nullify(); + Mutable = 0; + InOrOut = MS_IN; + Like = Standard_False; + + ListOfName->Clear(); +} + +void Add_Value(char *str,int type) +{ + ParamValue = new TCollection_HAsciiString(str); + ParamType = type; +} + + +// The general actions +// +void End() +{ + +} + +void Set_In() +{ + InOrOut = MS_IN; +} + +void Set_Out() +{ + InOrOut = MS_OUT; +} + +void Set_InOut() +{ + InOrOut = MS_INOUT; +} + +void Set_Mutable() +{ + Mutable = MS_MUTABLE; +} + +void Set_Mutable_Any() +{ + Mutable = MS_ANY; +} + +void Set_Immutable() +{ + Mutable = MS_IMMUTABLE; +} + +void Set_Priv() +{ + Private = Standard_True; +} + +void Set_Defe() +{ + Deferred = Standard_True; +} + +void Set_Redefined() +{ + if (!Construc.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "A constructor cannot be redefined." << endm; + YY_nb_error++; + } + if (!ClassMet.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "A class method cannot be redefined." << endm; + YY_nb_error++; + } + Redefined = Standard_True; + Static = Standard_False; +} + +void Set_Prot() +{ + Protected = Standard_True; + Private = Standard_False; +} + +void Set_Static() +{ + Static = Standard_True; +} + +void Set_Virtual() +{ + if (!ClassMet.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "A class method cannot be redefined, so the 'virtual' keyword cannot be applied to " << ClassMet->Name() << endm; + YY_nb_error++; + } + if (!Construc.IsNull()) { + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": " << "A constructor cannot be redefined, so the 'virtual' keyword cannot be applied to it." << endm; + YY_nb_error++; + } + Static = Standard_False; +} + +void Set_Method(char *name) +{ + MethodName = new TCollection_HAsciiString(name); +} + +void Set_Like_Me() +{ + Like = Standard_True; + + strncpy(thetypename,SimpleClass->Name()->ToCString(),MAX_CHAR); + strncpy(Pack_Name,Container->ToCString(),MAX_CHAR); +} + +void Set_Like_Type() +{ + ErrorMsg << "CDL" << "\"" << CDLFileName->ToCString() << "\"" << ", line " << CDLlineno << ": Obsolete syntaxe : like " << endm; + YY_nb_error++; +} + +void Set_Item(char *Item) +{ + Handle(TCollection_HAsciiString) anItem = new TCollection_HAsciiString(Item); + + ListOfItem->Append(anItem); +} + +void Set_Any() +{ + Any = Standard_True; +} + + +extern "C" CDLparse(); + + +void CDL_Main() +{ + YY_nb_error = 0; + CDLparse(); +} + +extern "C" { +void CDLrestart(FILE*); +} +#ifndef WNT +extern FILE *CDLin; +#else +extern "C" FILE *CDLin; +#endif // WNT + +int TraductionMain(char *FileName) +{ + + CDLin = fopen(FileName,"r"); + + + + if (CDLin == NULL) { + CDL_InitVariable(); + ErrorMsg << "CDL" << " File not found : " << FileName << endm; + MS_TraductionError::Raise("File not found."); + } + + CDLrestart(CDLin); + // Boot file + // + CDL_Main(); + + fclose(CDLin); + + if (YY_nb_error > 0) { + ErrorMsg << "CDL" << YY_nb_error << " errors." << endm; + } + + if (YY_nb_warning > 0) { + WarningMsg << "CDL" << YY_nb_warning << " warnings." << endm; + } + + return YY_nb_error; +} + + + +int CDLTranslate(const Handle(MS_MetaSchema)& aMetaSchema, + const Handle(TCollection_HAsciiString)& aFileName, + const Handle(TColStd_HSequenceOfHAsciiString)& aGlobalList, + const Handle(TColStd_HSequenceOfHAsciiString)& aTypeList, + const Handle(TColStd_HSequenceOfHAsciiString)& anInstList, + const Handle(TColStd_HSequenceOfHAsciiString)& anGenList) +{ + Standard_Integer ErrorLevel = 0; + + CDL_InitVariable(); + + theMetaSchema = aMetaSchema; + ListOfGlobalUsed = aGlobalList; + ListOfTypeUsed = aTypeList; + ListOfInst = anInstList; + ListOfGen = anGenList; + + if (!aFileName.IsNull()) { + CDLlineno = 1; + CDLFileName = aFileName; + + try { + ErrorLevel = TraductionMain(aFileName->ToCString()); + } + catch(Standard_Failure) { + fclose(CDLin); + ErrorLevel = 1; + } + } + else { + ErrorLevel = 1; + } + + theMetaSchema.Nullify(); + ListOfGlobalUsed.Nullify(); + ListOfTypeUsed.Nullify(); + ListOfInst.Nullify(); + ListOfGen.Nullify(); + + return ErrorLevel; +} + + diff --git a/src/CDLFront/CDLFront.hxx b/src/CDLFront/CDLFront.hxx new file mode 100755 index 0000000..83541df --- /dev/null +++ b/src/CDLFront/CDLFront.hxx @@ -0,0 +1,21 @@ +#ifndef CDLFront_HeaderFile +#define CDLFront_HeaderFile + +#include +#include + +#ifndef _Standard_Macro_HeaderFile +# include +#endif + +extern "C" { + +int Standard_EXPORT CDLTranslate(const Handle(MS_MetaSchema)& aMetaSchema, + const Handle(TCollection_HAsciiString)& aFileName, + const Handle(TColStd_HSequenceOfHAsciiString)& aGlobalList, + const Handle(TColStd_HSequenceOfHAsciiString)& aTypeList, + const Handle(TColStd_HSequenceOfHAsciiString)& anInstList, + const Handle(TColStd_HSequenceOfHAsciiString)& anGenList); +} + +#endif diff --git a/src/CDLFront/CDLFront_CMPLRS.edl b/src/CDLFront/CDLFront_CMPLRS.edl new file mode 100755 index 0000000..d531d56 --- /dev/null +++ b/src/CDLFront/CDLFront_CMPLRS.edl @@ -0,0 +1,14 @@ +-- File: CDLFront_CMPLRS.edl +-- Author: Prestataire Pascal BABIN +-- History: Tue Jan 21 16:18:59 1997 Prestataire Pascal BABIN Creation +-- Copyright: Matra Datavision 1997 + +@ifnotdefined ( %CDLFront_CMPLRS_EDL) then +@set %CDLFront_CMPLRS_EDL = ""; + +@if ( %Station == "hp" ) then + @string %CMPLRS_C_Options += " -Ae"; +@endif; + + +@endif; diff --git a/src/CDLFront/FILES b/src/CDLFront/FILES new file mode 100755 index 0000000..907d696 --- /dev/null +++ b/src/CDLFront/FILES @@ -0,0 +1,8 @@ +CDLFront_CMPLRS.edl +CDLFront.cxx +CDL.lex +CDL.yacc +cdl_defines.hxx +cdl_rules.h +CDLFront.hxx + diff --git a/src/CDLFront/cdl_defines.hxx b/src/CDLFront/cdl_defines.hxx new file mode 100755 index 0000000..07a0c59 --- /dev/null +++ b/src/CDLFront/cdl_defines.hxx @@ -0,0 +1,13 @@ +#define MAX_CHAR 256 /* The limit of a identifier. */ +#define MAX_STRING (MAX_CHAR * 10) /* The limit of a string. */ +#define MAX_COMMENT (MAX_CHAR * 300) /* The limit of comment line */ +#define ENDOFCOMMENT "\n%\n" /* The marque of end of coment */ + +#define CDL_OPERATOR 1 +#define CDL_INLINE 2 +#define CDL_DESTRUCTOR 3 +#define CDL_CONSTREF 4 +#define CDL_CONSTRET 5 +#define CDL_REF 6 +#define CDL_HARDALIAS 7 +#define CDL_FUNCTIONCALL 8 diff --git a/src/CDLFront/cdl_rules.h b/src/CDLFront/cdl_rules.h new file mode 100755 index 0000000..f210a23 --- /dev/null +++ b/src/CDLFront/cdl_rules.h @@ -0,0 +1,153 @@ +/*============================================================================ +//== File: cdl_rules.h Version 1.2 +//== +//== SCCS Date: 17/11/93 +//===========================================================================*/ + +void Clear_ListOfItem(); +void Type_Name(char*); +void Type_Pack(char*); +void Type_Pack_Blanc(); +void Add_Type(); +void add_name_to_list(char*); +void Begin_List_Ident(); +void Make_List_Ident(); +void Begin_List_Int(char*); +void Make_List_Int(char*); +void set_inc_state(); +void restore_state(); +void add_cpp_comment(int,char*); + +/*=-=-=-=-=-=-=-=-= The actions for the Package =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Pack_Begin(char*); +void Pack_Use(char*); +void Pack_End(); +/*=-=-=-=-=-=-=-=-= The actions for the Schema =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Schema_Begin(char*); +void Schema_Package(char*); +void Schema_Class(); +void Schema_End(); +/*=-=-=-=-=-=-=-=-= The actions for the Interface =-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Interface_Begin(char*); +void Interface_Name_Check(); +void Interface_Use(char*); +void Interface_Package(char*); +void Interface_Class(); +void Interface_Method(char*); +void Interface_End(); +/*=-=-=-=-=-=-=-=-= The actions for the Engine =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Engine_Begin(char *); +void Engine_Name_Check(); +void Engine_Schema(char*); +void Engine_Interface(char*); +void Engine_End(); +/*=-=-=-=-=-=-=-=-= The actions for the Component =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Component_Begin(char *); +void Component_Name_Check(); +void Component_Interface(char*,char*); +void Component_End(); +/*=-=-=-=-=-=-=-=-= The actions for the ExecFile =-=-=-=-=-=-=-=-=-=-=-=*/ +void Executable_Begin(char*); +void ExecFile_Begin(char*); +void ExecFile_Schema(char*); +void ExecFile_AddUse(char*); +void ExecFile_SetUseType(int); +void ExecFile_AddComponent(char*); +void ExecFile_SetLang(int); +void ExecFile_End(); +void Executable_End(); +/*=-=-=-=-=-=-=-=-= The actions for the classes =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Alias_Begin(); +void Alias_Type(); +void Alias_End(); +/*--------------------------------------------------------------------------*/ +void Pointer_Begin(); +void Pointer_Type(); +void Pointer_End(); +/*--------------------------------------------------------------------------*/ +void Imported_Begin(); +void Imported_End(); +/*--------------------------------------------------------------------------*/ +void Prim_Begin(); +void Prim_End(); +/*--------------------------------------------------------------------------*/ +void Except_Begin(); +void Except_End(); +/*--------------------------------------------------------------------------*/ +void Enum_Begin(); +void Add_Enum(char*); +void Enum_Name_Check(); +void Enum_End(); +/*--------------------------------------------------------------------------*/ +void Inc_Class_Dec(); +void Inc_GenClass_Dec(); +/*--------------------------------------------------------------------------*/ +void GenClass_Begin(); +void Add_GenType(); +void Add_DynaGenType(); +void Add_Embeded(); +void GenClass_End(); +/*--------------------------------------------------------------------------*/ +void InstClass_Begin(); +void Add_Gen_Class(); +void Add_InstType(); +void InstClass_End(); +void DynaType_Begin(); +/*--------------------------------------------------------------------------*/ +void StdClass_Begin(); +void Add_Std_Ancestors(); +void Add_Std_Uses(); +void StdClass_End(); +/*--------------------------------------------------------------------------*/ +void Add_Inherits(); +void Add_Uses(); +void Add_Raises(); +void Add_Field(); +void Add_RedefField(); +void Add_FriendMet(); +void Add_FriendExtMet(char*); +void Add_Friend_Class(); +/*=-=-=-=-=-=-=-=-= The actions for the Methods =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void add_cpp_comment_to_method(); +void Construct_Begin(); +void InstMet_Begin(); +void ClassMet_Begin(); +void ExtMet_Begin(); +void Method_TypeName(); +void Friend_Construct_Begin(); +void Friend_InstMet_Begin(); +void Friend_ClassMet_Begin(); +void Friend_ExtMet_Begin(); +void Add_Me(); +void Add_MetRaises(); +void Add_Returns(); +void MemberMet_End(); +void ExternMet_End(); +/*=-=-=-=-=-=-=-=-= The actions for Parameteres =-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void Param_Begin(); +void Add_Value(char*,int); +/*=-=-=-=-=-=-=-=-= The general actions =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ +void End(); +void Set_In(); +void Set_Out(); +void Set_InOut(); +void Set_Mutable(); +void Set_Mutable_Any(); +void Set_Immutable(); +void Set_Priv(); +void Set_Defe(); +void Set_Redefined(); +void Set_Prot(); +void Set_Static(); +void Set_Virtual(); +void Set_Method(char*); +void Set_Like_Me(); +void Set_Like_Type(); +void Set_Item(char *); +void Set_Any(); +void CDL_MustCheckUses(); +void CDL_MustNotCheckUses(); +void Client_Begin(char *); +void Client_Interface(char*); +void Client_Method(char*,int); +void Client_End(); -- 2.39.5