Closed steveshi7 closed 4 years ago
@steveshi7 sure, the standard tokenizer works on strings, but you can instead feed the parser with a sequence of your own tokens collected with your own tokenizer
hi @pombredanne, i'm encountering an issue parsing tokens in which the first character is a number (for example "1abc"). The docstring appears to state that "a string even if starting with digits" is a valid token, but the code then only starts building a symbol when it encounters an alpha char. Can you please advise if I am missing something in my usage of the parser? https://github.com/bastikr/boolean.py/blob/master/boolean/boolean.py#L463
@jcohen28 that's a bug alright as it should be allowed as noted in the doc
@pombredanne thank you for confirming. i'm not as familiar with the implementation logic, so might take me a bit to put together a pr for the fix with appropriate testing. any chance you have time to fix this more quickly?
Here is what I would do: I might try to replace on this line:
https://github.com/bastikr/boolean.py/blob/0da6086c25d0ea3881d3947a3e06340f06868917/boolean/boolean.py#L463
this:
sym = tok.isalpha() or tok == '_'
by
sym = tok.isalphanum() or tok == '_'
And then add a few tests?
@pombredanne thanks. i have opened a pr. what do you think? https://github.com/bastikr/boolean.py/pull/96
@jcohen28 this is all good and merged then released at https://pypi.org/project/boolean.py/3.8/ Thank you ++ :heart:
Is there a way to make this work with numbers as tokens? My use case for this is querying "ids", like 1234, 56, etc.