@idfkit/core 0.2.0-rc.1 → 0.2.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/dist/conformance.d.ts +1 -1
- package/dist/conformance.js +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/introspect/describe.d.ts +2 -2
- package/dist/introspect/describe.d.ts.map +1 -1
- package/dist/introspect/describe.js +62 -8
- package/dist/introspect/describe.js.map +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +22 -2
- package/dist/node.js.map +1 -1
- package/dist/parse/idf.d.ts +21 -3
- package/dist/parse/idf.d.ts.map +1 -1
- package/dist/parse/idf.js +158 -5
- package/dist/parse/idf.js.map +1 -1
- package/dist/parse/lexer.d.ts +42 -13
- package/dist/parse/lexer.d.ts.map +1 -1
- package/dist/parse/lexer.js +65 -83
- package/dist/parse/lexer.js.map +1 -1
- package/dist/parse/scan.d.ts +34 -0
- package/dist/parse/scan.d.ts.map +1 -0
- package/dist/parse/scan.js +177 -0
- package/dist/parse/scan.js.map +1 -0
- package/dist/syntax/classify.d.ts +25 -0
- package/dist/syntax/classify.d.ts.map +1 -0
- package/dist/syntax/classify.js +59 -0
- package/dist/syntax/classify.js.map +1 -0
- package/dist/syntax/layer.d.ts +67 -0
- package/dist/syntax/layer.d.ts.map +1 -0
- package/dist/syntax/layer.js +134 -0
- package/dist/syntax/layer.js.map +1 -0
- package/dist/syntax/region.d.ts +73 -0
- package/dist/syntax/region.d.ts.map +1 -0
- package/dist/syntax/region.js +105 -0
- package/dist/syntax/region.js.map +1 -0
- package/dist/syntax/tokens.d.ts +80 -0
- package/dist/syntax/tokens.d.ts.map +1 -0
- package/dist/syntax/tokens.js +140 -0
- package/dist/syntax/tokens.js.map +1 -0
- package/dist/write/idf.d.ts +32 -0
- package/dist/write/idf.d.ts.map +1 -1
- package/dist/write/idf.js +24 -5
- package/dist/write/idf.js.map +1 -1
- package/package.json +4 -4
package/dist/conformance.d.ts
CHANGED
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
* This is not a version number and it is not compared to one. Two installed libraries agree on the
|
|
17
17
|
* formats when they declare the same level, whatever their own versions say (FR-025).
|
|
18
18
|
*/
|
|
19
|
-
export declare const CONFORMANCE_LEVEL = "conformance-2026.
|
|
19
|
+
export declare const CONFORMANCE_LEVEL = "conformance-2026.8";
|
|
20
20
|
//# sourceMappingURL=conformance.d.ts.map
|
package/dist/conformance.js
CHANGED
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
* This is not a version number and it is not compared to one. Two installed libraries agree on the
|
|
17
17
|
* formats when they declare the same level, whatever their own versions say (FR-025).
|
|
18
18
|
*/
|
|
19
|
-
export const CONFORMANCE_LEVEL = 'conformance-2026.
|
|
19
|
+
export const CONFORMANCE_LEVEL = 'conformance-2026.8';
|
|
20
20
|
//# sourceMappingURL=conformance.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,12 @@ export { getIdfVersion, IdfParseError, parseIdf } from './parse/idf.js';
|
|
|
31
31
|
export type { ParseDiagnostic, ParseOptions, ParseResult } from './parse/idf.js';
|
|
32
32
|
export { getEpJsonVersion, parseEpJson } from './parse/epjson.js';
|
|
33
33
|
export type { EpJson } from './parse/epjson.js';
|
|
34
|
+
export { scanIdf } from './syntax/layer.js';
|
|
35
|
+
export type { Statement, SyntaxLayer } from './syntax/layer.js';
|
|
36
|
+
export { classify } from './syntax/classify.js';
|
|
37
|
+
export type { Token, TokenKind } from './syntax/tokens.js';
|
|
38
|
+
export { lineColumnAt, offsetAt } from './syntax/region.js';
|
|
39
|
+
export type { LineColumn, Region } from './syntax/region.js';
|
|
34
40
|
export { writeIdf, writeObject } from './write/idf.js';
|
|
35
41
|
export type { ObjectWriteOptions, WriteIdfOptions } from './write/idf.js';
|
|
36
42
|
export { toEpJson, writeEpJson } from './write/epjson.js';
|
|
@@ -42,5 +48,5 @@ export type { FieldDescription, ObjectDescription } from './introspect/describe.
|
|
|
42
48
|
export { docsUrlForObject, engineeringReferenceUrl, ioReferenceUrl, searchUrl, } from './docs-url/index.js';
|
|
43
49
|
export type { DocsUrl } from './docs-url/index.js';
|
|
44
50
|
export { Schema, SchemaBundle, httpSource } from '@idfkit/schemas';
|
|
45
|
-
export type { BundleSource, SchemaDelta, SlimField, SlimType } from '@idfkit/schemas';
|
|
51
|
+
export type { BundleSource, ProsePool, SchemaDelta, SlimField, SlimType } from '@idfkit/schemas';
|
|
46
52
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EACV,eAAe,EACf,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,YAAY,EAAE,aAA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KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACvD,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC1D,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjF,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACnE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,9 @@ export { CONFORMANCE_LEVEL } from './conformance.js';
|
|
|
27
27
|
export { lex } from './parse/lexer.js';
|
|
28
28
|
export { getIdfVersion, IdfParseError, parseIdf } from './parse/idf.js';
|
|
29
29
|
export { getEpJsonVersion, parseEpJson } from './parse/epjson.js';
|
|
30
|
+
export { scanIdf } from './syntax/layer.js';
|
|
31
|
+
export { classify } from './syntax/classify.js';
|
|
32
|
+
export { lineColumnAt, offsetAt } from './syntax/region.js';
|
|
30
33
|
export { writeIdf, writeObject } from './write/idf.js';
|
|
31
34
|
export { toEpJson, writeEpJson } from './write/epjson.js';
|
|
32
35
|
export { Severity, validateDocument, validateObject } from './validate/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQxC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE5E,8EAA8E;AAC9E,+EAA+E;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGjF,OAAO,EAAE,kBAAkB,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EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,SAAS,GACV,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Schema } from '@idfkit/schemas';
|
|
1
|
+
import type { ProsePool, Schema } from '@idfkit/schemas';
|
|
2
2
|
/**
|
|
3
3
|
* Description of a single field in an EnergyPlus object type.
|
|
4
4
|
*
|
|
@@ -102,5 +102,5 @@ export interface ObjectDescription {
|
|
|
102
102
|
* Python raises `UnknownObjectTypeError`, which has no registered TypeScript
|
|
103
103
|
* counterpart and so must not become a new exported class.
|
|
104
104
|
*/
|
|
105
|
-
export declare function describeObjectType(schema: Schema, objType: string): ObjectDescription;
|
|
105
|
+
export declare function describeObjectType(schema: Schema, objType: string, prose?: ProsePool): ObjectDescription;
|
|
106
106
|
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/introspect/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/introspect/describe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAuB,MAAM,iBAAiB,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,C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AC;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,SAAS,GAChB,iBAAiB,CAmCnB"}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* Python raises `UnknownObjectTypeError`, which has no registered TypeScript
|
|
15
15
|
* counterpart and so must not become a new exported class.
|
|
16
16
|
*/
|
|
17
|
-
export function describeObjectType(schema, objType) {
|
|
17
|
+
export function describeObjectType(schema, objType, prose) {
|
|
18
18
|
const type = schema.require(objType);
|
|
19
19
|
// Exact-cased input resolves to itself, so this matches Python's verbatim
|
|
20
20
|
// echo of the argument for every name Python accepts.
|
|
@@ -24,11 +24,15 @@ export function describeObjectType(schema, objType) {
|
|
|
24
24
|
const required = new Set(requiredFields);
|
|
25
25
|
const extensible = type.x;
|
|
26
26
|
const fieldNames = orderedFieldNames(type);
|
|
27
|
-
const fields = fieldNames.map((name) => describeField(name, properties[name], required.has(name)));
|
|
27
|
+
const fields = fieldNames.map((name) => describeField(name, properties[name], required.has(name), prose));
|
|
28
28
|
return {
|
|
29
29
|
objType: canonical,
|
|
30
|
-
//
|
|
31
|
-
|
|
30
|
+
// Resolved from the pool when one is supplied, and `undefined` otherwise —
|
|
31
|
+
// which is exactly what this returned before the pool existed, so a caller
|
|
32
|
+
// who passes nothing sees no change at all (FR-014). A type with no memo in
|
|
33
|
+
// the source schema also reports `undefined`, in both languages: absence is
|
|
34
|
+
// reported as absence rather than filled with a placeholder.
|
|
35
|
+
memo: lookupProse(type.m, prose),
|
|
32
36
|
fields,
|
|
33
37
|
requiredFields: [...requiredFields],
|
|
34
38
|
hasName: type.anon !== 1,
|
|
@@ -64,7 +68,11 @@ function orderedFieldNames(type) {
|
|
|
64
68
|
// not schema order. `AvailabilityManagerAssignmentList` is the type that shows
|
|
65
69
|
// it — its two extensible fields are declared object-type first and sort
|
|
66
70
|
// name first.
|
|
67
|
-
|
|
71
|
+
// `fo` is the declaration order, recorded by the bundle for the three types
|
|
72
|
+
// whose `f` holds only the name. Without it the fallback below returns the
|
|
73
|
+
// key order of `p`, which `canonical()` sorted for content-addressing, and
|
|
74
|
+
// the reader gets alphabetical order where Python gives declaration order.
|
|
75
|
+
const ordered = names.length > 0 ? names : (type.fo ?? Object.keys(type.p)).slice();
|
|
68
76
|
if (type.x !== undefined) {
|
|
69
77
|
for (const name of type.x.fields) {
|
|
70
78
|
if (!ordered.includes(name))
|
|
@@ -84,7 +92,7 @@ function mergedProperties(type) {
|
|
|
84
92
|
return type.x === undefined ? type.p : { ...type.p, ...type.x.p };
|
|
85
93
|
}
|
|
86
94
|
/** @internal */
|
|
87
|
-
function describeField(name, field, required) {
|
|
95
|
+
function describeField(name, field, required, prose) {
|
|
88
96
|
if (field === undefined) {
|
|
89
97
|
// In the positional order but absent from the schema. Python reaches the
|
|
90
98
|
// same state via `properties.get(field_name, {})`.
|
|
@@ -119,16 +127,62 @@ function describeField(name, field, required) {
|
|
|
119
127
|
required,
|
|
120
128
|
default: field.d,
|
|
121
129
|
units: field.u,
|
|
122
|
-
enumValues: field
|
|
130
|
+
enumValues: acceptedValues(field),
|
|
123
131
|
minimum: collapsedAnyOf ? undefined : field.min,
|
|
124
132
|
maximum: collapsedAnyOf ? undefined : field.max,
|
|
125
133
|
exclusiveMinimum: collapsedAnyOf ? undefined : field.xmin,
|
|
126
134
|
exclusiveMaximum: collapsedAnyOf ? undefined : field.xmax,
|
|
127
|
-
note:
|
|
135
|
+
note: lookupProse(field.n, prose),
|
|
128
136
|
isReference: field.ol !== undefined,
|
|
129
137
|
objectList: field.ol === undefined ? undefined : [...field.ol],
|
|
130
138
|
};
|
|
131
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Resolve a prose index against the pool.
|
|
142
|
+
*
|
|
143
|
+
* Returns `undefined` for a record with no prose, and for every record when no
|
|
144
|
+
* pool was supplied. Out-of-range is `undefined` too rather than a throw: a
|
|
145
|
+
* caller who hands in a pool from a different bundle build gets no prose, which
|
|
146
|
+
* is the same thing they had before, instead of a description that cannot be
|
|
147
|
+
* produced at all.
|
|
148
|
+
*
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
function lookupProse(index, prose) {
|
|
152
|
+
if (index === undefined || prose === undefined)
|
|
153
|
+
return undefined;
|
|
154
|
+
return prose[index];
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The values a field accepts, as Python reports them.
|
|
158
|
+
*
|
|
159
|
+
* Two sources, and until feature 002 this read neither completely:
|
|
160
|
+
*
|
|
161
|
+
* - `e`, the choice list, with the empty string filtered out by the bundle
|
|
162
|
+
* because `e` is what validation checks against. Python keeps the blank, so
|
|
163
|
+
* `eb` records that it was there and it goes back on the front. It is always
|
|
164
|
+
* the front: measured across all 17 schemas, all 21,962 blank-bearing enums
|
|
165
|
+
* carry it at position 0.
|
|
166
|
+
* - `se`, the collapsed `anyOf` string branch, which holds the sentinels.
|
|
167
|
+
* `Autosize` on 10,565 fields and `Autocalculate` on 1,781. Validation has
|
|
168
|
+
* always read it (`validate/validate.ts:543`); this path never did, so
|
|
169
|
+
* `WindowMaterial:Glazing:EquivalentLayer.diffuse_diffuse_solar_transmittance`
|
|
170
|
+
* reported nothing where Python reported `['', 'Autocalculate']`.
|
|
171
|
+
*
|
|
172
|
+
* A field carries one or the other, never both: `se` exists only when the field
|
|
173
|
+
* was an `anyOf`, and `e` is then hoisted from the numeric branch. The 68
|
|
174
|
+
* fields that carry both are the numeric-enum ones, and Python reports the
|
|
175
|
+
* string branch for those, which is what taking `se` first does.
|
|
176
|
+
*
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
function acceptedValues(field) {
|
|
180
|
+
if (field.se !== undefined)
|
|
181
|
+
return [...field.se];
|
|
182
|
+
if (field.e === undefined)
|
|
183
|
+
return undefined;
|
|
184
|
+
return field.eb === 1 ? ['', ...field.e] : [...field.e];
|
|
185
|
+
}
|
|
132
186
|
/**
|
|
133
187
|
* Map the slim storage class back to the epJSON JSON-Schema type string Python
|
|
134
188
|
* reports.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/introspect/describe.ts"],"names":[],"mappings":"AA2FA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/introspect/describe.ts"],"names":[],"mappings":"AA2FA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAAc,EACd,OAAe,EACf,KAAiB;IAEjB,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,0EAA0E;IAC1E,sDAAsD;IACtD,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;IAErD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IAEzC,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1B,MAAM,UAAU,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAuB,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACzD,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CACjE,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,SAAS;QAClB,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,4EAA4E;QAC5E,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;GAuBG;AACH,SAAS,WAAW,CAAC,KAAgB;IACnC,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;QAChB,KAAK,KAAK;YACR,OAAO,OAAO,CAAC;QACjB,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,KAAK,GAAG;YACN,OAAO,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC;QACvD,KAAK,GAAG;YACN,OAAO,QAAQ,CAAC;IACpB,CAAC;AACH,CAAC"}
|
package/dist/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAe,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAY,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAIhE,kFAAkF;AAClF,wBAAgB,OAAO,IAAI,YAAY,CAGtC;AAED,MAAM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writeFile } from 'node:fs/promises';
|
|
|
9
9
|
import { SchemaBundle } from '@idfkit/schemas';
|
|
10
10
|
import { localBundle } from '@idfkit/schemas/node';
|
|
11
11
|
import { getEpJsonVersion, parseEpJson } from './parse/epjson.js';
|
|
12
|
-
import { getIdfVersion, parseIdf } from './parse/idf.js';
|
|
12
|
+
import { getIdfVersion, IdfParseError, parseIdf, } from './parse/idf.js';
|
|
13
13
|
import { resolveVersion } from './versions.js';
|
|
14
14
|
import { writeEpJson } from './write/epjson.js';
|
|
15
15
|
import { writeIdf } from './write/idf.js';
|
|
@@ -51,7 +51,27 @@ export async function loadIdfWithDiagnostics(path, options = {}) {
|
|
|
51
51
|
// names) that are not valid utf-8 and would otherwise decode to U+FFFD.
|
|
52
52
|
const text = await readFile(path, 'latin1');
|
|
53
53
|
const schema = await schemaFor(getIdfVersion(text), options);
|
|
54
|
-
|
|
54
|
+
// `parseIdf` takes text and cannot know where the text came from, so the path is attached here,
|
|
55
|
+
// at the one place that does. Python's parser opens the file itself and fills `filepath` from
|
|
56
|
+
// its own constructor argument; this is the same field reaching a caller by the only route this
|
|
57
|
+
// library has (FR-033).
|
|
58
|
+
//
|
|
59
|
+
// Stamped on both paths: the findings that stop the parse arrive on the error, and the ones that
|
|
60
|
+
// do not arrive in the result. Neither is useful without saying which file it was.
|
|
61
|
+
try {
|
|
62
|
+
const result = parseIdf(text, schema, options);
|
|
63
|
+
return { ...result, diagnostics: result.diagnostics.map((d) => withPath(d, path)) };
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (error instanceof IdfParseError) {
|
|
67
|
+
throw new IdfParseError(error.diagnostics.map((d) => withPath(d, path)));
|
|
68
|
+
}
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Attach the source path to a finding, leaving one that already names a file alone. */
|
|
73
|
+
function withPath(diagnostic, path) {
|
|
74
|
+
return diagnostic.filepath === undefined ? { ...diagnostic, filepath: path } : diagnostic;
|
|
55
75
|
}
|
|
56
76
|
/** Read and parse an epJSON file. */
|
|
57
77
|
export async function loadEpJson(path, options = {}) {
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAe,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAe,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EACL,aAAa,EACb,aAAa,EACb,QAAQ,GAIT,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAwB,MAAM,gBAAgB,CAAC;AAEhE,IAAI,aAAuC,CAAC;AAE5C,kFAAkF;AAClF,MAAM,UAAU,OAAO;IACrB,aAAa,KAAK,WAAW,EAAE,CAAC;IAChC,OAAO,aAAa,CAAC;AACvB,CAAC;AASD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,QAA4B,EAC5B,UAAuB,EAAE;IAEzB,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Q,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC/D,CAAC;AAED,0CAA0C;AAC1C,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,QAAwB,EACxB,IAAY,EACZ,UAA8B,EAAE;IAEhC,MAAM,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/parse/idf.d.ts
CHANGED
|
@@ -3,8 +3,14 @@ import { IdfDocument } from '../document.js';
|
|
|
3
3
|
import type { AnyTypeMap, UntypedMap } from '../typemap.js';
|
|
4
4
|
import { type LexDiagnostic } from './lexer.js';
|
|
5
5
|
export interface ParseDiagnostic extends LexDiagnostic {
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Object name the problem occurred in, when known.
|
|
8
|
+
*
|
|
9
|
+
* Python spells this `obj_name`, and `typeName` against its `obj_type` is the same idiomatic
|
|
10
|
+
* casing difference the naming register already records. Not a gap, and not renamed: spending a
|
|
11
|
+
* rename to make the register harder to read is the wrong trade.
|
|
12
|
+
*/
|
|
13
|
+
objectName?: string;
|
|
8
14
|
}
|
|
9
15
|
export interface ParseOptions {
|
|
10
16
|
/**
|
|
@@ -31,7 +37,19 @@ export declare function parseIdf<M extends AnyTypeMap = UntypedMap>(text: string
|
|
|
31
37
|
export declare class IdfParseError extends Error {
|
|
32
38
|
readonly line: number;
|
|
33
39
|
readonly typeName: string | undefined;
|
|
34
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Every finding that stopped the parse.
|
|
42
|
+
*
|
|
43
|
+
* This error carried `line` and `typeName` from a single diagnostic, flattened into fields, and
|
|
44
|
+
* a caller who wanted the rest had nowhere to look. Python's `IDFParseError` has always carried
|
|
45
|
+
* the collection; this is the half of the difference that was real.
|
|
46
|
+
*
|
|
47
|
+
* `line` and `typeName` still resolve to the first finding's values, so no existing caller
|
|
48
|
+
* breaks (FR-013, FR-014). They are a convenience over `diagnostics[0]` rather than a second
|
|
49
|
+
* source of truth.
|
|
50
|
+
*/
|
|
51
|
+
readonly diagnostics: readonly ParseDiagnostic[];
|
|
52
|
+
constructor(diagnostic: ParseDiagnostic | readonly ParseDiagnostic[]);
|
|
35
53
|
}
|
|
36
54
|
/**
|
|
37
55
|
* Read the version identifier from IDF text without a schema.
|
package/dist/parse/idf.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idf.d.ts","sourceRoot":"","sources":["../../src/parse/idf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAO,KAAK,aAAa,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"idf.d.ts","sourceRoot":"","sources":["../../src/parse/idf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAO,KAAK,aAAa,EAAkB,MAAM,YAAY,CAAC;AAGrE,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mDAAmD;IACnD,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,IAAI,CAAC;CACtD;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAC5D,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACzB,WAAW,EAAE,eAAe,EAAE,CAAC;CAChC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EACxD,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,YAAiB,GACzB,WAAW,CAAC,CAAC,CAAC,CAoFhB;AAqMD,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,WAAW,EAAE,SAAS,eAAe,EAAE,CAAC;gBAErC,UAAU,EAAE,eAAe,GAAG,SAAS,eAAe,EAAE;CAcrE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAc9D"}
|
package/dist/parse/idf.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IdfDocument } from '../document.js';
|
|
2
2
|
import { lex } from './lexer.js';
|
|
3
|
+
import { scan } from './scan.js';
|
|
3
4
|
/**
|
|
4
5
|
* Parse IDF text into a document.
|
|
5
6
|
*
|
|
@@ -18,6 +19,19 @@ export function parseIdf(text, schema, options = {}) {
|
|
|
18
19
|
diagnostics.push(diagnostic);
|
|
19
20
|
options.onDiagnostic?.(diagnostic);
|
|
20
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Record a finding that does NOT stop the parse, whatever `strict` says.
|
|
24
|
+
*
|
|
25
|
+
* `report` throws under `strict`, which is right for a finding that leaves nothing to return: an
|
|
26
|
+
* object whose type is unknown cannot be built. A value of the wrong KIND is different. The
|
|
27
|
+
* object is built, the document is complete, and a caller reading strictly gets exactly what they
|
|
28
|
+
* got before this finding existed (FR-014). Routing it through `report` made a strict parse fail
|
|
29
|
+
* on files that used to load, which is the opposite of additive.
|
|
30
|
+
*/
|
|
31
|
+
const note = (diagnostic) => {
|
|
32
|
+
diagnostics.push(diagnostic);
|
|
33
|
+
options.onDiagnostic?.(diagnostic);
|
|
34
|
+
};
|
|
21
35
|
const raw = lex(text, { onDiagnostic: report });
|
|
22
36
|
const document = new IdfDocument(schema);
|
|
23
37
|
for (const object of raw) {
|
|
@@ -26,27 +40,57 @@ export function parseIdf(text, schema, options = {}) {
|
|
|
26
40
|
report({
|
|
27
41
|
message: `Unknown object type "${object.typeName}" in EnergyPlus ${schema.version}`,
|
|
28
42
|
line: object.line,
|
|
43
|
+
column: object.column,
|
|
29
44
|
typeName: object.typeName,
|
|
45
|
+
// Best effort, and the same rule Python's `_extract_object_name` uses: the first positional
|
|
46
|
+
// value is the name for every named type, and is a real field for the anonymous ones. An
|
|
47
|
+
// unknown type has no definition to tell the two apart, so the raw first value is what there
|
|
48
|
+
// is. Declaring `objectName` and never filling it would make the field a claim rather than a
|
|
49
|
+
// value.
|
|
50
|
+
objectName: object.values[0],
|
|
51
|
+
code: 'UnknownObjectType',
|
|
30
52
|
});
|
|
31
53
|
continue;
|
|
32
54
|
}
|
|
33
55
|
const definition = schema.require(canonical);
|
|
34
56
|
try {
|
|
35
|
-
const
|
|
57
|
+
const invalid = [];
|
|
58
|
+
const { name, values } = interpret(definition, object, invalid);
|
|
36
59
|
document.addRaw(canonical, definition.anon === 1 ? null : name, values);
|
|
60
|
+
// Reported after the object is built, never instead of building it: a value of the wrong
|
|
61
|
+
// kind does not stop the parse, so a caller reading strictly gets the document they always
|
|
62
|
+
// got. This adds a finding where there was silence, and nothing else.
|
|
63
|
+
//
|
|
64
|
+
// Positioned at the offending FIELD rather than at the object, because that is what makes it
|
|
65
|
+
// useful. The shape this catches is a missing semicolon swallowing the object below, and the
|
|
66
|
+
// object's own first line is nowhere near the damage.
|
|
67
|
+
for (const { field, index, value } of invalid) {
|
|
68
|
+
if (stringIsLegal(definition, field, value))
|
|
69
|
+
continue;
|
|
70
|
+
note({
|
|
71
|
+
message: `Field "${field}" expects a number, got "${value}"`,
|
|
72
|
+
line: fieldLine(text, object, index),
|
|
73
|
+
typeName: canonical,
|
|
74
|
+
objectName: definition.anon === 1 ? undefined : object.values[0],
|
|
75
|
+
code: 'InvalidField',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
37
78
|
}
|
|
38
79
|
catch (error) {
|
|
39
80
|
report({
|
|
40
81
|
message: error instanceof Error ? error.message : String(error),
|
|
41
82
|
line: object.line,
|
|
83
|
+
column: object.column,
|
|
42
84
|
typeName: canonical,
|
|
85
|
+
objectName: definition.anon === 1 ? undefined : object.values[0],
|
|
86
|
+
code: 'ParseError',
|
|
43
87
|
});
|
|
44
88
|
}
|
|
45
89
|
}
|
|
46
90
|
return { document, diagnostics };
|
|
47
91
|
}
|
|
48
92
|
/** Map positional IDF values onto named schema fields. */
|
|
49
|
-
function interpret(definition, object) {
|
|
93
|
+
function interpret(definition, object, invalid) {
|
|
50
94
|
const order = definition.f;
|
|
51
95
|
const named = definition.anon !== 1 && order[0] === 'name';
|
|
52
96
|
const values = {};
|
|
@@ -61,6 +105,7 @@ function interpret(definition, object) {
|
|
|
61
105
|
}
|
|
62
106
|
const fixed = named ? order.slice(1) : order;
|
|
63
107
|
for (const field of fixed) {
|
|
108
|
+
const index = cursor;
|
|
64
109
|
const raw = object.values[cursor++];
|
|
65
110
|
if (raw === undefined)
|
|
66
111
|
break;
|
|
@@ -69,6 +114,11 @@ function interpret(definition, object) {
|
|
|
69
114
|
const coerced = coerce(definition, field, raw);
|
|
70
115
|
if (coerced !== undefined)
|
|
71
116
|
values[field] = coerced;
|
|
117
|
+
// A numeric field that kept its string is a coercion that fell through. Whether that is
|
|
118
|
+
// actually wrong needs the schema and is asked on the reporting path, which runs almost never.
|
|
119
|
+
if (invalid !== undefined && coerced === raw && isNumericField(definition, field)) {
|
|
120
|
+
invalid.push({ field, index, value: raw });
|
|
121
|
+
}
|
|
72
122
|
}
|
|
73
123
|
// Everything past the fixed fields belongs to the extensible section, read in
|
|
74
124
|
// repeats of the group width. A trailing partial group is kept rather than
|
|
@@ -107,6 +157,89 @@ function interpret(definition, object) {
|
|
|
107
157
|
}
|
|
108
158
|
return { name, values };
|
|
109
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* The two sizing sentinels, accepted in ANY numeric field.
|
|
162
|
+
*
|
|
163
|
+
* Not read from the field's own `se` branch, deliberately. The schema EnergyPlus ships is NARROWER
|
|
164
|
+
* than the engine it ships with, and its own example files prove it. Both of these declare a string
|
|
165
|
+
* branch naming exactly one sentinel, and the shipped files use the other one:
|
|
166
|
+
*
|
|
167
|
+
* `PlantLoop.plant_loop_volume` allows `Autocalculate`; 28 files write `Autosize`.
|
|
168
|
+
* `AirTerminal:SingleDuct:VAV:Reheat.maximum_flow_fraction_during_reheat` allows `Autosize`;
|
|
169
|
+
* 673 files write `Autocalculate`.
|
|
170
|
+
*
|
|
171
|
+
* The schema is well formed: across all 17 bundled versions no field declares a non-numeric string
|
|
172
|
+
* default on a numeric type with no string branch. It is simply stricter about WHICH sentinel
|
|
173
|
+
* belongs where than EnergyPlus is. Reading each field's branch literally produced 3,775 findings
|
|
174
|
+
* across the 760 example files of one release, every one against a model EnergyPlus reads happily.
|
|
175
|
+
*
|
|
176
|
+
* A parse finding says the value is not of the kind the field takes. Whether the exact sentinel is
|
|
177
|
+
* the one THIS field documents is a schema question, and `validateObject` already answers it.
|
|
178
|
+
*/
|
|
179
|
+
const SIZING_SENTINELS = new Set(['autosize', 'autocalculate']);
|
|
180
|
+
/** @internal */
|
|
181
|
+
function isNumericField(definition, field) {
|
|
182
|
+
const kind = definition.p[field]?.t;
|
|
183
|
+
return kind === 'n' || kind === 'i';
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Whether a string the numeric coercion rejected is legal for this field anyway.
|
|
187
|
+
*
|
|
188
|
+
* Consulted only when coercion has already failed, so the parse path pays nothing for it.
|
|
189
|
+
*
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
function stringIsLegal(definition, field, value) {
|
|
193
|
+
if (SIZING_SENTINELS.has(value.toLowerCase()))
|
|
194
|
+
return true;
|
|
195
|
+
const slim = definition.p[field];
|
|
196
|
+
if (slim === undefined)
|
|
197
|
+
return true;
|
|
198
|
+
// `auto` marks a collapsed `anyOf`. Without an `se` the string branch declared no enum, so any
|
|
199
|
+
// string satisfies it; with one, only its members do.
|
|
200
|
+
if (slim.se === undefined)
|
|
201
|
+
return slim.auto === 1;
|
|
202
|
+
const folded = value.toLowerCase();
|
|
203
|
+
return slim.se.some((allowed) => allowed.toLowerCase() === folded);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The 1-based line a field sits on, found by rescanning the statement from its own offset.
|
|
207
|
+
*
|
|
208
|
+
* The lexer records one offset per object rather than a line per field, because a finding about a
|
|
209
|
+
* field is rare and an array per object is not. This is the rescan that offset exists for, and it
|
|
210
|
+
* runs only while a finding is being built.
|
|
211
|
+
*
|
|
212
|
+
* The rescan goes through the shared scanner, so "step over the comment between a separator and
|
|
213
|
+
* its value" is the rule the lexer itself followed rather than a second copy of it. A field's
|
|
214
|
+
* comma is routinely followed by `!- Field Name` on the same line, and a helper that stopped at
|
|
215
|
+
* the `!` would report the line the PREVIOUS value sits on, one too early.
|
|
216
|
+
*
|
|
217
|
+
* `index` counts into `RawObject.values`, which has already had the type name shifted off, so the
|
|
218
|
+
* field wanted is the scanner's `index + 1`: the comma that ends `Building,` is what puts
|
|
219
|
+
* `values[0]` on the line after it. The scan stops at that field, or at the end of the statement
|
|
220
|
+
* when the statement has fewer fields than the finding names, in which case the object's own line
|
|
221
|
+
* is the best answer available.
|
|
222
|
+
*
|
|
223
|
+
* @internal
|
|
224
|
+
*/
|
|
225
|
+
function fieldLine(text, object, index) {
|
|
226
|
+
if (object.offset === undefined)
|
|
227
|
+
return object.line;
|
|
228
|
+
const wanted = index + 1;
|
|
229
|
+
let line = object.line;
|
|
230
|
+
scan(text, {
|
|
231
|
+
fieldEnd(field, _start, _end, valueLine) {
|
|
232
|
+
if (field < wanted)
|
|
233
|
+
return;
|
|
234
|
+
line = valueLine;
|
|
235
|
+
return false;
|
|
236
|
+
},
|
|
237
|
+
statementEnd() {
|
|
238
|
+
return false;
|
|
239
|
+
},
|
|
240
|
+
}, { from: object.offset, line: object.line, column: object.column });
|
|
241
|
+
return line;
|
|
242
|
+
}
|
|
110
243
|
function coerce(definition, field, raw) {
|
|
111
244
|
return coerceValue(definition.p[field]?.t, raw);
|
|
112
245
|
}
|
|
@@ -137,11 +270,31 @@ function coerceValue(kind, raw) {
|
|
|
137
270
|
export class IdfParseError extends Error {
|
|
138
271
|
line;
|
|
139
272
|
typeName;
|
|
273
|
+
/**
|
|
274
|
+
* Every finding that stopped the parse.
|
|
275
|
+
*
|
|
276
|
+
* This error carried `line` and `typeName` from a single diagnostic, flattened into fields, and
|
|
277
|
+
* a caller who wanted the rest had nowhere to look. Python's `IDFParseError` has always carried
|
|
278
|
+
* the collection; this is the half of the difference that was real.
|
|
279
|
+
*
|
|
280
|
+
* `line` and `typeName` still resolve to the first finding's values, so no existing caller
|
|
281
|
+
* breaks (FR-013, FR-014). They are a convenience over `diagnostics[0]` rather than a second
|
|
282
|
+
* source of truth.
|
|
283
|
+
*/
|
|
284
|
+
diagnostics;
|
|
140
285
|
constructor(diagnostic) {
|
|
141
|
-
|
|
286
|
+
const diagnostics = Array.isArray(diagnostic)
|
|
287
|
+
? diagnostic
|
|
288
|
+
: [diagnostic];
|
|
289
|
+
const first = diagnostics[0];
|
|
290
|
+
if (first === undefined) {
|
|
291
|
+
throw new TypeError('IdfParseError needs at least one diagnostic');
|
|
292
|
+
}
|
|
293
|
+
super(`${first.message} (line ${first.line})`);
|
|
142
294
|
this.name = 'IdfParseError';
|
|
143
|
-
this.line =
|
|
144
|
-
this.typeName =
|
|
295
|
+
this.line = first.line;
|
|
296
|
+
this.typeName = first.typeName;
|
|
297
|
+
this.diagnostics = Object.freeze([...diagnostics]);
|
|
145
298
|
}
|
|
146
299
|
}
|
|
147
300
|
/**
|
package/dist/parse/idf.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idf.js","sourceRoot":"","sources":["../../src/parse/idf.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,GAAG,EAAsC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"idf.js","sourceRoot":"","sources":["../../src/parse/idf.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,OAAO,EAAE,GAAG,EAAsC,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA4BjC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAY,EACZ,MAAc,EACd,UAAwB,EAAE;IAE1B,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC;IACtC,MAAM,WAAW,GAAsB,EAAE,CAAC;IAE1C,MAAM,MAAM,GAAG,CAAC,UAA2B,EAAQ,EAAE;QACnD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;QACtC,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF;;;;;;;;OAQG;IACH,MAAM,IAAI,GAAG,CAAC,UAA2B,EAAQ,EAAE;QACjD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7B,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,MAA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