From cd0cf1fcd82c2bf028edaa7c9b5390909de4ee10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20S=2E=20Montero?= Date: Fri, 6 Mar 2009 12:07:32 +0000 Subject: [PATCH] Parsers generated with latest version of bison/flex git-svn-id: http://svn.opennebula.org/one/trunk@384 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- src/host/Host.cc | 2 +- src/host/host_parser.c | 53 +++++++++++++++++++-------- src/host/host_parser.h | 43 ++++++++++++++++------ src/template/Template.cc | 66 ++++++++++++++++++++++------------ src/template/template_parser.c | 53 +++++++++++++++++++-------- src/template/template_parser.h | 43 ++++++++++++++++------ 6 files changed, 187 insertions(+), 73 deletions(-) diff --git a/src/host/Host.cc b/src/host/Host.cc index c64af5ad09..3c948af1d2 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -320,7 +320,7 @@ extern "C" int host_rank_parse(Host * host, int& result, char ** errmsg); - void host_lex_destroy(); + int host_lex_destroy(); YY_BUFFER_STATE host__scan_string(const char * str); diff --git a/src/host/host_parser.c b/src/host/host_parser.c index 87d717c2f9..3c7cd788a7 100644 --- a/src/host/host_parser.c +++ b/src/host/host_parser.c @@ -28,7 +28,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -73,7 +73,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -104,6 +103,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -211,13 +212,6 @@ extern FILE *host_in, *host_out; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -498,7 +492,7 @@ int host__flex_debug = 0; char *host_text; #line 1 "host_parser.l" /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2008, Distributed Systems Architecture Group, Universidad */ +/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */ /* Complutense de Madrid (dsa-research.org) */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); you may */ @@ -527,7 +521,7 @@ char *host_text; #define YY_USER_ACTION llocp->first_line = host_lineno; \ llocp->first_column = llocp->last_column; \ llocp->last_column += host_leng; -#line 531 "host_parser.c" +#line 525 "host_parser.c" #define INITIAL 0 @@ -545,6 +539,35 @@ char *host_text; static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int host_lex_destroy (void ); + +int host_get_debug (void ); + +void host_set_debug (int debug_flag ); + +YY_EXTRA_TYPE host_get_extra (void ); + +void host_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *host_get_in (void ); + +void host_set_in (FILE * in_str ); + +FILE *host_get_out (void ); + +void host_set_out (FILE * out_str ); + +int host_get_leng (void ); + +char *host_get_text (void ); + +int host_get_lineno (void ); + +void host_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -585,7 +608,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( host_text, host_leng, 1, host_out ) +#define ECHO do { if (fwrite( host_text, host_leng, 1, host_out )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -596,7 +619,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( host_in )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -682,7 +705,7 @@ YY_DECL /* --- Tokens --- */ -#line 686 "host_parser.c" +#line 709 "host_parser.c" if ( !(yy_init) ) { @@ -819,7 +842,7 @@ YY_RULE_SETUP #line 64 "host_parser.l" ECHO; YY_BREAK -#line 823 "host_parser.c" +#line 846 "host_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); diff --git a/src/host/host_parser.h b/src/host/host_parser.h index 50b9b8a8ef..ba83d7fa1e 100644 --- a/src/host/host_parser.h +++ b/src/host/host_parser.h @@ -13,7 +13,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -58,7 +58,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -89,6 +88,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -126,13 +127,6 @@ extern int host_leng; extern FILE *host_in, *host_out; -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -229,6 +223,35 @@ extern char *host_text; #define YY_EXTRA_TYPE void * #endif +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int host_lex_destroy (void ); + +int host_get_debug (void ); + +void host_set_debug (int debug_flag ); + +YY_EXTRA_TYPE host_get_extra (void ); + +void host_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *host_get_in (void ); + +void host_set_in (FILE * in_str ); + +FILE *host_get_out (void ); + +void host_set_out (FILE * out_str ); + +int host_get_leng (void ); + +char *host_get_text (void ); + +int host_get_lineno (void ); + +void host_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -291,6 +314,6 @@ extern int host_lex (void); #line 64 "host_parser.l" -#line 295 "host_parser.h" +#line 318 "host_parser.h" #undef host_IN_HEADER #endif /* host_HEADER_H */ diff --git a/src/template/Template.cc b/src/template/Template.cc index b958ceebd8..bb43476d63 100644 --- a/src/template/Template.cc +++ b/src/template/Template.cc @@ -19,7 +19,7 @@ #include "Template.h" #include "template_syntax.h" -extern "C" +extern "C" { #include "template_parser.h" } @@ -46,7 +46,7 @@ extern "C" { int template_parse(Template * tmpl, char ** errmsg); - void template_lex_destroy(); + int template_lex_destroy(); YY_BUFFER_STATE template__scan_string(const char * str); @@ -97,7 +97,7 @@ int Template::parse(const string &parse_str, char **error_msg) YY_BUFFER_STATE str_buffer; const char * str; int rc; - + pthread_mutex_lock(&mutex); *error_msg = 0; @@ -137,7 +137,7 @@ void Template::marshall(string &str, const char delim) { multimap::iterator it; string * attr; - + for(it=attributes.begin(),str="";it!=attributes.end();it++) { attr = it->second->marshall(); @@ -148,7 +148,7 @@ void Template::marshall(string &str, const char delim) } str += it->first + "=" + *attr + delim; - + delete attr; } } @@ -156,13 +156,35 @@ void Template::marshall(string &str, const char delim) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ +int Template::remove(const string& name, vector& values) +{ + multimap::iterator i; + pair::iterator, + multimap::iterator> index; + int j; + + index = attributes.equal_range(name); + + for ( i = index.first,j=0 ; i != index.second ; i++,j++ ) + { + values.push_back(i->second); + } + + attributes.erase(index.first,index.second); + + return j; +} + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + int Template::get( - const string& name, + const string& name, vector& values) const { multimap::const_iterator i; pair::const_iterator, - multimap::const_iterator> index; + multimap::const_iterator> index; int j; index = attributes.equal_range(name); @@ -179,18 +201,18 @@ int Template::get( /* -------------------------------------------------------------------------- */ int Template::get( - const string& name, + const string& name, vector& values) { multimap::iterator i; pair::iterator, - multimap::iterator> index; + multimap::iterator> index; int j; index = attributes.equal_range(name); for ( i = index.first,j=0 ; i != index.second ; i++,j++ ) - { + { values.push_back(i->second); } @@ -217,18 +239,18 @@ void Template::get( value = ""; return; } - + sattr = dynamic_cast(attrs[0]); if ( sattr != 0 ) { - value = sattr->value(); + value = sattr->value(); } else { value=""; - } -} + } +} /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -249,8 +271,8 @@ void Template::get( istringstream iss(sval); - iss >> value; -} + iss >> value; +} /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -260,9 +282,9 @@ void Template::to_xml(string& xml) const multimap::const_iterator it; ostringstream oss; string * s; - + oss << "<" << xml_root << ">"; - + for ( it = attributes.begin(); it!=attributes.end(); it++) { s = it->second->to_xml(); @@ -271,9 +293,9 @@ void Template::to_xml(string& xml) const delete s; } - + oss << ""; - + xml = oss.str(); } @@ -284,7 +306,7 @@ ostream& operator << (ostream& os, Template& t) { multimap::iterator it; string * s; - + for ( it = t.attributes.begin(); it!=t.attributes.end(); it++) { s = it->second->marshall(","); @@ -293,7 +315,7 @@ ostream& operator << (ostream& os, Template& t) delete s; } - + return os; } diff --git a/src/template/template_parser.c b/src/template/template_parser.c index 87c6a8348e..56db87201e 100644 --- a/src/template/template_parser.c +++ b/src/template/template_parser.c @@ -28,7 +28,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -73,7 +73,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -104,6 +103,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -211,13 +212,6 @@ extern FILE *template_in, *template_out; #define unput(c) yyunput( c, (yytext_ptr) ) -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -516,7 +510,7 @@ int template__flex_debug = 0; char *template_text; #line 1 "template_parser.l" /* -------------------------------------------------------------------------- */ -/* Copyright 2002-2008, Distributed Systems Architecture Group, Universidad */ +/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */ /* Complutense de Madrid (dsa-research.org) */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); you may */ @@ -544,7 +538,7 @@ char *template_text; #define YY_USER_ACTION llocp->first_line = template_lineno; \ llocp->first_column = llocp->last_column; \ llocp->last_column += template_leng; -#line 548 "template_parser.c" +#line 542 "template_parser.c" #define INITIAL 0 @@ -562,6 +556,35 @@ char *template_text; static int yy_init_globals (void ); +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int template_lex_destroy (void ); + +int template_get_debug (void ); + +void template_set_debug (int debug_flag ); + +YY_EXTRA_TYPE template_get_extra (void ); + +void template_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *template_get_in (void ); + +void template_set_in (FILE * in_str ); + +FILE *template_get_out (void ); + +void template_set_out (FILE * out_str ); + +int template_get_leng (void ); + +char *template_get_text (void ); + +int template_get_lineno (void ); + +void template_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -602,7 +625,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( template_text, template_leng, 1, template_out ) +#define ECHO do { if (fwrite( template_text, template_leng, 1, template_out )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -613,7 +636,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( template_in )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -702,7 +725,7 @@ YY_DECL /* --- Comments and blanks --- */ -#line 706 "template_parser.c" +#line 729 "template_parser.c" if ( !(yy_init) ) { @@ -869,7 +892,7 @@ YY_RULE_SETUP #line 66 "template_parser.l" ECHO; YY_BREAK -#line 873 "template_parser.c" +#line 896 "template_parser.c" case YY_STATE_EOF(INITIAL): yyterminate(); diff --git a/src/template/template_parser.h b/src/template/template_parser.h index 3eb9bfd81f..a5f239b88e 100644 --- a/src/template/template_parser.h +++ b/src/template/template_parser.h @@ -13,7 +13,7 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 34 +#define YY_FLEX_SUBMINOR_VERSION 35 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif @@ -58,7 +58,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -89,6 +88,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -126,13 +127,6 @@ extern int template_leng; extern FILE *template_in, *template_out; -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - * Given that the standard has decreed that size_t exists since 1989, - * I guess we can afford to depend on it. Manoj. - */ - #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef size_t yy_size_t; @@ -229,6 +223,35 @@ extern char *template_text; #define YY_EXTRA_TYPE void * #endif +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int template_lex_destroy (void ); + +int template_get_debug (void ); + +void template_set_debug (int debug_flag ); + +YY_EXTRA_TYPE template_get_extra (void ); + +void template_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *template_get_in (void ); + +void template_set_in (FILE * in_str ); + +FILE *template_get_out (void ); + +void template_set_out (FILE * out_str ); + +int template_get_leng (void ); + +char *template_get_text (void ); + +int template_get_lineno (void ); + +void template_set_lineno (int line_number ); + /* Macros after this point can all be overridden by user definitions in * section 1. */ @@ -291,6 +314,6 @@ extern int template_lex (void); #line 66 "template_parser.l" -#line 295 "template_parser.h" +#line 318 "template_parser.h" #undef template_IN_HEADER #endif /* template_HEADER_H */