diff options
author | Paul McGuire <ptmcg@users.noreply.github.com> | 2020-10-11 23:24:20 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@users.noreply.github.com> | 2020-10-11 23:24:20 -0500 |
commit | 989c506bacf68a1451dbdae7b6975e0004d79e77 (patch) | |
tree | b3805f25baa7532f85416980110af6c9cfd156d5 /pyparsing/util.py | |
parent | a5c77176ffa0275e1ce8768ccabd105f873e406c (diff) | |
download | pyparsing-git-989c506bacf68a1451dbdae7b6975e0004d79e77.tar.gz |
Issue #244, fixed debug output to indicate correct parse location; updated setDebug output to include current text line and parse location
Diffstat (limited to 'pyparsing/util.py')
-rw-r--r-- | pyparsing/util.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pyparsing/util.py b/pyparsing/util.py index 1a700ec..152316c 100644 --- a/pyparsing/util.py +++ b/pyparsing/util.py @@ -3,7 +3,7 @@ import warnings import types import collections import itertools - +from functools import lru_cache _bslash = chr(92) @@ -36,6 +36,7 @@ class __config_flags: disable = classmethod(lambda cls, name: cls._set(name, False)) +@lru_cache(maxsize=128) def col(loc, strg): """Returns current column within a string, counting newlines as line separators. The first column is number 1. @@ -51,6 +52,7 @@ def col(loc, strg): return 1 if 0 < loc < len(s) and s[loc - 1] == "\n" else loc - s.rfind("\n", 0, loc) +@lru_cache(maxsize=128) def lineno(loc, strg): """Returns current line number within a string, counting newlines as line separators. The first line is number 1. @@ -64,6 +66,7 @@ def lineno(loc, strg): return strg.count("\n", 0, loc) + 1 +@lru_cache(maxsize=128) def line(loc, strg): """Returns the line of text containing loc within a string, counting newlines as line separators. """ |