mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
parent
88e1932930
commit
85f363990c
10 changed files with 80 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue