simplex-lang 0.0.3 → 0.0.5

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/compiler.ts CHANGED
@@ -521,7 +521,7 @@ export function compile<Data = Record<string, unknown>, Globals = null>(
521
521
  try {
522
522
  return func(data)
523
523
  } catch (err) {
524
- assert.ok(err instanceof Error)
524
+ if (err instanceof Error === false) throw err
525
525
 
526
526
  const stackRows = err.stack?.split('\n').map(row => row.trim())
527
527
 
@@ -557,7 +557,9 @@ export function compile<Data = Record<string, unknown>, Globals = null>(
557
557
  offsets
558
558
  )
559
559
 
560
- throw new ExpressionError(err, errorLocation)
560
+ throw new ExpressionError(err.message, expression, errorLocation, {
561
+ cause: err
562
+ })
561
563
  }
562
564
  }
563
565
  }
package/src/errors.ts CHANGED
@@ -3,10 +3,12 @@ import { typeOf } from './tools/index.js'
3
3
 
4
4
  export class ExpressionError extends Error {
5
5
  constructor(
6
- error: Error,
7
- public location: Location | null
6
+ message: string,
7
+ public expression: string,
8
+ public location: Location | null,
9
+ options?: ErrorOptions
8
10
  ) {
9
- super(error.message, { cause: error })
11
+ super(message, options)
10
12
  }
11
13
  }
12
14
 
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from './compiler.js'
2
2
  export * from './errors.js'
3
3
  export * from './simplex-tree.js'
4
4
  export * from './tools/index.js'
5
+ export * from './version.js'
@@ -71,6 +71,7 @@ export type MemberExpression =
71
71
  | {
72
72
  type: 'MemberExpression'
73
73
  computed: false
74
+ extension: boolean
74
75
  object: IdentifierExpression | ObjectExpression | ArrayExpression
75
76
  property: IdentifierExpression
76
77
  location: Location
package/src/simplex.peggy CHANGED
@@ -474,12 +474,17 @@ MemberExpression
474
474
  tail:(
475
475
  __ "[" __ property:Expression __ "]" {
476
476
  return {
477
- property: property, computed: true, location: getLocation(location())
477
+ property: property, computed: true, extension: false, location: getLocation(location())
478
478
  };
479
479
  }
480
480
  / __ "." __ property:IdentifierName {
481
481
  return {
482
- property: property, computed: false, location: getLocation(location())
482
+ property: property, computed: false, extension: false, location: getLocation(location())
483
+ };
484
+ }
485
+ / __ "::" __ property:IdentifierName {
486
+ return {
487
+ property: property, computed: false, extension: true, location: getLocation(location())
483
488
  };
484
489
  }
485
490
  )*
@@ -490,6 +495,7 @@ MemberExpression
490
495
  object: result,
491
496
  property: element.property,
492
497
  computed: element.computed,
498
+ extension: element.extension,
493
499
  location: getLocation(location())
494
500
  };
495
501
  }, head);
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const version = '0.0.5'