@helios-lang/compiler-utils
Advanced tools
Comparing version 0.1.55 to 0.1.56
{ | ||
"name": "@helios-lang/compiler-utils", | ||
"version": "0.1.55", | ||
"version": "0.1.56", | ||
"description": "Helios language compiler library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -11,2 +11,25 @@ /** | ||
/** | ||
* @readonly | ||
* @type {CompilerErrorKind} | ||
*/ | ||
kind | ||
/** | ||
* @readonly | ||
* @type {Site} | ||
*/ | ||
site | ||
/** | ||
* @readonly | ||
* @type {string} | ||
* */ | ||
originalMessage | ||
/** | ||
* @type {CompilerError[] | null} | ||
*/ | ||
otherErrors | ||
/** | ||
* @param {CompilerErrorKind} kind | ||
@@ -21,2 +44,3 @@ * @param {Site} site | ||
this.originalMessage = msg | ||
this.otherErrors = null | ||
} | ||
@@ -23,0 +47,0 @@ |
@@ -28,5 +28,7 @@ import { CompilerError } from "./CompilerError.js" | ||
if (this.errors.length > 0) { | ||
throw this.errors[0] | ||
const [firstError, ...others] = this.errors | ||
firstError.otherErrors = others | ||
throw firstError | ||
} | ||
} | ||
} |
@@ -44,3 +44,8 @@ import { None, isNone, isSome } from "@helios-lang/type-utils" | ||
/** | ||
* @readonly | ||
* @type {string | null} | ||
*/ | ||
error | ||
/** | ||
* @param {string} kind - "(", "[" or "{" | ||
@@ -52,5 +57,10 @@ * @param {F[]} fields | ||
constructor(kind, fields, separators, site = TokenSite.dummy()) { | ||
if (separators.length != Math.max(fields.length - 1, 0)) { | ||
const expectCount = Math.max(fields.length - 1, 0) | ||
this.error = null | ||
if (separators.length > expectCount) { | ||
const separatorType = separators[0].value | ||
this.error = `'${kind}' group: excess '${separatorType}' - expected ${expectCount}, got ${separators.length}` | ||
} else if (separators.length != expectCount) { | ||
throw new Error( | ||
`expected ${Math.max(fields.length - 1, 0)}, got ${separators.length}` | ||
`expected ${expectCount}, got ${separators.length}` | ||
) | ||
@@ -57,0 +67,0 @@ } |
@@ -857,4 +857,4 @@ import { encodeUtf8, hexToBytes } from "@helios-lang/codec-utils" | ||
if (separators.length > 0 && separators.length >= fields.length) { | ||
this.addSyntaxError(separators[0].site, `trailing comma`) | ||
} | ||
this.addSyntaxError(separators[separators.length-1].site, `trailing comma`) | ||
} | ||
@@ -869,3 +869,7 @@ const groupSite = new TokenSite( | ||
return new Group(open.value, fields, separators, groupSite) | ||
const group = new Group(open.value, fields, separators, groupSite) | ||
if (group.error) { | ||
this.addSyntaxError(group.site, group.error) | ||
} | ||
return group | ||
} | ||
@@ -917,3 +921,5 @@ | ||
const group = this.buildGroup(open, current.concat([t])) | ||
if (group.error) { | ||
this.addSyntaxError(group.site, group.error) | ||
} | ||
current = stack.pop() ?? [] | ||
@@ -920,0 +926,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137455
4200