Create two new exceptions: IndentationError and TabError. These are

used for indentation related errors.  This patch includes Ping's
improvements for indentation-related error messages.

Closes SourceForge patches #100734 and #100856.
This commit is contained in:
Fred Drake 2000-07-11 17:53:00 +00:00
parent 88e1932930
commit 85f363990c
10 changed files with 80 additions and 19 deletions

View file

@ -205,11 +205,12 @@ classify(g, type, str)
}
int
PyParser_AddToken(ps, type, str, lineno)
PyParser_AddToken(ps, type, str, lineno, expected_ret)
register parser_state *ps;
register int type;
char *str;
int lineno;
int *expected_ret;
{
register int ilabel;
int err;
@ -285,6 +286,15 @@ PyParser_AddToken(ps, type, str, lineno)
/* Stuck, report syntax error */
D(printf(" Error.\n"));
if (expected_ret) {
if (s->s_lower == s->s_upper - 1) {
/* Only one possible expected token */
*expected_ret = ps->p_grammar->
g_ll.ll_label[s->s_lower].lb_type;
}
else
*expected_ret = -1;
}
return E_SYNTAX;
}
}