starlight-cli 1.0.25 → 1.0.27

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.
package/src/lexer.js CHANGED
@@ -79,10 +79,13 @@ class Lexer {
79
79
  }
80
80
 
81
81
  const keywords = [
82
- 'let', 'sldeploy', 'if', 'else', 'while', 'for',
83
- 'break', 'continue', 'func', 'return', 'true', 'false', 'null',
84
- 'ask', 'define', 'import', 'from', 'as'
85
- ];
82
+ 'let', 'sldeploy', 'if', 'else', 'while', 'for',
83
+ 'break', 'continue', 'func', 'return',
84
+ 'true', 'false', 'null',
85
+ 'ask', 'define', 'import', 'from', 'as',
86
+ 'async', 'await'
87
+ ];
88
+
86
89
 
87
90
  if (keywords.includes(result)) {
88
91
  return { type: result.toUpperCase(), value: result, line: startLine, column: startCol };
package/src/parser.js CHANGED
@@ -31,6 +31,11 @@ class Parser {
31
31
  }
32
32
 
33
33
  statement() {
34
+ if (this.current.type === 'ASYNC' && this.peekType() === 'FUNC') {
35
+ this.eat('ASYNC');
36
+ this.eat('FUNC');
37
+ return this.asyncFuncDeclaration();
38
+ }
34
39
  switch (this.current.type) {
35
40
  case 'LET': return this.varDeclaration();
36
41
  case 'SLDEPLOY': return this.sldeployStatement();
@@ -78,6 +83,24 @@ class Parser {
78
83
  if (this.current.type === 'SEMICOLON') this.eat('SEMICOLON');
79
84
  return { type: 'DefineStatement', id, expr };
80
85
  }
86
+ asyncFuncDeclaration() {
87
+ const name = this.current.value;
88
+ this.eat('IDENTIFIER');
89
+ this.eat('LPAREN');
90
+ const params = [];
91
+ if (this.current.type !== 'RPAREN') {
92
+ params.push(this.current.value);
93
+ this.eat('IDENTIFIER');
94
+ while (this.current.type === 'COMMA') {
95
+ this.eat('COMMA');
96
+ params.push(this.current.value);
97
+ this.eat('IDENTIFIER');
98
+ }
99
+ }
100
+ this.eat('RPAREN');
101
+ const body = this.block();
102
+ return { type: 'FunctionDeclaration', name, params, body, async: true };
103
+ }
81
104
 
82
105
  ifStatement() {
83
106
  this.eat('IF');
@@ -386,7 +409,11 @@ arrowFunction(params) {
386
409
  if (t.type === 'TRUE') { this.eat('TRUE'); return { type: 'Literal', value: true }; }
387
410
  if (t.type === 'FALSE') { this.eat('FALSE'); return { type: 'Literal', value: false }; }
388
411
  if (t.type === 'NULL') { this.eat('NULL'); return { type: 'Literal', value: null }; }
389
-
412
+ if (t.type === 'AWAIT') {
413
+ this.eat('AWAIT');
414
+ const argument = this.expression();
415
+ return { type: 'AwaitExpression', argument };
416
+ }
390
417
  if (t.type === 'ASK') {
391
418
  this.eat('ASK');
392
419
  this.eat('LPAREN');
package/src/starlight.js CHANGED
@@ -9,7 +9,7 @@ const Lexer = require('./lexer');
9
9
  const Parser = require('./parser');
10
10
  const Evaluator = require('./evaluator');
11
11
 
12
- const VERSION = '1.0.25';
12
+ const VERSION = '1.0.27';
13
13
 
14
14
  const COLOR = {
15
15
  reset: '\x1b[0m',