Always include the boost-package. Otherwise it won't get searched on a second run.
[amule.git] / src / Parser.y
blobd938305cd74bd2030924975083cf872bab8e228f
1 %{
2 #include "SearchExpr.h"
3 #include "Scanner.h"
4 #include "OtherFunctions.h"
6 #include "libs/common/StringFunctions.h"
8 #ifdef _DEBUG
9 #undef THIS_FILE
10 static char THIS_FILE[] = __FILE__;
11 #endif
13 extern wxArrayString _astrParserErrors;
15 int yyerror(const char* errstr);
16 int yyerror(wxString errstr);
20 %union {
21 wxString* pstr;
22 CSearchExpr* pexpr;
25 %token TOK_STRING
26 %token TOK_AND TOK_OR TOK_NOT
27 %token TOK_ED2K_LINK
29 %type <pexpr> searchexpr and_strings
30 %type <pstr> TOK_STRING TOK_ED2K_LINK
32 %left TOK_OR
33 %left TOK_AND
34 %left TOK_NOT
37 /*-------------------------------------------------------------------*/
39 action : searchexpr
41 ParsedSearchExpression($1);
42 delete $1;
43 return 0;
45 | TOK_ED2K_LINK
47 CSearchExpr* pexpr = new CSearchExpr(*$1);
48 ParsedSearchExpression(pexpr);
49 delete pexpr;
50 delete $1;
51 return 0;
53 /* --------- Error Handling --------- */
54 | searchexpr error
56 yyerror(wxT("Undefined search expression error"));
57 delete $1;
58 return 1;
63 searchexpr : and_strings
64 | searchexpr TOK_AND searchexpr
66 CSearchExpr* pexpr = new CSearchExpr;
67 pexpr->Add(SEARCHOP_AND);
68 pexpr->Add($1);
69 pexpr->Add($3);
70 $$ = pexpr;
71 delete $1;
72 delete $3;
74 | searchexpr TOK_OR searchexpr
76 CSearchExpr* pexpr = new CSearchExpr;
77 pexpr->Add(SEARCHOP_OR);
78 pexpr->Add($1);
79 pexpr->Add($3);
80 $$ = pexpr;
81 delete $1;
82 delete $3;
84 | searchexpr TOK_NOT searchexpr
86 CSearchExpr* pexpr = new CSearchExpr;
87 pexpr->Add(SEARCHOP_NOT);
88 pexpr->Add($1);
89 pexpr->Add($3);
90 $$ = pexpr;
91 delete $1;
92 delete $3;
94 | '(' searchexpr ')'
96 $$ = $2;
98 /* --------- Error Handling --------- */
99 | searchexpr TOK_OR error
101 yyerror(wxT("Missing right operand for OR on search expression"));
102 delete $1;
103 return 1;
105 | searchexpr TOK_NOT error
107 yyerror(wxT("Missing operand for NOT on search expression"));
108 delete $1;
109 return 1;
111 | '(' error
113 yyerror(wxT("Missing left parenthesis on search expression"));
114 return 1;
116 | '(' searchexpr error
118 yyerror(wxT("Missing closing parenthesis on search expression"));
119 delete $2;
120 return 1;
122 | TOK_AND error
124 yyerror(wxT("Missing left operand for AND on search expression"));
125 return 1;
127 | TOK_OR error
129 yyerror(wxT("Missing left operand for OR on search expression"));
130 return 1;
132 | TOK_NOT error
134 yyerror(wxT("Missing left operand for NOT on search expression (?)"));
135 return 1;
139 and_strings : TOK_STRING
141 $$ = new CSearchExpr(*$1);
142 delete $1;
144 | and_strings TOK_STRING
146 /*$1->Concatenate($2);
147 delete $2;*/
148 CSearchExpr* pexpr = new CSearchExpr;
149 pexpr->Add(SEARCHOP_AND);
150 pexpr->Add($1);
151 pexpr->Add(*$2);
152 $$ = pexpr;
153 delete $1;
154 delete $2;
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));
169 return EXIT_FAILURE;
172 int yyerror(wxString errstr)
174 _astrParserErrors.Add(errstr);
175 return EXIT_FAILURE;