diff options
author | David Beazley <dave@dabeaz.com> | 2017-12-02 13:37:54 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-02 13:37:54 -0600 |
commit | eed7b38128687be54ec4468cc22426cc1b3c24fc (patch) | |
tree | 2245b3d622dc292207c535ab6b52290287ff2b82 | |
parent | 15d42d9d17b41cac7c0937bc858ec9407f0c2d03 (diff) | |
parent | 3d7c860b33fac82076d2d8e34d0a8d71fa9ec5ec (diff) | |
download | ply-eed7b38128687be54ec4468cc22426cc1b3c24fc.tar.gz |
Merge pull request #139 from segevfiner/fix-find-column
Fix the find_column example in the documentation
-rw-r--r-- | doc/ply.html | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/doc/ply.html b/doc/ply.html index 30905e2..b35ba44 100644 --- a/doc/ply.html +++ b/doc/ply.html @@ -558,15 +558,12 @@ column information as a separate step. For instance, just count backwards unti <blockquote> <pre> -# Compute column. +# Compute column. # input is the input text string # token is a token instance def find_column(input, token): - last_cr = input.rfind('\n', 0, token.lexpos) - if last_cr < 0: - last_cr = 0 - column = (token.lexpos - last_cr) + 1 - return column + line_start = input.rfind('\n', 0, token.lexpos) + 1 + return (token.lexpos - line_start) + 1 </pre> </blockquote> |