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

Add support for 'Or' logical operator - hacktoberfest #3

Open
4 tasks
arrlancore opened this issue Oct 18, 2024 · 0 comments
Open
4 tasks

Add support for 'Or' logical operator - hacktoberfest #3

arrlancore opened this issue Oct 18, 2024 · 0 comments
Labels

Comments

@arrlancore
Copy link
Owner

arrlancore commented Oct 18, 2024

We need to add support for the 'Or' logical operator in Minirule to allow for more complex rule conditions.

Tasks

  • Add 'Or' keyword token
  • Implement 'or' clause in the parser
  • Implement visitor for 'or' clause in the interpreter
  • Add new keyword token to playground editor config

Implementation Details

1. Add 'Or' keyword token

  • Update tokenConfig.ts to include 'Or' in the keywords object
  • Add 'Or' to the list of tokens in grammar.ts

2. Implement 'or' clause in the parser

  • Modify the condition rule in RuleParser class in grammar.ts to support 'or' conditions
  • Update the CONDITION method to handle 'or' clauses

3. Implement visitor for 'or' clause in the interpreter

  • Update the visitCondition method in interpreter.ts to evaluate 'or' conditions
  • Implement logic to return true if any of the conditions in the 'or' clause are true

4. Add new keyword token to playground editor config

  • Update the Monaco editor configuration in the playground to recognize and highlight the 'Or' keyword

Example Usage

rule "Special Offer"
when
  customer.status is "gold"
  or customer.lifetime_value > 10000
then
  apply 15% discount to order.total
end

Acceptance Criteria

  • 'Or' keyword is recognized by the parser
  • Rules with 'or' conditions are correctly interpreted
  • 'Or' keyword is properly highlighted in the playground
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant