Skip to content

Commit

Permalink
Lower statement prec
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jun 11, 2024
1 parent f11ff85 commit 6ac2264
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions feature/group.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { err, nary, group } from '../src/parse.js'
import { compile, operator } from '../src/compile.js'
import { PREC_ACCESS, PREC_GROUP, PREC_SEQ } from '../src/const.js'
import { PREC_ACCESS, PREC_GROUP, PREC_SEQ, PREC_STATEMENT } from '../src/const.js'

// (a,b,c), (a)
// FIXME: try raising group precedence (it causes conflict in ?. though)
Expand All @@ -9,4 +9,4 @@ operator('()', (a) => (!a && err('Empty ()'), compile(a)))

const last = (...args) => (args = args.map(compile), ctx => args.map(arg => arg(ctx)).pop())
nary(',', PREC_SEQ), operator(',', last)
nary(';', PREC_SEQ, true), operator(';', last)
nary(';', PREC_STATEMENT, true), operator(';', last)
1 change: 1 addition & 0 deletions src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const
// ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence
// we mult by 10 to leave space for extensions
export const
PREC_STATEMENT = 1,
PREC_SEQ = 10,
PREC_ASSIGN = 20,
PREC_LOR = 30,
Expand Down

0 comments on commit 6ac2264

Please sign in to comment.