00001 // -*- C++ -*- 00002 // PSDL_Interpreter.cpp,v 1.1 2002/07/25 15:25:51 pgontla Exp 00003 00004 #include "PSDL_Interpreter.h" 00005 #include "PSDL_Node.h" 00006 #include "PSDL_y.h" 00007 00008 ACE_RCSID(PSDL, PSDL_Interpreter, "PSDL_Interpreter.cpp,v 1.1 2002/07/25 15:25:51 pgontla Exp") 00009 00010 TAO_SYNCH_MUTEX TAO_PSDL_Interpreter::parserMutex__; 00011 00012 TAO_PSDL_Interpreter::TAO_PSDL_Interpreter (void) 00013 : root_ (0) 00014 { 00015 } 00016 00017 TAO_PSDL_Interpreter::~TAO_PSDL_Interpreter (void) 00018 { 00019 delete this->root_; 00020 } 00021 00022 int 00023 TAO_PSDL_Interpreter::build_tree (const char* nodes) 00024 { 00025 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, 00026 guard, 00027 TAO_PSDL_Interpreter::parserMutex__, 00028 -1); 00029 00030 TAO_Lex_String_Input::reset ((char*)nodes); 00031 00032 yyval = 0; 00033 void *result_ptr = 0; 00034 int return_value = TAO_PSDL_yyparse (result_ptr); 00035 00036 if (return_value == 0 && yyval != 0) 00037 { 00038 this->root_ = yyval; 00039 } 00040 else 00041 { 00042 this->root_ = 0; 00043 } 00044 00045 return return_value; 00046 } 00047 00048 int 00049 TAO_PSDL_Interpreter::is_empty_string (const char* str) 00050 { 00051 int return_value = 0; 00052 00053 if (str != 0) 00054 { 00055 int i = 0; 00056 00057 while (str[i] != '\0') 00058 { 00059 if (str[i] != ' ') 00060 { 00061 break; 00062 } 00063 00064 i++; 00065 } 00066 00067 if (str[i] == '\0') 00068 { 00069 return_value = 1; 00070 } 00071 } 00072 00073 return return_value; 00074 } 00075 00076 char* TAO_Lex_String_Input::string_ = 0; 00077 char* TAO_Lex_String_Input::current_ = 0; 00078 char* TAO_Lex_String_Input::end_ = 0; 00079 00080 // Routine to have Lex read its input from the node string. 00081 00082 int 00083 TAO_Lex_String_Input::copy_into (char* buf, 00084 int max_size) 00085 { 00086 int chars_left = TAO_Lex_String_Input::end_ - TAO_Lex_String_Input::current_; 00087 int n = max_size > chars_left ? chars_left : max_size; 00088 00089 if (n > 0) 00090 { 00091 ACE_OS:: memcpy (buf, 00092 TAO_Lex_String_Input::current_, 00093 n); 00094 TAO_Lex_String_Input::current_ += n; 00095 } 00096 00097 return n; 00098 } 00099 00100 void 00101 TAO_Lex_String_Input::reset (char* input_string) 00102 { 00103 TAO_Lex_String_Input::string_ = input_string; 00104 TAO_Lex_String_Input::current_ = input_string; 00105 TAO_Lex_String_Input::end_ = 00106 input_string + ACE_OS::strlen (TAO_Lex_String_Input::string_); 00107 }