21,22c21,44
< #include <sstream>
< #include <cstdarg>
---
> #define YYPARSE_PARAM yythd
> #define YYLEX_PARAM yythd
> #define YYTHD ((THD *)yythd)
> 
> #define MYSQL_YACC
> #define YYINITDEPTH 100
> #define YYMAXDEPTH 3200				/* Because of 64K stack */
> #define Lex (YYTHD->lex)
> #define Select Lex->current_select
> #include "mysql_priv.h"
> #include "slave.h"
> #include "lex_symbol.h"
> #include "item_create.h"
> #include "sp_head.h"
> #include "sp_pcontext.h"
> #include "sp_rcontext.h"
> #include "sp.h"
> #include <myisam.h>
> #include <myisammrg.h>
> 
> //#include <iostream>
> //#include <algorithm>
> //#include <sstream>
> //#include <cstdarg>
827c849
< #include <iostream.h>
---
> //#include <iostream.h>
880a903
> 	yyFlexLexer( char** ptr );
963a987
>   THD *thd;
967c991,993
<   sparql(istream* in, ostream* out) : theScanner(in, out) {;}
---
>   sparql(THD *thd, char** ptr) : theScanner(ptr) {
>     this->thd = thd;
>   }
977c1003,1010
<   fprintf(stderr,"%d: %s at token '%s'\n",yylloc.first_line, m,yylloc.text);
---
> #if TEST
>     cout << yylloc.first_line << ": " << m << " at token '" << yylloc.text << "'" << endl;
> #else
>   //  fprintf("%d: %s at token '%s'\n",yylloc.first_line, m,yylloc.text);
> 	    my_error(ER_NON_UPDATABLE_TABLE, MYF(0),
>                      thd->lex->select_lex.get_table_list()->alias, "UPDATE"); /*
> 	    YYABORT; */
> #endif
983c1016
< using namespace std;
---
> #include "sparqlFrob.h"
985,994c1018
< class sparqlFrob {
< private:
<   void* parser;
< public:
<   sparqlFrob(istream* in, ostream* out);
<   int parse();
< };
< //#include "sparqlFrob.h"
< 
< sparqlFrob::sparqlFrob(istream* in, ostream* out)
---
> sparqlFrob::sparqlFrob(THD *thd, char** ptr)
996c1020,1023
<   sparql* aCompiler = new sparql(in, out);
---
>   // stringstream* ss = new stringstream(buf, stringstream::in);
>   this->thd= thd;
>   lex= thd ? thd->lex : NULL;
>   sparql* aCompiler = new sparql(thd, ptr);
1000a1028,1063
> #if (!TEST)
>   thd->lex->current_select->parsing_place = NO_MATTER;
>   mysql_init_select(lex);
>   thd->lex->current_select->parsing_place = SELECT_LIST;
>   lex->sql_command= SQLCOM_SELECT; // SQLCOM_EMPTY_QUERY;
>   SELECT_LEX *sel= lex->current_select;
>   sel->use_index_ptr=sel->ignore_index_ptr=0;
>   sel->table_join_options= 0;
>   Item* orderDateI = new Item_field(lex->current_context(), NullS, NullS, "orderDate");
>   if (add_item_to_list(thd, orderDateI)) {
>     1/0;
>   }
>   LEX_STRING orderDateS = {"orderDate", 9};
>   lex->create_view_select_start = orderDateS.str; // "orderDate"; // orderDate.name;
>   thd->lex->current_select->parsing_place = NO_MATTER;
>   lex->current_select->set_braces(0);
>   LEX_STRING ordersStr = {"Orders", 6};
>   Table_ident* ti = new Table_ident(ordersStr);
>   TABLE_LIST* jt = sel->add_table_to_list(lex->thd, ti, (LEX_STRING *) 0x0,
> 					  sel->get_table_join_options(),
> 					  lex->lock_option,
> 					  sel->get_use_index(),
> 					  sel->get_ignore_index());
>   sel->add_joined_table(jt);
>   thd->lex->current_select->parsing_place = IN_WHERE;
>   LEX_STRING idStr = {"id", 2};
>   Item* idI = new Item_field(lex->current_context(), NullS, NullS, idStr.str);
>   chooser_compare_func_creator eq = &comp_eq_creator;
>   LEX_STRING n2186Str = {"2186", 4};
>   int error;
>   Item* val = new Item_int(n2186Str.str, (longlong) my_strtoll10(n2186Str.str, NULL, &error), n2186Str.length);
>   Item* test = eq(0)->create(idI, val);
>   sel->where = test;
>   thd->lex->current_select->parsing_place = NO_MATTER;
>   test->top_level_item();
> #endif
1007,1025d1069
< #include <sstream>
< #include <iostream>
< // #include "sparqlFrob.h"
< 
< int main(int argc,char **argv)
< {
<   int result;
<   stringstream* ss = argc > 1 ? new stringstream(argv[1], stringstream::in) : NULL;
< 
<  //  sparql aCompiler(ss, NULL);
<  //  result=aCompiler.yyparse();
< 
<   sparqlFrob frob(ss, NULL);
<   result = frob.parse();
< 
<   cout << "Parsing result: %s.\n" << (result ? "Error" : "OK");
<   return result;
< };
< 
