However at the last step I have hit an issue related to possible non-conformance of ure with re.
As far as I can see, I'm not using any re syntax features which ure doesn't support. In any case I believe that ure should either break (tell me I am using unsupported re syntax) or conform (match the behaviour of micropython-re-pcre).
I have done what I can to paper over the cracks from known variations of the api and re support (e.g. omitting character classes, reimplementing .start() and .end()). However, there must be some incorrect feature I am still using.
The only patterns used in the pure-python JSON parsing backend (ijson/backends/python.py) are as below.
Code: Select all
LEXEME_RE = re.compile('[a-z0-9eE\\.\\+-]+|[^ \t\r\n\f]')
STRINGCHUNK = re.compile('(.*?)(["\\\\\\x00-\\x1f])')
For reference, you can find the project at https://github.com/ShrimpingIt/micropython-ijson and the snapshot I am discussing which has a ure issue is at https://github.com/ShrimpingIt/micropyt ... 3cb9bbe283
The test case I am using is functional in unix micropython 1.8.7 with micropython-re-pcre but non-functional with ure. The bug can be demonstrated by substituting import ure as re for import re in the pure python backend https://github.com/ShrimpingIt/micropyt ... /python.py
A successful (or unsuccessful) run can be demonstrated using the test function print_local() in https://github.com/ShrimpingIt/micropyt ... 83/main.py
With ure, the test parse fails immediately on the first structure in the test JSON file https://github.com/ShrimpingIt/micropyt ... ermap.json
** UPDATE **
I have simplified the patterns even further, but still facing parsing errors with ure while micropython-re-pcre works as expected...
Code: Select all
LEXEME_RE = re.compile('[a-z0-9eE\\.\\+-]+|[^ \t\r\n\f]')
STRINGCHUNK = re.compile('(.*?)(")')
Code: Select all
>>> import main
>>> main.print_local()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "main.py", line 43, in print_local
File "main.py", line 43, in print_local
File "main.py", line 29, in print_forecast
File "ijson/common.py", line 63, in parse
File "ijson/backends/python.py", line 262, in basic_parse
File "ijson/backends/python.py", line 202, in parse_value
File "ijson/backends/python.py", line 200, in parse_value
File "ijson/common.py", line 156, in number
ValueError: invalid syntax for integer with base 10: 'c'