plainscript-lang 1.0.0 → 1.0.2

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 (52) hide show
  1. package/README.md +157 -150
  2. package/compiler/bundler.js +2 -2
  3. package/compiler/cli.js +172 -65
  4. package/compiler/formatter.js +1 -1
  5. package/compiler/generator.js +905 -184
  6. package/compiler/lexer.js +128 -54
  7. package/compiler/parser.js +1075 -155
  8. package/compiler/version.js +1 -1
  9. package/docs/CAPABILITY_GAP_AUDIT.md +131 -30
  10. package/docs/PLAINSCRIPT-SPEC.md +584 -0
  11. package/docs/index.html +48 -52
  12. package/docs/website/script.js +110 -24
  13. package/docs/website/style.css +4 -4
  14. package/examples/arrays.pln +12 -0
  15. package/examples/{auth-api.ps → auth-api.pln} +3 -3
  16. package/examples/{cache-and-jobs.ps → cache-and-jobs.pln} +1 -1
  17. package/examples/{concurrency.ps → concurrency.pln} +8 -8
  18. package/examples/{database.ps → database.pln} +1 -1
  19. package/examples/{deployment.ps → deployment.pln} +2 -2
  20. package/examples/{email-send.ps → email-send.pln} +1 -1
  21. package/examples/{error-handling.ps → error-handling.pln} +8 -7
  22. package/examples/{expressions.ps → expressions.pln} +1 -1
  23. package/examples/{file-uploads.ps → file-uploads.pln} +4 -4
  24. package/examples/{files-and-config.ps → files-and-config.pln} +4 -4
  25. package/examples/football-backend/{app.ps → app.pln} +2 -2
  26. package/examples/{http-client.ps → http-client.pln} +18 -18
  27. package/examples/id-verification/{app.ps → app.pln} +1 -1
  28. package/examples/{loops.ps → loops.pln} +2 -3
  29. package/examples/modules/{app.ps → app.pln} +4 -4
  30. package/examples/modules/{math.ps → math.pln} +1 -1
  31. package/examples/{record-kinds.ps → record-kinds.pln} +4 -4
  32. package/examples/{rest-api-fetch.ps → rest-api-fetch.pln} +1 -1
  33. package/examples/{rest-api.ps → rest-api.pln} +5 -5
  34. package/examples/{scheduled-tasks.ps → scheduled-tasks.pln} +2 -2
  35. package/examples/{search-and-filter.ps → search-and-filter.pln} +5 -5
  36. package/examples/{sessions-and-cookies.ps → sessions-and-cookies.pln} +2 -2
  37. package/examples/start.pln +2 -0
  38. package/examples/{stdlib.ps → stdlib.pln} +2 -2
  39. package/examples/{telegram-bot.ps → telegram-bot.pln} +2 -2
  40. package/examples/{websocket-server.ps → websocket-server.pln} +1 -1
  41. package/package.json +2 -2
  42. package/docs/PLINJS_SPEC.md +0 -1151
  43. package/examples/arrays.ps +0 -13
  44. package/examples/start.ps +0 -2
  45. /package/examples/{day2.ps → day2.pln} +0 -0
  46. /package/examples/{day3.ps → day3.pln} +0 -0
  47. /package/examples/{hello.ps → hello.pln} +0 -0
  48. /package/examples/{objects.ps → objects.pln} +0 -0
  49. /package/examples/{server.ps → server.pln} +0 -0
  50. /package/examples/{web-app.ps → web-app.pln} +0 -0
  51. /package/examples/whatsapp-bot/{pairing.ps → pairing.pln} +0 -0
  52. /package/examples/whatsapp-bot/{qr.ps → qr.pln} +0 -0
package/compiler/lexer.js CHANGED
@@ -4,33 +4,54 @@
4
4
  const TOKEN = {
5
5
  // Core keywords (v0.1–v0.4)
6
6
  REMEMBER: 'REMEMBER',
7
+ LET: 'LET', // alias for remember: "let x is 5"
7
8
  SHOW: 'SHOW',
9
+ PRINT: 'PRINT', // alias for show
10
+ DISPLAY: 'DISPLAY', // alias for show
8
11
  AS: 'AS',
12
+ IS: 'IS', // used for both "let x is 5" and comparisons
9
13
  IF: 'IF',
10
14
  OTHERWISE: 'OTHERWISE',
15
+ ELSE: 'ELSE', // alias for otherwise
11
16
  DONE: 'DONE',
12
- IS: 'IS',
17
+ END: 'END', // alias for done
13
18
  GREATER: 'GREATER',
14
19
  LESS: 'LESS',
15
20
  THAN: 'THAN',
16
21
  MAKE: 'MAKE',
22
+ DEFINE: 'DEFINE', // alias for make: "define add(a, b)"
23
+ FUNCTION: 'FUNCTION', // alias for make: "function add(a, b)"
17
24
  GIVE: 'GIVE',
25
+ RETURN: 'RETURN', // alias for give
26
+ GIVE_BACK: 'GIVE_BACK', // alias for give: "give back a + b"
18
27
  BECOMES: 'BECOMES',
28
+ IS_NOW: 'IS_NOW', // alias for becomes: "x is now 10"
29
+ SET_TO: 'SET_TO', // alias for becomes: "set x to 10"
30
+ CHANGE_TO: 'CHANGE_TO', // alias for becomes: "change x to 10"
19
31
  FOR: 'FOR',
20
- EACH: 'EACH', // also used for "every" alias
32
+ EACH: 'EACH', // also used for "every" alias
33
+ EVERY: 'EVERY', // alias: "for every item in list"
21
34
  IN: 'IN',
22
35
  WHILE: 'WHILE',
23
36
  USE: 'USE',
24
37
  IMPORT: 'IMPORT',
38
+ INCLUDE: 'INCLUDE', // alias for import: "include "./file.pln""
39
+ LOAD: 'LOAD', // alias for import: "load "./file.pln""
25
40
  // v0.3 — Express runtime
26
41
  WHEN: 'WHEN',
27
42
  SOMEONE: 'SOMEONE',
28
43
  VISITS: 'VISITS',
29
44
  LISTEN: 'LISTEN',
45
+ START_ON: 'START_ON', // alias for listen: "start on port 3000"
46
+ SERVE_ON: 'SERVE_ON', // alias for listen: "serve on port 3000"
30
47
  ON: 'ON',
31
48
  REPLY: 'REPLY',
49
+ RESPOND: 'RESPOND', // alias for reply
50
+ SEND_BACK: 'SEND_BACK', // alias for reply
32
51
  JSON_KW: 'JSON_KW',
33
52
  SERVE: 'SERVE',
53
+ SERVE_STATIC: 'SERVE_STATIC', // alias for serve folder
54
+ SERVE_PUBLIC: 'SERVE_PUBLIC', // alias for serve folder
34
55
  FOLDER: 'FOLDER',
35
56
  // v0.6 — Extended comparisons
36
57
  ABOVE: 'ABOVE',
@@ -41,28 +62,32 @@ const TOKEN = {
41
62
  NOT: 'NOT',
42
63
  EMPTY: 'EMPTY',
43
64
  CONTAINS: 'CONTAINS',
65
+ NOW: 'NOW', // for "is now" assignment
66
+ BACK: 'BACK', // for "give back" return
44
67
  STARTS: 'STARTS',
45
68
  ENDS: 'ENDS',
46
69
  WITH: 'WITH',
47
70
  BETWEEN: 'BETWEEN',
48
71
  AND: 'AND',
49
- OR: 'OR', // v2.1.1 — logical or in conditions
72
+ OR: 'OR', // v2.1.1 — logical or in conditions
73
+ INSTANCEOF: 'INSTANCEOF', // v1.0.2 — instanceof condition
50
74
  // v0.6 — Express DX
51
75
  WEB: 'WEB',
52
76
  ROUTE_KW: 'ROUTE_KW',
53
77
  START_KW: 'START_KW',
78
+ RUN_ON: 'RUN_ON', // alias for start: "run on port 3000"
54
79
  // v0.6 — SQLite DX
55
80
  DATABASE_KW: 'DATABASE_KW',
81
+ CONNECT_DB: 'CONNECT_DB', // alias for database: "connect database "app.db""
82
+ USE_DATABASE: 'USE_DATABASE', // alias for database: "use database "app.db""
56
83
  QUERY_KW: 'QUERY_KW',
57
84
  INSERT_KW: 'INSERT_KW',
58
85
  UPDATE_KW: 'UPDATE_KW',
59
86
  DELETE_KW: 'DELETE_KW',
60
87
  EXECUTE_KW: 'EXECUTE_KW',
61
- SQL_BODY: 'SQL_BODY', // raw SQL collected between a block keyword and "done"
62
- // v1.1.1 — JavaScript Gateway (RFC-0011)
63
- JAVASCRIPT_KW: 'JAVASCRIPT_KW', // the "javascript" keyword introducing a raw JS block
64
- JS_BODY: 'JS_BODY', // raw JavaScript collected between "javascript" and "done"
88
+ SQL_BODY: 'SQL_BODY', // raw SQL collected between a block keyword and "done"
65
89
  ASK: 'ASK', // interactive input: ask name / ask "prompt" as name
90
+ PROMPT: 'PROMPT', // alias for ask: 'prompt "name?" as name'
66
91
  OCR_KW: 'OCR_KW', // v2.0.1 — ocr "<image>" as <name> [using "<lang>"]
67
92
  PACKAGE: 'PACKAGE', // bare npm package name after "use" (may contain -, _, ., /, @)
68
93
  GATHER: 'GATHER', // gather each item in list giving expr (functional map)
@@ -76,9 +101,20 @@ const TOKEN = {
76
101
  EMIT: 'EMIT', // emit "event.name" with data (event emitter)
77
102
  HAPPENS: 'HAPPENS', // when "event.name" happens as data (event listener)
78
103
  CATCHES: 'CATCHES', // recover when err catches "TypeError" (typed error recovery)
79
- // v1.0.0 — generators. "yield" is a JavaScript reserved word, so it becomes a
104
+ // v1.0.1 — generators. "yield" is a JavaScript reserved word, so it becomes a
80
105
  // real keyword token (a variable named `yield` is illegal in JS anyway).
81
106
  YIELD: 'YIELD',
107
+ // v2.3 — English-like syntax keywords
108
+ TO: 'TO', // "to add a and b together" function syntax
109
+ TOGETHER: 'TOGETHER', // function block terminator alternative
110
+ BE: 'BE', // "let x be 5" alternative to "let x is 5"
111
+ THEN: 'THEN', // "when ... then" alternative
112
+ PLUS_WORD: 'PLUS_WORD', // "a plus b" alternative to "a + b"
113
+ MINUS_WORD: 'MINUS_WORD', // "a minus b" alternative to "a - b"
114
+ TIMES_WORD: 'TIMES_WORD', // "a times b" alternative to "a * b"
115
+ DIVIDED_BY_WORD: 'DIVIDED_BY_WORD', // "a divided by b" alternative to "a / b"
116
+ LIST_WITH: 'LIST_WITH', // "list with 1, 2, 3" alternative to "[1, 2, 3]"
117
+ RECORD_WITH: 'RECORD_WITH', // "record with name 'Alice'" alternative to object literal
82
118
  // Punctuation
83
119
  LBRACE: 'LBRACE', // { — inline object literal (v1.2)
84
120
  RBRACE: 'RBRACE', // }
@@ -90,11 +126,19 @@ const TOKEN = {
90
126
  RBRACKET: 'RBRACKET',
91
127
  COMMA: 'COMMA',
92
128
  DOT: 'DOT',
129
+ OPTIONAL_CHAIN: 'OPTIONAL_CHAIN', // ?. — optional chaining
130
+ NULLISH_COALESCE: 'NULLISH_COALESCE', // ?? — nullish coalescing
131
+ POWER: 'POWER', // ** — exponentiation
93
132
  PLUS: 'PLUS',
94
133
  MINUS: 'MINUS', // v2.1.1 — subtraction / unary minus
95
134
  STAR: 'STAR', // v2.1.1 — multiplication
96
135
  SLASH: 'SLASH', // v2.1.1 — division
97
136
  PERCENT: 'PERCENT', // v2.1.1 — remainder (modulo)
137
+ SPREAD: 'SPREAD', // ... — spread operator
138
+ REST: 'REST', // ... — rest parameter
139
+ LOGICAL_OR_ASSIGN: 'LOGICAL_OR_ASSIGN', // ||=
140
+ LOGICAL_AND_ASSIGN: 'LOGICAL_AND_ASSIGN', // &&=
141
+ NULLISH_ASSIGN: 'NULLISH_ASSIGN', // ??=
98
142
  // Literals & identifiers
99
143
  IDENTIFIER: 'IDENTIFIER',
100
144
  STRING: 'STRING',
@@ -102,7 +146,17 @@ const TOKEN = {
102
146
  TRUE_KW: 'TRUE_KW', // v2.1.1 — boolean literal true
103
147
  FALSE_KW: 'FALSE_KW', // v2.1.1 — boolean literal false
104
148
  NULL_KW: 'NULL_KW', // v2.1.1 — null literal
149
+ UNDEFINED_KW: 'UNDEFINED_KW', // v2.2.0 — undefined literal
150
+ BIGINT: 'BIGINT', // BigInt literal (e.g., 42n)
105
151
  TEMPLATE_STRING: 'TEMPLATE_STRING', // backtick-delimited string with interpolation
152
+ SYMBOL_KW: 'SYMBOL_KW', // symbol keyword
153
+ DEBUGGER_KW: 'DEBUGGER_KW', // debugger keyword
154
+ IMPORT_META: 'IMPORT_META', // import.meta
155
+ // v2.4 — Near-English intent-oriented syntax (single-word keywords)
156
+ RAISES: 'RAISES', // "raise expr" throw alternative
157
+ CHOOSING: 'CHOOSING', // "choosing cond then a otherwise b" ternary
158
+ USES: 'USES', // "x uses a, b together" function call
159
+ FILLS: 'FILLS', // "fill x with a, b together" function call
106
160
  // End of input
107
161
  EOF: 'EOF',
108
162
  };
@@ -110,18 +164,30 @@ const TOKEN = {
110
164
  const KEYWORDS = {
111
165
  // Core
112
166
  remember: TOKEN.REMEMBER,
167
+ let: TOKEN.LET,
113
168
  show: TOKEN.SHOW,
169
+ print: TOKEN.PRINT,
170
+ display: TOKEN.DISPLAY,
114
171
  as: TOKEN.AS,
172
+ is: TOKEN.IS,
115
173
  if: TOKEN.IF,
116
174
  otherwise: TOKEN.OTHERWISE,
175
+ else: TOKEN.ELSE,
117
176
  done: TOKEN.DONE,
118
- is: TOKEN.IS,
177
+ end: TOKEN.END,
119
178
  greater: TOKEN.GREATER,
120
179
  less: TOKEN.LESS,
121
180
  than: TOKEN.THAN,
122
181
  make: TOKEN.MAKE,
182
+ define: TOKEN.DEFINE,
183
+ function: TOKEN.FUNCTION,
123
184
  give: TOKEN.GIVE,
185
+ return: TOKEN.RETURN,
186
+ give_back: TOKEN.GIVE_BACK,
124
187
  becomes: TOKEN.BECOMES,
188
+ is_now: TOKEN.IS_NOW,
189
+ set_to: TOKEN.SET_TO,
190
+ change_to: TOKEN.CHANGE_TO,
125
191
  for: TOKEN.FOR,
126
192
  each: TOKEN.EACH,
127
193
  every: TOKEN.EACH, // alias: "for every" = "for each"
@@ -129,15 +195,23 @@ const KEYWORDS = {
129
195
  while: TOKEN.WHILE,
130
196
  use: TOKEN.USE,
131
197
  import: TOKEN.IMPORT,
198
+ include: TOKEN.INCLUDE,
199
+ load: TOKEN.LOAD,
132
200
  // v0.3
133
201
  when: TOKEN.WHEN,
134
202
  someone: TOKEN.SOMEONE,
135
203
  visits: TOKEN.VISITS,
136
204
  listen: TOKEN.LISTEN,
205
+ start_on: TOKEN.START_ON,
206
+ serve_on: TOKEN.SERVE_ON,
137
207
  on: TOKEN.ON,
138
208
  reply: TOKEN.REPLY,
209
+ respond: TOKEN.RESPOND,
210
+ send_back: TOKEN.SEND_BACK,
139
211
  json: TOKEN.JSON_KW,
140
212
  serve: TOKEN.SERVE,
213
+ serve_static: TOKEN.SERVE_STATIC,
214
+ serve_public: TOKEN.SERVE_PUBLIC,
141
215
  folder: TOKEN.FOLDER,
142
216
  // v0.6 — comparisons
143
217
  above: TOKEN.ABOVE,
@@ -154,21 +228,27 @@ const KEYWORDS = {
154
228
  between: TOKEN.BETWEEN,
155
229
  and: TOKEN.AND,
156
230
  or: TOKEN.OR,
231
+ instanceof: TOKEN.INSTANCEOF,
232
+ now: TOKEN.NOW,
233
+ back: TOKEN.BACK,
157
234
  // v2.1.1 — literal keywords. These were previously plain identifiers that
158
235
  // passed through to generated JavaScript; making them explicit tokens gives
159
236
  // them first-class AST nodes and deterministic diagnostics.
160
237
  true: TOKEN.TRUE_KW,
161
238
  false: TOKEN.FALSE_KW,
162
239
  null: TOKEN.NULL_KW,
240
+ undefined: TOKEN.UNDEFINED_KW,
163
241
  // v0.6 — Express DX
164
242
  web: TOKEN.WEB,
165
243
  route: TOKEN.ROUTE_KW,
166
244
  start: TOKEN.START_KW,
245
+ run_on: TOKEN.RUN_ON,
167
246
  // v0.6 — SQLite DX
168
247
  database: TOKEN.DATABASE_KW,
169
- // v1.1.1 — JavaScript Gateway (RFC-0011)
170
- javascript: TOKEN.JAVASCRIPT_KW,
248
+ connect_db: TOKEN.CONNECT_DB,
249
+ use_database: TOKEN.USE_DATABASE,
171
250
  ask: TOKEN.ASK,
251
+ prompt: TOKEN.PROMPT,
172
252
  // v2.0.1 — OCR capability
173
253
  ocr: TOKEN.OCR_KW,
174
254
  // IOPL-native features
@@ -184,6 +264,25 @@ const KEYWORDS = {
184
264
  happens: TOKEN.HAPPENS,
185
265
  catches: TOKEN.CATCHES,
186
266
  yield: TOKEN.YIELD,
267
+ symbol: TOKEN.SYMBOL_KW,
268
+ debugger: TOKEN.DEBUGGER_KW,
269
+ // v2.3 — English-like syntax keywords
270
+ to: TOKEN.TO,
271
+ together: TOKEN.TOGETHER,
272
+ be: TOKEN.BE,
273
+ then: TOKEN.THEN,
274
+ plus: TOKEN.PLUS_WORD,
275
+ minus: TOKEN.MINUS_WORD,
276
+ times: TOKEN.TIMES_WORD,
277
+ divided_by: TOKEN.DIVIDED_BY_WORD,
278
+ list_with: TOKEN.LIST_WITH,
279
+ record_with: TOKEN.RECORD_WITH,
280
+ // v2.4 — Near-English intent-oriented syntax (single-word keywords)
281
+ raise: TOKEN.RAISES,
282
+ raises: TOKEN.RAISES,
283
+ choosing: TOKEN.CHOOSING,
284
+ uses: TOKEN.USES,
285
+ fills: TOKEN.FILLS,
187
286
  };
188
287
 
189
288
  // Keywords that introduce raw SQL blocks (content up to "done" is collected verbatim).
@@ -310,11 +409,17 @@ function tokenize(source) {
310
409
  continue;
311
410
  }
312
411
 
313
- // Number literal (may include decimal point)
412
+ // Number literal (may include decimal point or BigInt suffix 'n')
314
413
  if (/[0-9]/.test(source[i])) {
315
414
  let num = '';
316
415
  while (i < source.length && /[0-9.]/.test(source[i])) num += source[i++];
317
- tokens.push({ type: TOKEN.NUMBER, value: Number(num), line: tokenLine, col: tokenCol });
416
+ // Check for BigInt suffix
417
+ if (i < source.length && source[i] === 'n') {
418
+ i++; // consume 'n'
419
+ tokens.push({ type: TOKEN.BIGINT, value: BigInt(num), line: tokenLine, col: tokenCol });
420
+ } else {
421
+ tokens.push({ type: TOKEN.NUMBER, value: Number(num), line: tokenLine, col: tokenCol });
422
+ }
318
423
  continue;
319
424
  }
320
425
 
@@ -363,47 +468,6 @@ function tokenize(source) {
363
468
  continue;
364
469
  }
365
470
 
366
- // "javascript" introduces a raw JavaScript block: collect every line
367
- // verbatim until a line whose trimmed content is exactly "done".
368
- // This mirrors the SQL block behaviour so the lexer never has to
369
- // understand the JavaScript grammar inside the block.
370
- if (word === 'javascript') {
371
- tokens.push({ type: TOKEN.JAVASCRIPT_KW, value: word, line: tokenLine, col: tokenCol });
372
-
373
- let j = i;
374
- while (j < source.length && (source[j] === ' ' || source[j] === '\t')) j++;
375
-
376
- if (j >= source.length || source[j] === '\n' || source[j] === '\r') {
377
- // Raw block mode — advance past the newline and collect until "done"
378
- i = j;
379
- if (i < source.length && source[i] === '\n') { i++; line++; lineStart = i; }
380
-
381
- let js = '';
382
- while (i < source.length) {
383
- const lineEnd = source.indexOf('\n', i);
384
- const realEnd = lineEnd === -1 ? source.length : lineEnd;
385
- const lineText = source.slice(i, realEnd);
386
- const trimmed = lineText.trim();
387
-
388
- if (trimmed === 'done') {
389
- i = realEnd < source.length ? realEnd + 1 : realEnd;
390
- if (realEnd < source.length) { line++; lineStart = i; }
391
- break;
392
- }
393
-
394
- js += lineText + '\n';
395
- i = realEnd < source.length ? realEnd + 1 : realEnd;
396
- if (realEnd < source.length) { line++; lineStart = i; }
397
- }
398
-
399
- tokens.push({ type: TOKEN.JS_BODY, value: js.trimEnd(), line: tokenLine, col: tokenCol });
400
- tokens.push({ type: TOKEN.DONE, value: 'done', line, col: col() });
401
- }
402
- // else: "javascript" on its own line is followed by a value —
403
- // parsed normally by the parser (used as a remembered value).
404
- continue;
405
- }
406
-
407
471
  const type = Object.prototype.hasOwnProperty.call(KEYWORDS, word)
408
472
  ? KEYWORDS[word]
409
473
  : TOKEN.IDENTIFIER;
@@ -421,14 +485,24 @@ function tokenize(source) {
421
485
  if (source[i] === '[') { tokens.push({ type: TOKEN.LBRACKET, value: '[', line: tokenLine, col: tokenCol }); i++; continue; }
422
486
  if (source[i] === ']') { tokens.push({ type: TOKEN.RBRACKET, value: ']', line: tokenLine, col: tokenCol }); i++; continue; }
423
487
  if (source[i] === ',') { tokens.push({ type: TOKEN.COMMA, value: ',', line: tokenLine, col: tokenCol }); i++; continue; }
488
+ if (source[i] === '?' && source[i + 1] === '.') { tokens.push({ type: TOKEN.OPTIONAL_CHAIN, value: '?.', line: tokenLine, col: tokenCol }); i += 2; continue; }
489
+ if (source[i] === '?' && source[i + 1] === '?' && source[i + 2] === '=') { tokens.push({ type: TOKEN.NULLISH_ASSIGN, value: '??=', line: tokenLine, col: tokenCol }); i += 3; continue; }
490
+ if (source[i] === '?' && source[i + 1] === '?') { tokens.push({ type: TOKEN.NULLISH_COALESCE, value: '??', line: tokenLine, col: tokenCol }); i += 2; continue; }
491
+ if (source[i] === '.' && source[i + 1] === '.' && source[i + 2] === '.') { tokens.push({ type: TOKEN.SPREAD, value: '...', line: tokenLine, col: tokenCol }); i += 3; continue; }
424
492
  if (source[i] === '.') { tokens.push({ type: TOKEN.DOT, value: '.', line: tokenLine, col: tokenCol }); i++; continue; }
493
+ if (source[i] === '+' && source[i + 1] === '+' && source[i + 2] === '=') { tokens.push({ type: TOKEN.LOGICAL_AND_ASSIGN, value: '++=', line: tokenLine, col: tokenCol }); i += 3; continue; }
425
494
  if (source[i] === '+') { tokens.push({ type: TOKEN.PLUS, value: '+', line: tokenLine, col: tokenCol }); i++; continue; }
426
495
  // v2.1.1 — arithmetic. "->" is matched first so it never becomes MINUS.
427
496
  if (source[i] === '-' && source[i + 1] === '>') { tokens.push({ type: TOKEN.ARROW, value: '->', line: tokenLine, col: tokenCol }); i += 2; continue; }
428
497
  if (source[i] === '-') { tokens.push({ type: TOKEN.MINUS, value: '-', line: tokenLine, col: tokenCol }); i++; continue; }
498
+ if (source[i] === '*' && source[i + 1] === '*') { tokens.push({ type: TOKEN.POWER, value: '**', line: tokenLine, col: tokenCol }); i += 2; continue; }
429
499
  if (source[i] === '*') { tokens.push({ type: TOKEN.STAR, value: '*', line: tokenLine, col: tokenCol }); i++; continue; }
430
500
  if (source[i] === '/') { tokens.push({ type: TOKEN.SLASH, value: '/', line: tokenLine, col: tokenCol }); i++; continue; }
431
501
  if (source[i] === '%') { tokens.push({ type: TOKEN.PERCENT, value: '%', line: tokenLine, col: tokenCol }); i++; continue; }
502
+ if (source[i] === '|' && source[i + 1] === '|' && source[i + 2] === '=') { tokens.push({ type: TOKEN.LOGICAL_OR_ASSIGN, value: '||=', line: tokenLine, col: tokenCol }); i += 3; continue; }
503
+ if (source[i] === '&' && source[i + 1] === '&' && source[i + 2] === '=') { tokens.push({ type: TOKEN.LOGICAL_AND_ASSIGN, value: '&&=', line: tokenLine, col: tokenCol }); i += 3; continue; }
504
+ if (source[i] === '|') { i++; continue; } // lone | not supported
505
+ if (source[i] === '&') { i++; continue; } // lone & not supported
432
506
 
433
507
  throw new Error(
434
508
  `Line ${line}, Column ${col()}: Unexpected character "${source[i]}". PlainScript only uses letters, numbers, strings, and known symbols.`