rip-lang 1.3.0 → 1.3.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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rip-lang",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "A lightweight scripting language that compiles to modern JavaScript",
5
5
  "type": "module",
6
6
  "main": "src/compiler.js",
@@ -34,7 +34,7 @@
34
34
  "test": "bun test/runner.js",
35
35
  "version": "./bin/rip -v",
36
36
  "pack": "npm pack --dry-run",
37
- "prepublishOnly": "bun run test && bun run browser"
37
+ "prepublishOnly": "bun run test"
38
38
  },
39
39
  "keywords": [
40
40
  "compiler",
package/src/codegen.js CHANGED
@@ -413,6 +413,7 @@ export class CodeGenerator {
413
413
  case '&&':
414
414
  case '||':
415
415
  case '??':
416
+ case '!?':
416
417
  case '&':
417
418
  case '|':
418
419
  case '^':
@@ -430,6 +431,14 @@ export class CodeGenerator {
430
431
  // Binary operation (all operators)
431
432
  const [left, right] = rest;
432
433
 
434
+ // Special case: Otherwise operator (!?) - undefined-only coalescing
435
+ // Pattern: a !? b → (a !== undefined ? a : b)
436
+ if (head === '!?') {
437
+ const leftCode = this.generate(left, 'value');
438
+ const rightCode = this.generate(right, 'value');
439
+ return `(${leftCode} !== undefined ? ${leftCode} : ${rightCode})`;
440
+ }
441
+
433
442
  // Always use strict equality (CoffeeScript compatibility)
434
443
  // == → ===, != → !==, === → ===, !== → !==
435
444
  let op = head;
@@ -751,6 +751,7 @@ grammar =
751
751
  o 'Expression && Expression' , '["&&", 1, 3]'
752
752
  o 'Expression || Expression' , '["||", 1, 3]'
753
753
  o 'Expression ?? Expression' , '["??", 1, 3]' # Nullish coalescing
754
+ o 'Expression !? Expression' , '["!?", 1, 3]' # Otherwise operator (undefined-only coalescing)
754
755
  o 'Expression RELATION Expression', '[2, 1, 3]' # in, of, instanceof
755
756
 
756
757
  # Ternary operator (uses SPACE? token = ? with space before it)
@@ -14,7 +14,7 @@ import fs from 'fs'
14
14
  import path from 'path'
15
15
  import { fileURLToPath, pathToFileURL } from 'url'
16
16
 
17
- VERSION = '1.3.0-rip'
17
+ VERSION = '1.3.0'
18
18
 
19
19
  # Token: A terminal symbol that cannot be broken down further
20
20
  class Token
package/src/lexer.js CHANGED
@@ -1756,8 +1756,9 @@ NUMBER = /^0b[01](?:_?[01])*n?|^0o[0-7](?:_?[0-7])*n?|^0x[\da-f](?:_?[\da-f])*n?
1756
1756
  // decimal without support for numeric literal separators for reference:
1757
1757
  // \d*\.?\d+ (?:e[+-]?\d+)?
1758
1758
 
1759
- OPERATOR = /^(?:[-=]>|===|!==|\?\?|=~|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/; // function
1759
+ OPERATOR = /^(?:[-=]>|===|!==|!\?|\?\?|=~|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/; // function
1760
1760
  // Added === and !== for explicit strict equality (compiles same as == and !=)
1761
+ // !? (otherwise operator) must come before ?? and before !=
1761
1762
  // ?? must come before single ? to match correctly
1762
1763
  // regex match operator
1763
1764
  // compound assign / compare / strict equality