diff options
author | Linus Lee <linus@thesephist.com> | 2020-09-24 07:55:24 -0400 |
---|---|---|
committer | Linus Lee <linus@thesephist.com> | 2020-09-24 07:55:24 -0400 |
commit | 528eb9c74dc29e8f86554852862cdea941dda7a5 (patch) | |
tree | 49f50e9c3add7aae37ade8c95e6ced8014107696 | |
parent | 6c67ca1a0450fac873ec13d0137824a20aef8ebe (diff) | |
download | tabloid-fake-closure-528eb9c74dc29e8f86554852862cdea941dda7a5.tar.gz tabloid-fake-closure-528eb9c74dc29e8f86554852862cdea941dda7a5.zip |
Add support for exprgroups guraded by parens
-rw-r--r-- | static/js/lang.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/static/js/lang.js b/static/js/lang.js index fe6f25b..0782e64 100644 --- a/static/js/lang.js +++ b/static/js/lang.js @@ -414,6 +414,17 @@ class Parser { type: N.ExprGroup, exprs: exprs, }; + } else if (next === T.LParen) { + // block, but guarded by parens, for binary exprs + const exprs = []; + while (this.tokens.hasNext() && this.tokens.peek() !== T.RParen) { + exprs.push(this.expr()); + } + this.tokens.expect(T.RParen); + return { + type: N.ExprGroup, + exprs: exprs, + }; } throw new Error(`Parsing error: expected ident, literal, or block, got ${ @@ -471,7 +482,6 @@ class Parser { const atom = this.atom(); if (BINARY_OPS.includes(this.tokens.peek())) { // infix binary ops - // TODO: support operator precedence const left = atom; const op = this.tokens.next(); const right = this.atom(); |