Skip to content

feat(cql2-text): add modulo, integer division, and power arithmetic operators - #151

Open
constantinius wants to merge 1 commit into
mainfrom
cql2-arithmetic-compliance
Open

feat(cql2-text): add modulo, integer division, and power arithmetic operators#151
constantinius wants to merge 1 commit into
mainfrom
cql2-arithmetic-compliance

Conversation

@constantinius

Copy link
Copy Markdown
Contributor

Implements three CQL2 arithmetic operators missing from the text parser:

  • Modulo (%): e.g. 'attr % 2 = 0'
  • Integer division (div): e.g. 'attr div 2 = 1'
  • Power (^): e.g. 'attr ^ 2 = 4' (right-associative)

Changes span all layers:

  • ast.py: adds ArithmeticOp.MOD/INTDIV/POW enums and Mod/IntDiv/Pow dataclasses
  • cql2.py: extends ARITHMETIC_MAP with the three new operators
  • grammar.lark: introduces a 'power' precedence level above 'product' for right-associative exponentiation; adds mod and intdiv production rules; uses named filter terminals (_PERCENT, _INTDIV) so they don't bleed into transformer callbacks
  • parser.py: adds mod(), intdiv(), and pow() transformer methods
  • tests: adds test_modulo, test_integer_division, test_power

…perators

Implements three CQL2 arithmetic operators missing from the text parser:

- Modulo (%): e.g. 'attr % 2 = 0'
- Integer division (div): e.g. 'attr div 2 = 1'
- Power (^): e.g. 'attr ^ 2 = 4' (right-associative)

Changes span all layers:
- ast.py: adds ArithmeticOp.MOD/INTDIV/POW enums and Mod/IntDiv/Pow dataclasses
- cql2.py: extends ARITHMETIC_MAP with the three new operators
- grammar.lark: introduces a 'power' precedence level above 'product' for
  right-associative exponentiation; adds mod and intdiv production rules;
  uses named filter terminals (_PERCENT, _INTDIV) so they don't bleed into
  transformer callbacks
- parser.py: adds mod(), intdiv(), and pow() transformer methods
- tests: adds test_modulo, test_integer_division, test_power
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

Successfully merging this pull request may close these issues.

1 participant