Skip to content

Commit 35b60fa

Browse files
committed
fix-infix
1 parent fcc5459 commit 35b60fa

File tree

6 files changed

+244
-85
lines changed

6 files changed

+244
-85
lines changed

expr.js

Lines changed: 24 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

expr.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

expr.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,10 +564,10 @@ let Expr: Plugin = function expr(jsonic: Jsonic, options: ExprOptions) {
564564
r.node.push(r.child.node)
565565
}
566566

567-
// console.log('EXPR-BC', addterm, r.i, p(r.node),
567+
// console.log('EXPR-BC', addterm, r.i, p(r.node), r.u,
568568
// 'C', r.child.i, p(r.child.node),
569569
// 'P', r.parent.i, p(r.parent.node),
570-
//)
570+
// )
571571
})
572572

573573
.close([
@@ -578,27 +578,52 @@ let Expr: Plugin = function expr(jsonic: Jsonic, options: ExprOptions) {
578578
g: 'expr,expr-end,expr-paren-end',
579579
},
580580

581+
581582
hasInfix
582583
? {
583584
s: [INFIX],
584585
// Complete prefix first.
585586
c: (r: Rule) => !r.n.expr_prefix,
586587
b: 1,
587588
r: 'expr',
589+
g: 'expr,expr-infix,expr-prefix',
590+
}
591+
: NONE,
592+
593+
// TTT
594+
hasInfix
595+
? {
596+
s: [INFIX],
597+
// Complete prefix first.
598+
c: (r: Rule) => !!r.n.expr_prefix,
599+
b: 1,
600+
// r: 'expr',
588601
g: 'expr,expr-infix',
589602
}
590603
: NONE,
591604

605+
592606
hasSuffix
593607
? {
594608
s: [SUFFIX],
595609
c: (r: Rule) => !r.n.expr_prefix,
596610
b: 1,
597611
r: 'expr',
598-
g: 'expr,expr-suffix',
612+
g: 'expr,expr-suffix,expr-prefix',
599613
}
600614
: NONE,
601615

616+
// TTT
617+
// hasSuffix
618+
// ? {
619+
// s: [SUFFIX],
620+
// c: (r: Rule) => !!r.n.expr_prefix,
621+
// b: 1,
622+
// r: 'expr',
623+
// g: 'expr,expr-suffix',
624+
// }
625+
// : NONE,
626+
602627
hasParen
603628
? {
604629
s: [CP],
@@ -974,6 +999,7 @@ function makeCloseParen(parenCTM: OpMap) {
974999
}
9751000
}
9761001

1002+
9771003
function implicitList(rule: Rule, ctx: Context, a: any) {
9781004
let paren: Rule | null = null
9791005

@@ -1002,9 +1028,11 @@ function implicitList(rule: Rule, ctx: Context, a: any) {
10021028

10031029
rule.node = paren.child.node
10041030
}
1031+
10051032
return a
10061033
}
10071034

1035+
10081036
function implicitTernaryCond(r: Rule) {
10091037
let cond =
10101038
(0 === r.d || 1 <= r.n.expr_paren) && !r.n.pk && 2 === r.u.expr_ternary_step

test/expr.test.js

Lines changed: 86 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/expr.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)