booleworks / prl-compiler

PRL (Pragmatic Rule Language) compiler
Other
0 stars 0 forks source link

First steps with boolerules - how to start the compiler? #1

Open ChrisSeiler1 opened 9 months ago

ChrisSeiler1 commented 9 months ago

Hi, I tried to create my first rule and uploaded via the showcase UI -> got a parse error, but no indication where exactly the problem is in the prl file. How can I start the compiler and get reasonable feedback on syntax errors?

czengler commented 8 months ago

Hi @ChrisSeiler1 , the best solution would be to use the PRL IntelliJ Plugin at https://github.com/booleworks/prl-intellij-plugin since you get syntax highlighting of PRL files and it shows you syntax errors in your file directly in the editor.

If this is not an option, I just made a little improvement in the parser error handling which should output the offending line numbers in more cases in the GUI. You can fetch the new version by executing a docker compose pull before you run docker compose up again. Now you should get line numbers in your error message like in the appended screenshot.

Screenshot 2024-01-18 at 21 25 02

Executing the compiler e.g. on the commandline is not yet supported out-of-the-box, but will be added in the future.

ChrisSeiler1 commented 8 months ago

Hi Christoph, both ways worked find for me. I found the error, but unfortunately I tried to use integer features that are not yet implemented: "Currently integer and versioned Boolean features are not supported. Support will be added in future releases."

module com.mb.rainfall.odd { enum feature rainfall ["light rain", "medium rain", "heavy rain"] int feature rainfall_duration_in_seconds [1 - 10000] rule [rainfall in ["light rain", "medium rain", "heavy rain"] ] & [rainfall_duration_in_seconds > 30] }

so I have to wait until this feature will be supported. Do you have a rough estimate when this will be available?

czengler commented 8 months ago

Hi Chris, this is actually the feature we are working on right now. There will be a two-step implementation:

  1. Support for integer features which are just assigned and compared (like in your example with >= or <
  2. Support for arithmetic on integer features (so operators +, -, and *

The first one will be available in the next 2 or 3 weeks. The second one ist a different beast alltogether since it requires the integration of either an SMT solver like Z3 or an advances encoding to Boolean algebra. We have some ideas here, but this will definitly take more than a few weeks.

But we think enabling the first kind of integer features (and related version features) will cover most use cases. Stay tuned ;)