summaryrefslogtreecommitdiffstats
path: root/Parser/parser.c
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-07-11 17:53:00 (GMT)
committerFred Drake <fdrake@acm.org>2000-07-11 17:53:00 (GMT)
commit85f363990cbd6df21015eebdc171c533176e3407 (patch)
tree4aa69857ffe21991384e379799f42ba308a58086 /Parser/parser.c
parent88e1932930245b2f7ed300ff8b31034db7ecda5b (diff)
downloadcpython-85f363990cbd6df21015eebdc171c533176e3407.zip
cpython-85f363990cbd6df21015eebdc171c533176e3407.tar.gz
cpython-85f363990cbd6df21015eebdc171c533176e3407.tar.bz2
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.
Diffstat (limited to 'Parser/parser.c')
-rw-r--r--Parser/parser.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Parser/parser.c b/Parser/parser.c
index ee40f21..b74de7f 100644
--- a/Parser/parser.c
+++ b/Parser/parser.c
@@ -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;
}
}