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

feat(compiler): Add boolean algebra [fixes LNG-211] #814

Merged
merged 16 commits into from
Jul 27, 2023
Merged

Conversation

InversionSpaces
Copy link
Contributor

No description provided.

@linear
Copy link

linear bot commented Jul 25, 2023

LNG-211 Introduce boolean algebra

Add binary boolean operations ||(or) and &&(and) and unary boolean operation !(not)

Result of ||, && and ! should be of type boolean

Precedence:

  • ! should have highest precedence
  • || and && should have lower precedence than math and comparison operations
  • || should have lower precedence than &&

e.g expression a < 5 || foo() > 10 && !flag should be parsed like (a < 5) || ((foo() > 10) && !flag)

Evaluation of arguments:

  • If left argument of || executes to true, right argument should not be computed
  • If left argument of && executes to false, right argument should not be computed

Implementation:

Translate <left> || <right> to

<left-inline>
(xor
  (match <left-res> true (ap true <res>))
  (seq
    <right-inline>
    (ap <right-res> <res>)
  )
)

Translate && to

<left-inline>
(xor
  (match <left-res> false (ap false <res>))
  (seq
    <right-inline>
    (ap <right-res> <res>)
  )
)

Translate !<expr> to

<expr-inline>
(xor
  (match <expr-res> true (ap false <res>))
  (ap true <res>)
)

@InversionSpaces InversionSpaces force-pushed the feat/boolean-algebra branch 2 times, most recently from 4c72702 to 49b0f45 Compare July 25, 2023 13:12
@InversionSpaces InversionSpaces added the e2e Run e2e workflow label Jul 25, 2023
@InversionSpaces InversionSpaces force-pushed the feat/boolean-algebra branch 2 times, most recently from 33cdcca to 76fbb12 Compare July 26, 2023 08:13
@DieMyst DieMyst merged commit a5b6102 into main Jul 27, 2023
9 checks passed
@DieMyst DieMyst deleted the feat/boolean-algebra branch July 27, 2023 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants