@herb-tools/core 0.1.1 → 0.3.0
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/CHANGELOG.md +8 -0
- package/dist/herb-core.browser.js +576 -117
- package/dist/herb-core.browser.js.map +1 -1
- package/dist/herb-core.cjs +581 -117
- package/dist/herb-core.cjs.map +1 -1
- package/dist/herb-core.esm.js +576 -117
- package/dist/herb-core.esm.js.map +1 -1
- package/dist/herb-core.umd.js +581 -117
- package/dist/herb-core.umd.js.map +1 -1
- package/dist/types/errors.d.ts +16 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lex-result.d.ts +13 -8
- package/dist/types/nodes.d.ts +206 -36
- package/dist/types/parse-result.d.ts +4 -4
- package/dist/types/result.d.ts +12 -4
- package/dist/types/visitor.d.ts +34 -9
- package/package.json +2 -11
- package/src/errors.ts +49 -14
- package/src/index.ts +1 -1
- package/src/lex-result.ts +15 -9
- package/src/nodes.ts +713 -95
- package/src/parse-result.ts +7 -5
- package/src/result.ts +14 -6
- package/src/visitor.ts +169 -10
- package/dist/types/ast.d.ts +0 -4
- package/dist/types/error.d.ts +0 -16
- package/dist/types/node.d.ts +0 -27
- package/src/ast.ts +0 -7
- package/src/error.ts +0 -38
- package/src/node.ts +0 -106
package/src/lex-result.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Result } from "./result.js"
|
|
2
|
-
import { TokenList
|
|
2
|
+
import { TokenList } from "./token-list.js"
|
|
3
|
+
import { HerbError } from "./errors.js"
|
|
4
|
+
import { HerbWarning } from "./warning.js"
|
|
5
|
+
|
|
6
|
+
import type { SerializedHerbError } from "./errors.js"
|
|
7
|
+
import type { SerializedHerbWarning } from "./warning.js"
|
|
8
|
+
import type { SerializedTokenList } from "./token-list.js"
|
|
3
9
|
|
|
4
10
|
export type SerializedLexResult = {
|
|
5
11
|
tokens: SerializedTokenList
|
|
6
12
|
source: string
|
|
7
|
-
warnings:
|
|
8
|
-
errors:
|
|
13
|
+
warnings: SerializedHerbWarning[]
|
|
14
|
+
errors: SerializedHerbError[]
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
/**
|
|
@@ -25,8 +31,8 @@ export class LexResult extends Result {
|
|
|
25
31
|
return new LexResult(
|
|
26
32
|
TokenList.from(result.tokens || []),
|
|
27
33
|
result.source,
|
|
28
|
-
result.warnings,
|
|
29
|
-
result.errors,
|
|
34
|
+
result.warnings.map((warning) => HerbWarning.from(warning)),
|
|
35
|
+
result.errors.map((error) => HerbError.from(error)),
|
|
30
36
|
)
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -40,8 +46,8 @@ export class LexResult extends Result {
|
|
|
40
46
|
constructor(
|
|
41
47
|
value: TokenList,
|
|
42
48
|
source: string,
|
|
43
|
-
warnings:
|
|
44
|
-
errors:
|
|
49
|
+
warnings: HerbWarning[] = [],
|
|
50
|
+
errors: HerbError[] = [],
|
|
45
51
|
) {
|
|
46
52
|
super(source, warnings, errors)
|
|
47
53
|
this.value = value
|
|
@@ -51,7 +57,7 @@ export class LexResult extends Result {
|
|
|
51
57
|
* Determines if the lexing was successful.
|
|
52
58
|
* @returns `true` if there are no errors, otherwise `false`.
|
|
53
59
|
*/
|
|
54
|
-
|
|
60
|
+
get successful(): boolean {
|
|
55
61
|
return this.errors.length === 0
|
|
56
62
|
}
|
|
57
63
|
|
|
@@ -59,7 +65,7 @@ export class LexResult extends Result {
|
|
|
59
65
|
* Determines if the lexing failed.
|
|
60
66
|
* @returns `true` if there are errors, otherwise `false`.
|
|
61
67
|
*/
|
|
62
|
-
|
|
68
|
+
get failed(): boolean {
|
|
63
69
|
return this.errors.length > 0
|
|
64
70
|
}
|
|
65
71
|
|