~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/execute/parser.yy

  • Committer: Olaf van der Spek
  • Date: 2011-10-06 18:18:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2433.
  • Revision ID: olafvdspek@gmail.com-20111006181831-1ix5b80ry7iifbjf
Use lex_string assign(), data() and size()

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2
 
 * 
 
2
 *
3
3
 *  Drizzle Execute Parser
4
4
 *
5
5
 *  Copyright (C) 2011 Data Differential, http://datadifferential.com/
71
71
 
72
72
int execute_lex(YYSTYPE* lvalp, void* scanner);
73
73
std::string query;
74
 
#define parser_abort(A, B) do { parser::abort_func((A), (B)); YYABORT; } while (0) 
 
74
#define parser_abort(A, B) do { parser::abort_func((A), (B)); YYABORT; } while (0)
75
75
 
76
76
inline void execute_error(::drizzled::execute::Context *context, yyscan_t *scanner, const char *error)
77
77
{
92
92
 
93
93
%%
94
94
 
95
 
begin:    
 
95
begin:
96
96
 
97
 
          STRING   {   
98
 
                       query.append( std::string($1.str, $1.length));
 
97
          STRING   {
 
98
                       query.append($1.data(), $1.size());
99
99
                       query.push_back(' ');
100
100
                   }
101
101
          |
102
 
                         
 
102
 
103
103
          begin STRING {
104
 
                         query.append(std::string($2.str, $2.length));
 
104
                         query.append($2.data(), $2.size());
105
105
                         query.push_back(' ');
106
106
                       }
107
107
        ;
108
108
 
109
109
 
110
 
%% 
 
110
%%
111
111
 
112
112
 
113
113
namespace drizzled {
114
114
namespace execute {
115
115
 
116
 
std::vector<std::string> Context::start() 
 
116
std::vector<std::string> Context::start()
117
117
{
118
118
  execute_parse(this, (void **)scanner);
119
119
  std::vector<std::string> parsed_queries;
120
120
  while ((pos= query.find(';')) != std::string::npos)
121
121
  {
122
122
    parsed_queries.push_back(query.substr(0, pos));
123
 
    if (query[pos+1] == ' ')
124
 
    {
125
 
      query= query.substr(pos + 2, query.length());
126
 
    }
127
 
    else
128
 
    {
129
 
      query= query.substr(pos + 1, query.length());
130
 
    }
 
123
    pos++;
 
124
    if (query[pos] == ' ')
 
125
        pos++;
 
126
    query.erase(0, pos);
131
127
  }
132
 
  parsed_queries.push_back(query); 
 
128
  parsed_queries.push_back(query);
133
129
  query.clear();
134
130
 
135
131
  return parsed_queries;