By having the logger stored there, any code using CTokenizer can log messages there.
Unified · Split
| @@ -177,7 +177,7 @@ class CTokenizer(): · 176 unmodified lines | ||
| 177 | 177 | # This class is inspired and follows the basic concepts of: |
| 178 | 178 | # https://docs.python.org/3/library/re.html#writing-a-tokenizer |
| 179 | 179 | |
| 180 | − def __init__(self, source=None, log=None): | |
| 180 | + def __init__(self, source=None): | |
| 181 | 181 | """ |
| 182 | 182 | Create a regular expression to handle RE_SCANNER_LIST. |
| 183 | 183 | |
| @@ -188,6 +188,12 @@ class CTokenizer(): · 4 unmodified lines | ||
| 188 | 188 | when matching a code via RE_SCANNER. |
| 189 | 189 | """ |
| 190 | 190 | |
| 191 | + # | |
| 192 | + # Store logger to allow parser classes to re-use it | |
| 193 | + # | |
| 194 | + global log | |
| 195 | + self.log = log | |
| 196 | + | |
| 191 | 197 | self.tokens = [] |
| 192 | 198 | |
| 193 | 199 | if not source: |