@cilix/lightjs 0.0.12 → 0.0.13

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 +15 -11
  2. package/package.json +1 -1
package/core.js CHANGED
@@ -385,8 +385,6 @@ module.exports = (config, fs, path) => {
385
385
  return c == '\n' || c == '\r'
386
386
  }
387
387
 
388
- // amazing
389
- // https://stackoverflow.com/a/32567789
390
388
  function is_letter (c) {
391
389
  return c.toLowerCase() != c.toUpperCase();
392
390
  }
@@ -706,8 +704,9 @@ module.exports = (config, fs, path) => {
706
704
  return false;
707
705
  }
708
706
 
709
- function peek(t) {
710
- if (tok.type === t) {
707
+ function peek(t, forward) {
708
+ const tk = forward ? tokens[cursor + forward] : tok;
709
+ if (tk.type === t) {
711
710
  return true;
712
711
  }
713
712
  return false;
@@ -1008,7 +1007,6 @@ module.exports = (config, fs, path) => {
1008
1007
  let handler;
1009
1008
  let evt;
1010
1009
  if (accept('on')) {
1011
- console.log('YEAHHHHH')
1012
1010
  expect(":");
1013
1011
  evt = tok.data;
1014
1012
  } else {
@@ -1188,6 +1186,10 @@ module.exports = (config, fs, path) => {
1188
1186
  parent = current;
1189
1187
  }
1190
1188
 
1189
+ function isAssignment() {
1190
+ return peek('let') || (peek('ident') && peek(':', 1));
1191
+ }
1192
+
1191
1193
  function parse_tag_list() {
1192
1194
  if (accept("if")) {
1193
1195
  parse_if_statement();
@@ -1222,6 +1224,9 @@ module.exports = (config, fs, path) => {
1222
1224
  } else if (accept("when")) {
1223
1225
  parse_when_statement();
1224
1226
  parse_tag_list();
1227
+ } else if (parse_state.in_tag && isAssignment()) {
1228
+ parse_assignment();
1229
+ parse_tag_list();
1225
1230
  } else if (peek("ident")) {
1226
1231
  parse_tag();
1227
1232
  parse_tag_list();
@@ -1233,9 +1238,6 @@ module.exports = (config, fs, path) => {
1233
1238
  ast_node('yield', { pos: tok.pos, file: tok.file });
1234
1239
  next();
1235
1240
  parse_tag_list();
1236
- } else if (parse_state.in_tag && (peek('global') || peek('const') || peek('let'))) {
1237
- parse_assignment();
1238
- parse_tag_list();
1239
1241
  } else if (parse_state.in_tag && peek('js_context')) {
1240
1242
  includeRuntime = true;
1241
1243
  parent.js = tok.data;
@@ -1304,7 +1306,9 @@ module.exports = (config, fs, path) => {
1304
1306
 
1305
1307
  function parse_assignment () {
1306
1308
  const global = tok.data === 'global';
1307
- next();
1309
+ if (peek('global') || peek('let')) {
1310
+ next();
1311
+ }
1308
1312
  let dst = { data: tok.data, pos: tok.pos, file: tok.file };
1309
1313
  expect('ident');
1310
1314
  if (!accept("=") && !accept(':')) {
@@ -1375,12 +1379,12 @@ module.exports = (config, fs, path) => {
1375
1379
  pos: pos,
1376
1380
  file: file
1377
1381
  });
1382
+ } else if (isAssignment() || peek('global')) {
1383
+ parse_assignment();
1378
1384
  } else if (tok.type === "ident") {
1379
1385
  parse_tag_list();
1380
1386
  } else if (peek("tag")) {
1381
1387
  parse_custom_tag();
1382
- } else if (peek('const') || peek('let') || peek('global')) {
1383
- parse_assignment();
1384
1388
  } else if (peek('js_context')) {
1385
1389
  includeRuntime = true;
1386
1390
  ast_node('js', { js: tok.data, pos: tok.pos, file: tok.file });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cilix/lightjs",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "A new kind of JavaScript framework",
5
5
  "main": "index.js",
6
6
  "scripts": {