2 #include "SearchExpr.h"
3 #include "Scanner.h.in"
5 #include "OtherFunctions.h"
7 #include "libs/common/StringFunctions.h"
11 static char THIS_FILE
[] = __FILE__
;
14 extern wxArrayString _astrParserErrors
;
16 void ParsedSearchExpression
(const CSearchExpr
* pexpr
);
17 int yyerror(const char* errstr
);
18 int yyerror(wxString errstr
);
28 %token TOK_AND TOK_OR TOK_NOT
31 %type
<pexpr
> searchexpr and_strings
32 %type
<pstr
> TOK_STRING TOK_ED2K_LINK
39 /*-------------------------------------------------------------------*/
43 ParsedSearchExpression
($1);
49 CSearchExpr
* pexpr
= new CSearchExpr
(*$1);
50 ParsedSearchExpression
(pexpr
);
55 /* --------- Error Handling --------- */
58 yyerror(wxT
("Undefined search expression error"));
65 searchexpr
: and_strings
66 | searchexpr TOK_AND searchexpr
68 CSearchExpr
* pexpr
= new CSearchExpr
;
69 pexpr
->Add
(SEARCHOP_AND
);
76 | searchexpr TOK_OR searchexpr
78 CSearchExpr
* pexpr
= new CSearchExpr
;
79 pexpr
->Add
(SEARCHOP_OR
);
86 | searchexpr TOK_NOT searchexpr
88 CSearchExpr
* pexpr
= new CSearchExpr
;
89 pexpr
->Add
(SEARCHOP_NOT
);
100 /* --------- Error Handling --------- */
101 | searchexpr TOK_OR
error
103 yyerror(wxT
("Missing right operand for OR on search expression"));
107 | searchexpr TOK_NOT
error
109 yyerror(wxT
("Missing operand for NOT on search expression"));
115 yyerror(wxT
("Missing left parenthesis on search expression"));
118 |
'(' searchexpr
error
120 yyerror(wxT
("Missing closing parenthesis on search expression"));
126 yyerror(wxT
("Missing left operand for AND on search expression"));
131 yyerror(wxT
("Missing left operand for OR on search expression"));
136 yyerror(wxT
("Missing left operand for NOT on search expression (?)"));
141 and_strings
: TOK_STRING
143 $$
= new CSearchExpr
(*$1);
146 | and_strings TOK_STRING
148 /*$1->Concatenate($2);
150 CSearchExpr
* pexpr
= new CSearchExpr
;
151 pexpr
->Add
(SEARCHOP_AND
);
162 int yyerror(const char* errstr
)
164 // Errors created by yacc generated code
165 //yyerror ("syntax error: cannot back up");
166 //yyerror ("syntax error; also virtual memory exhausted");
167 //yyerror ("syntax error");
168 //yyerror ("parser stack overflow");
170 _astrParserErrors.Add
(char2unicode
(errstr
));
174 int yyerror(wxString errstr
)
176 _astrParserErrors.Add
(errstr
);