Skip to content

Commit

Permalink
Fix same-group issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jun 11, 2024
1 parent 6ac2264 commit 22dc9b0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion feature/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import { token, skip, next, cur, idx, expr } from "../src/parse.js"
// /**/, //
// FIXME: try replacing with group
token('/*', PREC_TOKEN, (a, prec) => (next(c => c !== STAR && cur.charCodeAt(idx + 1) !== 47), skip(2), a || expr(prec) || []))
token('//', PREC_TOKEN, (a, prec) => (next(c => c >= SPACE), a || expr(prec) || ['']))
token('//', PREC_TOKEN, (a, prec) => (next(c => c >= SPACE), a || expr(prec) || []))
2 changes: 1 addition & 1 deletion justin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +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_STATEMENT = 5,
PREC_SEQ = 10,
PREC_ASSIGN = 20,
PREC_LOR = 30,
Expand Down
2 changes: 1 addition & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export let idx, cur,
(b = expr(prec)),
(
(!a || a[0] !== op) && (a = [op, a]), // if beginning of sequence - init node
a.push(b),
b?.[0] === op ? [, ...b] = b : b = [b], a.push(...b), // comments can return same-token expr
a
))
)
Expand Down
Loading

0 comments on commit 22dc9b0

Please sign in to comment.