@cilix/lightjs 0.0.16 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/core.js +21 -5
  2. package/package.json +1 -1
package/core.js CHANGED
@@ -392,7 +392,8 @@ module.exports = (config, fs, path) => {
392
392
  "as",
393
393
  "global",
394
394
  "when",
395
- "catch"
395
+ "catch",
396
+ "state"
396
397
  ];
397
398
 
398
399
  const symbols = [
@@ -700,6 +701,12 @@ module.exports = (config, fs, path) => {
700
701
  tok.type = c;
701
702
  tok.data = c;
702
703
  cursor++;
704
+ if (c === ':') {
705
+ if (prog[cursor] === '=') {
706
+ tok.type = tok.data = ':=';
707
+ cursor++;
708
+ }
709
+ }
703
710
  } else {
704
711
  tok.type = tok.data = c;
705
712
  cursor++;
@@ -1240,8 +1247,16 @@ module.exports = (config, fs, path) => {
1240
1247
  parent = current;
1241
1248
  }
1242
1249
 
1250
+ function assignmentTok(ahead = 0) {
1251
+ return peek(':', ahead) || peek(':=', ahead) || peek('=', ahead);
1252
+ }
1253
+
1254
+ function assignmentStart() {
1255
+ return peek('let') || peek('state');
1256
+ }
1257
+
1243
1258
  function isAssignment() {
1244
- return peek('let') || (peek('ident') && peek(':', 1));
1259
+ return assignmentStart() || (peek('ident') && assignmentTok(1));
1245
1260
  }
1246
1261
 
1247
1262
  function parse_tag_list() {
@@ -1360,18 +1375,19 @@ module.exports = (config, fs, path) => {
1360
1375
 
1361
1376
  function parse_assignment () {
1362
1377
  const global = tok.data === 'global';
1363
- if (peek('global') || peek('let')) {
1378
+ if (peek('global') || assignmentStart()) {
1364
1379
  next();
1365
1380
  }
1366
1381
  let dst = { data: tok.data, pos: tok.pos, file: tok.file };
1367
1382
  expect('ident');
1368
- if (!accept("=") && !accept(':')) {
1383
+ if (!assignmentTok()) {
1369
1384
  throw_error({
1370
1385
  msg: 'expected assignment',
1371
1386
  pos: tok.pos,
1372
1387
  file: tok.file
1373
1388
  });
1374
1389
  }
1390
+ next();
1375
1391
  let val = parse_rhs();
1376
1392
  ast_node('set', {
1377
1393
  global,
@@ -1619,7 +1635,7 @@ module.exports = (config, fs, path) => {
1619
1635
  return c;
1620
1636
  }).join(' ');
1621
1637
  } else if (t === 'object') {
1622
- val = Object.keys(val).filter((k) => v[k]).join(' ');
1638
+ val = Object.keys(val).filter((k) => val[k]).join(' ');
1623
1639
  } else if (t === 'string') {
1624
1640
  val = val.replace(/"/g, '"');
1625
1641
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cilix/lightjs",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "A new kind of JavaScript framework",
5
5
  "main": "index.js",
6
6
  "scripts": {