Commit graph

17 commits

Author SHA1 Message Date
ceea557a61 algo.ShuntingYard: Increase debug logging
Make ShuntingYard log more. Might be overkill in which case the
change should be reversed.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-07-11 10:46:19 +02:00
428692ea3a Streamline Python file headers somewhat
- Add coding statement
  - Import all modules in one line where possible
  - Order: __future__, typing, plain imports, from imports,
    janware modules

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-07-10 05:14:06 +02:00
8b6504f01b fixup! algo.ShuntingYard: Use slog() for debugging
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-07-04 10:22:14 +02:00
49e9b5ab5d algo.ShuntingYard.tokenize(): Allow mixed quotes
"A string which contains 'single quotes'" or 'a string containing
"double quotes"' is not tokenized as quoted. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-07-04 08:59:58 +02:00
27e2a49d1e algo.ShuntingYard: Use slog() for debugging
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-07-04 08:58:42 +02:00
271ea32dcd algo.ShuntingYard.tokenize(): Support double quotes
tokenize() only sorts single quoted strings into QUOTED, fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-06-27 09:46:12 +02:00
29f57ec187 algo.ShuntingYard: Add operator()
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-06-09 09:16:48 +02:00
27813efc04 Fix bogus type errors dug up by mypy
Signed-off-by: Jan Lindemann <jan@janware.com>
2024-06-02 12:05:44 +02:00
952bf4a4e1 Fix Python errors reported by mypy
This commit fixes Python errors and warnings reported by static type checking
with mypy.

Signed-off-by: Jan Lindemann <jan@janware.com>
2020-04-10 14:17:15 +02:00
faa85f7c69 Flip some more switches from pathon 2 to 3 (untested!)
This commit flips some more switches from Python 2 to Python 3 in makefiles and
Python code. Build runs through, but it's still likely to break things.

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-06-02 14:28:47 +02:00
6dd594d47b Fix multiple Python 3 compatibility issues
Changes in Python 3 that made the code choke:

  o basestring is merged into str
  o print() needs parentesis
  o Class inheritance syntax changed
  o Abstract baseclass (ABCMeta) syntax changed
  o map.iteritems() is replaced by map.items()
  o Inconsistent use of tabs and spaces are no longer tolerated

Signed-off-by: Jan Lindemann <jan@janware.com>
2019-03-10 16:38:59 +01:00
421ff284cb ShuntingYard.py: Improve tokenize() quote handling
Quoted arguments were not grouped into one token, firstly, because the
parser didn't pay any attention to them, and secondly, because the data
structure carrying the postfixed string converted it back to being a
string, not a list, in column 2 of the result table.

Signed-off-by: Jan Lindemann <jan@janware.com>
2017-08-03 10:00:29 +02:00
36aac73b5d Add Object.py and log.py
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-30 18:51:19 +02:00
751afbe93d ShuntingYard: Decrease logging
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-27 17:53:55 +02:00
da6c32255e Make jwutils.algo.Operator a class
This was a namedtuple before, but I couldn't figure out how to ex-/import it
over module boundaries, so I've made it a class.

Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-27 16:51:48 +02:00
1259b16837 Re-implement ShuntingYard.infix_to_postfix()
The previous implementation had no concept of associativity.

Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-27 15:18:17 +02:00
81ca793a6e Add algo.ShuntingYard
Signed-off-by: Jan Lindemann <jan@janware.com>
2017-07-27 09:14:45 +02:00