61 string error =
"Parse error." ;
64 for(
int w = 0; w < _counter+1; w++ )
65 where += tokens[w] +
" " ;
66 where +=
"<----HERE IS THE ERROR" ;
67 error +=
"\n" + where ;
85 return tokens[_counter] ;
99 if( _counter == -1 ) {
103 if( _counter > _number_tokens-1 ) {
107 return tokens[_counter] ;
121 if( _counter == -1 ) {
125 if( _counter >= _number_tokens-1 ) {
129 return tokens[++_counter] ;
160 size_t len = strlen( p ) ;
162 bool passing_raw = false ;
163 bool escaped = false ;
167 for(
unsigned int j = 0; j < len; j++ ) {
170 if( !escaped && p[j] ==
'\"') {
175 tokens.push_back( s ) ;
178 tokens.push_back( s ) ;
184 passing_raw =! passing_raw ;
186 }
else if( passing_raw ) {
188 if(!escaped && p[j] ==
'\\' ){
198 if( ( p[j] ==
' ' ) ||
203 tokens.push_back( s ) ;
206 }
else if( ( p[j] ==
',' ) || ( p[j] ==
';' ) ) {
208 tokens.push_back( s ) ;
213 tokens.push_back(
"," ) ;
216 tokens.push_back(
";" ) ;
226 tokens.push_back( s ) ;
227 _number_tokens = tokens.size() ;
230 if( _number_tokens < 1 )
231 parse_error(
"Unknown command: '" + (
string)p + (
string)
"'") ;
232 if( tokens[_number_tokens - 1] !=
";" )
233 parse_error(
"The request must be terminated by a semicolon (;)" ) ;
258 string::size_type where = s.rfind(
".constraint=", s.size() ) ;
259 if( where == string::npos ) {
260 where = s.rfind(
".attributes=", s.size() ) ;
261 if( where == string::npos ) {
269 string valid = s.substr( where, s.size() ) ;
270 if( (valid !=
".constraint=") && (valid !=
".attributes=") ) {
271 string err = (string)
"Invalid container property " 274 + s.substr( 0, where )
275 +
". constraint expressions and attribute lists " 276 +
"must be wrapped in quotes" ;
279 return s.substr( 0, where ) ;
295 if( (s[0] !=
'"' ) || (s[s.size() - 1] !=
'"' ) ) {
296 parse_error(
"item " + s +
" must be enclosed by quotes" ) ;
298 return s.substr( 1, s.size() - 2 ) ;
311 tokens_citerator i = tokens.begin() ;
312 tokens_citerator ie = tokens.end() ;
313 for( ; i != ie; i++ ) {
314 cout <<
"\"" << (*i) <<
"\"" << endl ;
327 << (
void *)
this <<
")" << endl ;
329 tokens_citerator i = tokens.begin() ;
330 tokens_citerator ie = tokens.end() ;
331 for( ; i != ie; i++ ) {
string & get_next_token()
returns the next token from the token list
error thrown if there is a user syntax error in the request or any other user error ...
string & get_first_token()
returns the first token from the token list
string remove_quotes(const string &s)
removes quotes from a quoted token
static ostream & LMarg(ostream &strm)
virtual void dump(ostream &strm) const
dumps information about this object
string parse_container_name(const string &s, unsigned int &type)
parses a container name for constraint and attributes
void parse_error(const string &s="")
throws an exception giving the tokens up to the point of the problem
void tokenize(const char *p)
tokenize the BES request/command string
string & get_current_token()
returns the current token from the token list
void dump_tokens()
dump the tokens that have been tokenized in the order in which they are parsed.