Skip to content

Commit

Permalink
feat: Add custom operator (#868)
Browse files Browse the repository at this point in the history
* feat: Add custom operator

From #863

- It doesn't parse anything — I'm not sure how to parse ` SELECT 'a' REGEXP '^[a-d]';` with `REGEXP` as the operator... (but fine for my narrow purpose)
- If we need tests, where would I add them?

* Update src/ast/operator.rs

---------

Co-authored-by: Andrew Lamb <[email protected]>
  • Loading branch information
max-sixty and alamb authored May 17, 2023
1 parent 4559d87 commit feaa13c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ast/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ pub enum BinaryOperator {
BitwiseOr,
BitwiseAnd,
BitwiseXor,
/// Support for custom operators (built by parsers outside this crate)
Custom(String),
PGBitwiseXor,
PGBitwiseShiftLeft,
PGBitwiseShiftRight,
Expand Down Expand Up @@ -122,6 +124,7 @@ impl fmt::Display for BinaryOperator {
BinaryOperator::BitwiseOr => f.write_str("|"),
BinaryOperator::BitwiseAnd => f.write_str("&"),
BinaryOperator::BitwiseXor => f.write_str("^"),
BinaryOperator::Custom(s) => f.write_str(s),
BinaryOperator::PGBitwiseXor => f.write_str("#"),
BinaryOperator::PGBitwiseShiftLeft => f.write_str("<<"),
BinaryOperator::PGBitwiseShiftRight => f.write_str(">>"),
Expand Down

0 comments on commit feaa13c

Please sign in to comment.