Oops. I just reread Marjolein's message, and made the error message a
bit clearer. I also made the messages start consistently with a capital,
as proper sentences should.
Please try this patch, instead of all the previous ones, to be applied
to the 3.1.1 pre-release:
--- ./htsearch/parser.h.errors Mon Feb 15 20:37:20 1999
+++ ./htsearch/parser.h Tue Feb 16 15:14:00 1999
@@ -39,6 +39,7 @@
int hadError() {return valid == 0;}
protected:
+ void fullexpr(int);
int lexan();
void expr(int);
void term(int);
--- ./htsearch/parser.cc.errors Mon Feb 15 20:37:20 1999
+++ ./htsearch/parser.cc Tue Feb 16 15:27:25 1999
@@ -60,11 +60,31 @@
tokens->Start_Get();
lookahead = lexan();
valid = 1;
- expr(0);
+ fullexpr(0);
return valid;
}
//*****************************************************************************
+void
+Parser::fullexpr(int output)
+{
+ expr(output);
+ if (lookahead != DONE)
+ {
+ valid = 0;
+ error = 0;
+ error << "Expected end of expression instead of '";
+ error << current->word.get() << '\'';
+ switch (lookahead)
+ {
+ case '&': error << " or 'AND'"; break;
+ case '|': error << " or 'OR'"; break;
+ case '!': error << " or 'NOT'"; break;
+ }
+ }
+}
+
+//*****************************************************************************
int
Parser::lexan()
{
@@ -114,7 +134,7 @@
{
valid = 0;
error = 0;
- error << "expected 'AND' or 'OR' instead of '" << current->word.get();
+ error << "Expected 'AND' or 'OR' instead of '" << current->word.get();
error << '\'';
}
}
@@ -155,6 +175,8 @@
else
{
valid = 0;
+ error = 0;
+ error << "Expected ')'";
}
}
else if (lookahead == WORD)
@@ -168,6 +190,27 @@
else
{
valid = 0;
+ error = 0;
+ error << "Expected a search word";
+ }
+
+ if (!valid)
+ {
+ if (lookahead == DONE || !current)
+ {
+ error << " at the end";
+ }
+ else
+ {
+ error << " instead of '" << current->word.get();
+ error << '\'';
+ switch (lookahead)
+ {
+ case '&': error << " or 'AND'"; break;
+ case '|': error << " or 'OR'"; break;
+ case '!': error << " or 'NOT'"; break;
+ }
+ }
}
}
@@ -391,7 +434,7 @@
tokens = tokenList;
tokens->Start_Get();
lookahead = lexan();
- expr(1);
+ fullexpr(1);
ResultList *result = (ResultList *) stack.pop();
if (!result) // Ouch!
--
Gilles R. Detillieux E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba Phone: (204)789-3766
Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930
------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] containing the single word "unsubscribe" in
the SUBJECT of the message.