diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2006-03-01 22:49:05 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2006-03-01 22:49:05 (GMT) |
commit | 49c5da1d88f605248167f4d95b1dfe08c1f703c7 (patch) | |
tree | 7c7c6ee02daee4f5a2dd3a3fb7b22a5910ec15d2 /Parser/parsetok.c | |
parent | 3ffa59b137a0c1f80b5fd495cc3d25d4ef21e0c0 (diff) | |
download | cpython-49c5da1d88f605248167f4d95b1dfe08c1f703c7.zip cpython-49c5da1d88f605248167f4d95b1dfe08c1f703c7.tar.gz cpython-49c5da1d88f605248167f4d95b1dfe08c1f703c7.tar.bz2 |
Patch #1440601: Add col_offset attribute to AST nodes.
Diffstat (limited to 'Parser/parsetok.c')
-rw-r--r-- | Parser/parsetok.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c index 8b1f70c..77a2cac 100644 --- a/Parser/parsetok.c +++ b/Parser/parsetok.c @@ -130,6 +130,7 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, int type; size_t len; char *str; + int col_offset; type = PyTokenizer_Get(tok, &a, &b); if (type == ERRORTOKEN) { @@ -185,9 +186,13 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, len == 4 && str[0] == 'w' && strcmp(str, "with") == 0) handling_with = 1; #endif - + if (a >= tok->line_start) + col_offset = a - tok->line_start; + else + col_offset = -1; + if ((err_ret->error = - PyParser_AddToken(ps, (int)type, str, tok->lineno, + PyParser_AddToken(ps, (int)type, str, tok->lineno, col_offset, &(err_ret->expected))) != E_OK) { if (err_ret->error != E_DONE) PyObject_FREE(str); |