Skip to content
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

Boolean function parser breaks for alternative notation of AND, OR #597

Open
RenWal opened this issue Nov 6, 2024 · 1 comment
Open
Labels
Priority: Medium Normal priority Type: Bug This is a confirmed or unconfirmed bug

Comments

@RenWal
Copy link
Contributor

RenWal commented Nov 6, 2024

The wiki states:

In general, Boolean functions support NOT ("!", "'"), AND ("&", "*", " "), OR ("|", "+"), and XOR ("^") operations as well as brackets ("(", ")") when being parsed from a string.

The following parses OK:

hal_py.BooleanFunction.from_string("(A & B) | C")

The following should parse according to the documentation, but doesn't:

hal_py.BooleanFunction.from_string("(A * B) + C")

The latter produces the following error:

[06.11.2024 19:50:24] [python_context] [error] [hal/src/python_bindings/bindings/boolean_function.cpp:1251] [hal/src/netlist/boolean_function.cpp:1079] could not parse Boolean function from string: no parser available for '(A...

Can we fix the parser, or update the docs?

@RenWal RenWal added Type: Bug This is a confirmed or unconfirmed bug Priority: Medium Normal priority labels Nov 6, 2024
@RenWal
Copy link
Contributor Author

RenWal commented Nov 7, 2024

The reason seems to be that HAL switches to the Liberty parser when encountering the "*" or "+" symbols. While the HAL-internal parser has no issue with spaces, the Liberty parser treats spaces as AND. Thanks @fyrbiak for pointing this out.

Hence, what does work is the following:

hal_py.BooleanFunction.from_string("(A*B)+C")

I updated the documentation to include a caution about spaces in equations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Medium Normal priority Type: Bug This is a confirmed or unconfirmed bug
Projects
None yet
Development

No branches or pull requests

1 participant