@@ -77,6 +77,9 @@ fn() // 1
7777+ ` { a; b } ` — block scope
7878+ ` let x ` , ` const x = 1 `
7979+ ` break ` , ` continue ` , ` return x `
80+ + `` `a ${x} b` `` — template literals
81+ + ` /pattern/flags ` — regex literals
82+ + ` 5px ` , ` 10rem ` — unit suffixes
8083
8184``` js
8285import subscript from ' subscript/justin'
@@ -124,21 +127,41 @@ const fn = compile(['+', ['*', 'min', [,60]], [,'sec']])
124127fn ({min: 5 }) // min*60 + "sec" == "300sec"
125128
126129// node kinds
127- [' +' , a]; // unary operator `+a`
128- [' +' , a, b]; // binary operator `a + b`
129- [' +' , a, b, c]; // n-ary operator `a + b + c`
130- [' ()' , a]; // group operator `(a)`
131- [' ()' , a, b]; // access operator `a(b)`
132- [, ' a' ]; // literal value `'a'`
133- ' a' ; // variable (from scope)
134- null | empty; // placeholder
135-
136- // eg.
137- [' ()' , ' a' ] // (a)
138- [' ()' , ' a' , null ] // a()
139- [' ()' , ' a' , ' b' ] // a(b)
140- [' ++' , ' a' ] // ++a
141- [' ++' ,' a' , null ] // a++
130+ ' a' // identifier — variable from scope
131+ [, value] // literal — [0] empty distinguishes from operator
132+ [op, a] // unary — prefix operator
133+ [op, a, null ] // unary — postfix operator (null marks postfix)
134+ [op, a, b] // binary
135+ [op, a, b, c] // n-ary / ternary
136+
137+ // operators
138+ [' +' , a, b] // a + b
139+ [' .' , a, ' b' ] // a.b — property access
140+ [' []' , a, b] // a[b] — bracket access
141+ [' ()' , a] // (a) — grouping
142+ [' ()' , a, b] // a(b) — function call
143+ [' ()' , a, null ] // a() — call with no args
144+
145+ // literals & structures
146+ [, 1 ] // 1
147+ [, ' hello' ] // "hello"
148+ [' []' , [' ,' , ... ]] // [a, b] — array literal
149+ [' {}' , [' :' , ... ]] // {a: b} — object literal
150+
151+ // justin extensions
152+ [' ?' , a, b, c] // a ? b : c — ternary
153+ [' =>' , params, x] // (a) => x — arrow function
154+ [' ...' , a] // ...a — spread
155+
156+ // control flow (extra)
157+ [' if' , cond, then, else ]
158+ [' while' , cond, body]
159+ [' for' , init, cond, step, body]
160+
161+ // postfix example
162+ [' ++' , ' a' ] // ++a
163+ [' ++' , ' a' , null ] // a++
164+ [' px' , [,5 ]] // 5px (unit suffix)
142165```
143166
144167### Stringify
0 commit comments