Skip to content

Commit

Permalink
chore: some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PrettyWood committed Dec 10, 2023
1 parent 1659506 commit 054d29e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion grammars/prql-lezer/src/prql.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ LambdaParam { identPart TypeDefinition? (":" expression)? }
Comment { "#" ![\n]* }
@precedence { Docblock, Comment }

//op_bin_only { "*" | "/" | "//" | "%" | "!=" | ">=" | "<=" | "~=" | ">" | "<" | "??" | "&&" | "||" }
//op_bin_only { "*" | "/" | "//" | "%" | "**" | "!=" | ">=" | "<=" | "~=" | ">" | "<" | "??" | "&&" | "||" }
//op_unary { "-" | "+" | "==" }
end { @eof }
lineWrap { "\\" }
Expand Down
3 changes: 2 additions & 1 deletion prqlc/prql-compiler/src/codegen/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ fn binding_strength(expr: &ExprKind) -> u8 {
ExprKind::Range(_) => 19,

ExprKind::Binary(BinaryExpr { op, .. }) => match op {
BinOp::Mul | BinOp::DivInt | BinOp::DivFloat | BinOp::Mod | BinOp::Pow => 18,
BinOp::Pow => 19,
BinOp::Mul | BinOp::DivInt | BinOp::DivFloat | BinOp::Mod => 18,
BinOp::Add | BinOp::Sub => 17,
BinOp::Eq
| BinOp::Ne
Expand Down
6 changes: 3 additions & 3 deletions prqlc/prqlc-parser/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ fn operator_unary() -> impl Parser<Token, UnOp, Error = PError> {
.or(just(Token::Eq).to(UnOp::EqSelf))
}
fn operator_mul() -> impl Parser<Token, BinOp, Error = PError> {
(ctrl('*').to(BinOp::Mul))
.or(just(Token::DivInt).to(BinOp::DivInt))
(just(Token::DivInt).to(BinOp::DivInt))
.or(just(Token::Pow).to(BinOp::Pow))
.or(ctrl('*').to(BinOp::Mul))
.or(ctrl('/').to(BinOp::DivFloat))
.or(ctrl('%').to(BinOp::Mod))
.or(just(Token::Pow).to(BinOp::Pow))
}
fn operator_add() -> impl Parser<Token, BinOp, Error = PError> {
(ctrl('+').to(BinOp::Add)).or(ctrl('-').to(BinOp::Sub))
Expand Down
15 changes: 8 additions & 7 deletions web/book/src/reference/syntax/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ operations and for function calls (see the discussion below.)
| identifier dot | `.` | 1 | |
| unary | `-` `+` `!` `==` | 2 | |
| range | `..` | 3 | |
| mul | `*` `/` `//` `%` `**` | 4 | left-to-right |
| add | `+` `-` | 5 | left-to-right |
| compare | `==` `!=` `<=` `>=` `<` `>` | 6 | left-to-right |
| coalesce | `??` | 7 | left-to-right |
| and | `&&` | 8 | left-to-right |
| or | <code>\|\|</code> | 9 | left-to-right |
| function call | | 10 | |
| pow | `**` | 4 | |
| mul | `*` `/` `//` `%` | 5 | left-to-right |
| add | `+` `-` | 6 | left-to-right |
| compare | `==` `!=` `<=` `>=` `<` `>` | 7 | left-to-right |
| coalesce | `??` | 8 | left-to-right |
| and | `&&` | 9 | left-to-right |
| or | <code>\|\|</code> | 10 | left-to-right |
| function call | | 11 | |

## Division and integer division

Expand Down
4 changes: 2 additions & 2 deletions web/playground/src/workbench/prql-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const def = {
keywords: [...TRANSFORMS, ...BUILTIN_FUNCTIONS, ...KEYWORDS, ...LITERALS],

operators: [
"+",
"-",
"*",
"/",
"//",
"%",
"+",
"-",
"**",
"==",
"!=",
"->",
Expand Down

0 comments on commit 054d29e

Please sign in to comment.