Skip to content

An alternative symbol tokenizer and lexer using an Aho-Corasick automaton #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pombredanne opened this issue Feb 23, 2017 · 4 comments

Comments

@pombredanne
Copy link
Collaborator

This is not a bug but a suggestion. I implemented an alternative expression tokenizer using an Aho-Corasick automaton. This allows to lex against a list of known symbols and resolve expressions that would be otherwise ambiguous and may help other boolean.py users.
You can find it there: https://github.com/nexB/license-expression/tree/56709dc901c97a3722247d4e4158e95594fd69a1/src/license_expression

@haschdl
Copy link

haschdl commented May 2, 2024

@pombredanne is there a straighforward way to use your tokenizer with boolean.py ? I checked the code but didn't understand how to use it - my most important requirement is to support hyphens "-" in symbols names e.g. var-A AND var-B

@ferdnyc
Copy link
Contributor

ferdnyc commented May 21, 2024

@haschdl

is there a straighforward way to use your tokenizer with boolean.py ?

I don't know if you looked at the __init__.py in the repo, but it does pretty much exactly that, creating a subclass of boolean.BooleanAlgebra called Licensing and hooking up the automaton as its tokenizer.

I don't expect you can use it directly with the built-in classes in boolean.py, you'd need to subclass BooleanAlgebra in a similar manner to change how it works.

@ferdnyc
Copy link
Contributor

ferdnyc commented May 21, 2024

(Yes, it's one of those packages with a ton of code hidden in its __init__.py. 10 demerits to @pombredanne for that. 😉 )

@haschdl
Copy link

haschdl commented May 22, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants