2 #include "SearchExpr.h"
4 #include "OtherFunctions.h"
6 #include "libs/common/StringFunctions.h"
10 static char THIS_FILE
[] = __FILE__
;
13 extern wxArrayString _astrParserErrors
;
15 int yyerror(const char* errstr
);
16 int yyerror(wxString errstr
);
26 %token TOK_AND TOK_OR TOK_NOT
29 %type
<pexpr
> searchexpr and_strings
30 %type
<pstr
> TOK_STRING TOK_ED2K_LINK
37 /*-------------------------------------------------------------------*/
41 ParsedSearchExpression
($1);
47 CSearchExpr
* pexpr
= new CSearchExpr
(*$1);
48 ParsedSearchExpression
(pexpr
);
53 /* --------- Error Handling --------- */
56 yyerror(wxT
("Undefined search expression error"));
63 searchexpr
: and_strings
64 | searchexpr TOK_AND searchexpr
66 CSearchExpr
* pexpr
= new CSearchExpr
;
67 pexpr
->Add
(SEARCHOP_AND
);
74 | searchexpr TOK_OR searchexpr
76 CSearchExpr
* pexpr
= new CSearchExpr
;
77 pexpr
->Add
(SEARCHOP_OR
);
84 | searchexpr TOK_NOT searchexpr
86 CSearchExpr
* pexpr
= new CSearchExpr
;
87 pexpr
->Add
(SEARCHOP_NOT
);
98 /* --------- Error Handling --------- */
99 | searchexpr TOK_OR
error
101 yyerror(wxT
("Missing right operand for OR on search expression"));
105 | searchexpr TOK_NOT
error
107 yyerror(wxT
("Missing operand for NOT on search expression"));
113 yyerror(wxT
("Missing left parenthesis on search expression"));
116 |
'(' searchexpr
error
118 yyerror(wxT
("Missing closing parenthesis on search expression"));
124 yyerror(wxT
("Missing left operand for AND on search expression"));
129 yyerror(wxT
("Missing left operand for OR on search expression"));
134 yyerror(wxT
("Missing left operand for NOT on search expression (?)"));
139 and_strings
: TOK_STRING
141 $$
= new CSearchExpr
(*$1);
144 | and_strings TOK_STRING
146 /*$1->Concatenate($2);
148 CSearchExpr
* pexpr
= new CSearchExpr
;
149 pexpr
->Add
(SEARCHOP_AND
);
160 int yyerror(const char* errstr
)
162 // Errors created by yacc generated code
163 //yyerror ("syntax error: cannot back up");
164 //yyerror ("syntax error; also virtual memory exhausted");
165 //yyerror ("syntax error");
166 //yyerror ("parser stack overflow");
168 _astrParserErrors.Add
(char2unicode
(errstr
));
172 int yyerror(wxString errstr
)
174 _astrParserErrors.Add
(errstr
);