@idfkit/core 0.2.0-rc.1 → 0.2.0-rc.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.
- package/dist/conformance.d.ts +1 -1
- package/dist/conformance.js +1 -1
- package/dist/introspect/describe.d.ts +12 -1
- package/dist/introspect/describe.d.ts.map +1 -1
- package/dist/introspect/describe.js +62 -24
- 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 +178 -5
- package/dist/parse/idf.js.map +1 -1
- package/dist/parse/lexer.d.ts +36 -0
- package/dist/parse/lexer.d.ts.map +1 -1
- package/dist/parse/lexer.js +49 -2
- package/dist/parse/lexer.js.map +1 -1
- 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
|
|
@@ -102,5 +102,16 @@ 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
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The schema's explanatory prose, loaded on demand.
|
|
107
|
+
*
|
|
108
|
+
* A plain array of strings, indexed by `SlimType.m` and `SlimField.n`. It is
|
|
109
|
+
* passed in rather than reached for, and that is deliberate: reading it is
|
|
110
|
+
* asynchronous, `describeObjectType` is synchronous, and making the function
|
|
111
|
+
* async to fetch a file most callers do not want would be a breaking change
|
|
112
|
+
* serving the minority. Loading it is the caller's step, and its cost is
|
|
113
|
+
* visible at the call site instead of hidden inside a description.
|
|
114
|
+
*/
|
|
115
|
+
export type ProsePool = readonly string[];
|
|
116
|
+
export declare function describeObjectType(schema: Schema, objType: string, prose?: ProsePool): ObjectDescription;
|
|
106
117
|
//# 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;AAEnE;;;;;;;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,CAAC;IACvC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC9C,uCAAuC;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,G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AAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,uDAAuD;IACvD,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;GAeG;AACH;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,MAAM,EAAE,CAAC;AAE1C,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,SAAS,GAChB,iBAAiB,CAmCnB"}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Describe an EnergyPlus object type: its fields, their order, and their
|
|
3
|
-
* constraints.
|
|
4
|
-
*
|
|
5
|
-
* Synchronous and pure, like the rest of `@idfkit/core`'s root entry: the
|
|
6
|
-
* schema is already in memory, and this only reads it.
|
|
7
|
-
*
|
|
8
|
-
* Ports `idfkit.introspection.describe_object_type`. Where the slim schema
|
|
9
|
-
* cannot reproduce Python exactly the loss is recorded in a comment at the
|
|
10
|
-
* point it happens rather than papered over with a plausible substitute.
|
|
11
|
-
*
|
|
12
|
-
* @throws If `objType` is not defined in this schema version. The message is
|
|
13
|
-
* the one `Schema.require` already produces everywhere else in the package;
|
|
14
|
-
* Python raises `UnknownObjectTypeError`, which has no registered TypeScript
|
|
15
|
-
* counterpart and so must not become a new exported class.
|
|
16
|
-
*/
|
|
17
|
-
export function describeObjectType(schema, objType) {
|
|
1
|
+
export function describeObjectType(schema, objType, prose) {
|
|
18
2
|
const type = schema.require(objType);
|
|
19
3
|
// Exact-cased input resolves to itself, so this matches Python's verbatim
|
|
20
4
|
// echo of the argument for every name Python accepts.
|
|
@@ -24,11 +8,15 @@ export function describeObjectType(schema, objType) {
|
|
|
24
8
|
const required = new Set(requiredFields);
|
|
25
9
|
const extensible = type.x;
|
|
26
10
|
const fieldNames = orderedFieldNames(type);
|
|
27
|
-
const fields = fieldNames.map((name) => describeField(name, properties[name], required.has(name)));
|
|
11
|
+
const fields = fieldNames.map((name) => describeField(name, properties[name], required.has(name), prose));
|
|
28
12
|
return {
|
|
29
13
|
objType: canonical,
|
|
30
|
-
//
|
|
31
|
-
|
|
14
|
+
// Resolved from the pool when one is supplied, and `undefined` otherwise —
|
|
15
|
+
// which is exactly what this returned before the pool existed, so a caller
|
|
16
|
+
// who passes nothing sees no change at all (FR-014). A type with no memo in
|
|
17
|
+
// the source schema also reports `undefined`, in both languages: absence is
|
|
18
|
+
// reported as absence rather than filled with a placeholder.
|
|
19
|
+
memo: lookupProse(type.m, prose),
|
|
32
20
|
fields,
|
|
33
21
|
requiredFields: [...requiredFields],
|
|
34
22
|
hasName: type.anon !== 1,
|
|
@@ -64,7 +52,11 @@ function orderedFieldNames(type) {
|
|
|
64
52
|
// not schema order. `AvailabilityManagerAssignmentList` is the type that shows
|
|
65
53
|
// it — its two extensible fields are declared object-type first and sort
|
|
66
54
|
// name first.
|
|
67
|
-
|
|
55
|
+
// `fo` is the declaration order, recorded by the bundle for the three types
|
|
56
|
+
// whose `f` holds only the name. Without it the fallback below returns the
|
|
57
|
+
// key order of `p`, which `canonical()` sorted for content-addressing, and
|
|
58
|
+
// the reader gets alphabetical order where Python gives declaration order.
|
|
59
|
+
const ordered = names.length > 0 ? names : (type.fo ?? Object.keys(type.p)).slice();
|
|
68
60
|
if (type.x !== undefined) {
|
|
69
61
|
for (const name of type.x.fields) {
|
|
70
62
|
if (!ordered.includes(name))
|
|
@@ -84,7 +76,7 @@ function mergedProperties(type) {
|
|
|
84
76
|
return type.x === undefined ? type.p : { ...type.p, ...type.x.p };
|
|
85
77
|
}
|
|
86
78
|
/** @internal */
|
|
87
|
-
function describeField(name, field, required) {
|
|
79
|
+
function describeField(name, field, required, prose) {
|
|
88
80
|
if (field === undefined) {
|
|
89
81
|
// In the positional order but absent from the schema. Python reaches the
|
|
90
82
|
// same state via `properties.get(field_name, {})`.
|
|
@@ -119,16 +111,62 @@ function describeField(name, field, required) {
|
|
|
119
111
|
required,
|
|
120
112
|
default: field.d,
|
|
121
113
|
units: field.u,
|
|
122
|
-
enumValues: field
|
|
114
|
+
enumValues: acceptedValues(field),
|
|
123
115
|
minimum: collapsedAnyOf ? undefined : field.min,
|
|
124
116
|
maximum: collapsedAnyOf ? undefined : field.max,
|
|
125
117
|
exclusiveMinimum: collapsedAnyOf ? undefined : field.xmin,
|
|
126
118
|
exclusiveMaximum: collapsedAnyOf ? undefined : field.xmax,
|
|
127
|
-
note:
|
|
119
|
+
note: lookupProse(field.n, prose),
|
|
128
120
|
isReference: field.ol !== undefined,
|
|
129
121
|
objectList: field.ol === undefined ? undefined : [...field.ol],
|
|
130
122
|
};
|
|
131
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Resolve a prose index against the pool.
|
|
126
|
+
*
|
|
127
|
+
* Returns `undefined` for a record with no prose, and for every record when no
|
|
128
|
+
* pool was supplied. Out-of-range is `undefined` too rather than a throw: a
|
|
129
|
+
* caller who hands in a pool from a different bundle build gets no prose, which
|
|
130
|
+
* is the same thing they had before, instead of a description that cannot be
|
|
131
|
+
* produced at all.
|
|
132
|
+
*
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
function lookupProse(index, prose) {
|
|
136
|
+
if (index === undefined || prose === undefined)
|
|
137
|
+
return undefined;
|
|
138
|
+
return prose[index];
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The values a field accepts, as Python reports them.
|
|
142
|
+
*
|
|
143
|
+
* Two sources, and until feature 002 this read neither completely:
|
|
144
|
+
*
|
|
145
|
+
* - `e`, the choice list, with the empty string filtered out by the bundle
|
|
146
|
+
* because `e` is what validation checks against. Python keeps the blank, so
|
|
147
|
+
* `eb` records that it was there and it goes back on the front. It is always
|
|
148
|
+
* the front: measured across all 17 schemas, all 21,962 blank-bearing enums
|
|
149
|
+
* carry it at position 0.
|
|
150
|
+
* - `se`, the collapsed `anyOf` string branch, which holds the sentinels.
|
|
151
|
+
* `Autosize` on 10,565 fields and `Autocalculate` on 1,781. Validation has
|
|
152
|
+
* always read it (`validate/validate.ts:543`); this path never did, so
|
|
153
|
+
* `WindowMaterial:Glazing:EquivalentLayer.diffuse_diffuse_solar_transmittance`
|
|
154
|
+
* reported nothing where Python reported `['', 'Autocalculate']`.
|
|
155
|
+
*
|
|
156
|
+
* A field carries one or the other, never both: `se` exists only when the field
|
|
157
|
+
* was an `anyOf`, and `e` is then hoisted from the numeric branch. The 68
|
|
158
|
+
* fields that carry both are the numeric-enum ones, and Python reports the
|
|
159
|
+
* string branch for those, which is what taking `se` first does.
|
|
160
|
+
*
|
|
161
|
+
* @internal
|
|
162
|
+
*/
|
|
163
|
+
function acceptedValues(field) {
|
|
164
|
+
if (field.se !== undefined)
|
|
165
|
+
return [...field.se];
|
|
166
|
+
if (field.e === undefined)
|
|
167
|
+
return undefined;
|
|
168
|
+
return field.eb === 1 ? ['', ...field.e] : [...field.e];
|
|
169
|
+
}
|
|
132
170
|
/**
|
|
133
171
|
* Map the slim storage class back to the epJSON JSON-Schema type string Python
|
|
134
172
|
* reports.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/introspect/describe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/introspect/describe.ts"],"names":[],"mappings":"AAuHA,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,IA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AAU,GAAG,UAAU,EAChE,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAIzB;AAED,uCAAuC;AACvC,wBAAsB,OAAO,CAAC,CAAC,SAAS,UAAU,EAChD,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,0CAA0C;AAC1C,wBAAsB,UAAU,CAAC,CAAC,SAAS,UAAU,EACnD,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
package/dist/node.js
CHANGED
|
@@ -9,7 +9,7 @@ import { readFile, 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,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AAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;AAC5F,CAAC;AAED,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,UAAuB,EAAE;IAEzB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IAChE,OAAO,WAAW,CAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,uCAAuC;AACvC,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAAwB,EACxB,IAAY,EACZ,UAA2B,EAAE;IAE7B,MAAM,SAAS,CAAC,IAAI,EAAE,QAAQ,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;AAErE,MAAM,WAAW,eAAgB,SAAQ,aAAa;IACpD
|
|
1
|
+
{"version":3,"file":"idf.d.ts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|
package/dist/parse/idf.js
CHANGED
|
@@ -18,6 +18,19 @@ export function parseIdf(text, schema, options = {}) {
|
|
|
18
18
|
diagnostics.push(diagnostic);
|
|
19
19
|
options.onDiagnostic?.(diagnostic);
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Record a finding that does NOT stop the parse, whatever `strict` says.
|
|
23
|
+
*
|
|
24
|
+
* `report` throws under `strict`, which is right for a finding that leaves nothing to return: an
|
|
25
|
+
* object whose type is unknown cannot be built. A value of the wrong KIND is different. The
|
|
26
|
+
* object is built, the document is complete, and a caller reading strictly gets exactly what they
|
|
27
|
+
* got before this finding existed (FR-014). Routing it through `report` made a strict parse fail
|
|
28
|
+
* on files that used to load, which is the opposite of additive.
|
|
29
|
+
*/
|
|
30
|
+
const note = (diagnostic) => {
|
|
31
|
+
diagnostics.push(diagnostic);
|
|
32
|
+
options.onDiagnostic?.(diagnostic);
|
|
33
|
+
};
|
|
21
34
|
const raw = lex(text, { onDiagnostic: report });
|
|
22
35
|
const document = new IdfDocument(schema);
|
|
23
36
|
for (const object of raw) {
|
|
@@ -26,27 +39,57 @@ export function parseIdf(text, schema, options = {}) {
|
|
|
26
39
|
report({
|
|
27
40
|
message: `Unknown object type "${object.typeName}" in EnergyPlus ${schema.version}`,
|
|
28
41
|
line: object.line,
|
|
42
|
+
column: object.column,
|
|
29
43
|
typeName: object.typeName,
|
|
44
|
+
// Best effort, and the same rule Python's `_extract_object_name` uses: the first positional
|
|
45
|
+
// value is the name for every named type, and is a real field for the anonymous ones. An
|
|
46
|
+
// unknown type has no definition to tell the two apart, so the raw first value is what there
|
|
47
|
+
// is. Declaring `objectName` and never filling it would make the field a claim rather than a
|
|
48
|
+
// value.
|
|
49
|
+
objectName: object.values[0],
|
|
50
|
+
code: 'UnknownObjectType',
|
|
30
51
|
});
|
|
31
52
|
continue;
|
|
32
53
|
}
|
|
33
54
|
const definition = schema.require(canonical);
|
|
34
55
|
try {
|
|
35
|
-
const
|
|
56
|
+
const invalid = [];
|
|
57
|
+
const { name, values } = interpret(definition, object, invalid);
|
|
36
58
|
document.addRaw(canonical, definition.anon === 1 ? null : name, values);
|
|
59
|
+
// Reported after the object is built, never instead of building it: a value of the wrong
|
|
60
|
+
// kind does not stop the parse, so a caller reading strictly gets the document they always
|
|
61
|
+
// got. This adds a finding where there was silence, and nothing else.
|
|
62
|
+
//
|
|
63
|
+
// Positioned at the offending FIELD rather than at the object, because that is what makes it
|
|
64
|
+
// useful. The shape this catches is a missing semicolon swallowing the object below, and the
|
|
65
|
+
// object's own first line is nowhere near the damage.
|
|
66
|
+
for (const { field, index, value } of invalid) {
|
|
67
|
+
if (stringIsLegal(definition, field, value))
|
|
68
|
+
continue;
|
|
69
|
+
note({
|
|
70
|
+
message: `Field "${field}" expects a number, got "${value}"`,
|
|
71
|
+
line: fieldLine(text, object, index),
|
|
72
|
+
typeName: canonical,
|
|
73
|
+
objectName: definition.anon === 1 ? undefined : object.values[0],
|
|
74
|
+
code: 'InvalidField',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
37
77
|
}
|
|
38
78
|
catch (error) {
|
|
39
79
|
report({
|
|
40
80
|
message: error instanceof Error ? error.message : String(error),
|
|
41
81
|
line: object.line,
|
|
82
|
+
column: object.column,
|
|
42
83
|
typeName: canonical,
|
|
84
|
+
objectName: definition.anon === 1 ? undefined : object.values[0],
|
|
85
|
+
code: 'ParseError',
|
|
43
86
|
});
|
|
44
87
|
}
|
|
45
88
|
}
|
|
46
89
|
return { document, diagnostics };
|
|
47
90
|
}
|
|
48
91
|
/** Map positional IDF values onto named schema fields. */
|
|
49
|
-
function interpret(definition, object) {
|
|
92
|
+
function interpret(definition, object, invalid) {
|
|
50
93
|
const order = definition.f;
|
|
51
94
|
const named = definition.anon !== 1 && order[0] === 'name';
|
|
52
95
|
const values = {};
|
|
@@ -61,6 +104,7 @@ function interpret(definition, object) {
|
|
|
61
104
|
}
|
|
62
105
|
const fixed = named ? order.slice(1) : order;
|
|
63
106
|
for (const field of fixed) {
|
|
107
|
+
const index = cursor;
|
|
64
108
|
const raw = object.values[cursor++];
|
|
65
109
|
if (raw === undefined)
|
|
66
110
|
break;
|
|
@@ -69,6 +113,11 @@ function interpret(definition, object) {
|
|
|
69
113
|
const coerced = coerce(definition, field, raw);
|
|
70
114
|
if (coerced !== undefined)
|
|
71
115
|
values[field] = coerced;
|
|
116
|
+
// A numeric field that kept its string is a coercion that fell through. Whether that is
|
|
117
|
+
// actually wrong needs the schema and is asked on the reporting path, which runs almost never.
|
|
118
|
+
if (invalid !== undefined && coerced === raw && isNumericField(definition, field)) {
|
|
119
|
+
invalid.push({ field, index, value: raw });
|
|
120
|
+
}
|
|
72
121
|
}
|
|
73
122
|
// Everything past the fixed fields belongs to the extensible section, read in
|
|
74
123
|
// repeats of the group width. A trailing partial group is kept rather than
|
|
@@ -107,6 +156,110 @@ function interpret(definition, object) {
|
|
|
107
156
|
}
|
|
108
157
|
return { name, values };
|
|
109
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* The two sizing sentinels, accepted in ANY numeric field.
|
|
161
|
+
*
|
|
162
|
+
* Not read from the field's own `se` branch, deliberately. The schema EnergyPlus ships is NARROWER
|
|
163
|
+
* than the engine it ships with, and its own example files prove it. Both of these declare a string
|
|
164
|
+
* branch naming exactly one sentinel, and the shipped files use the other one:
|
|
165
|
+
*
|
|
166
|
+
* `PlantLoop.plant_loop_volume` allows `Autocalculate`; 28 files write `Autosize`.
|
|
167
|
+
* `AirTerminal:SingleDuct:VAV:Reheat.maximum_flow_fraction_during_reheat` allows `Autosize`;
|
|
168
|
+
* 673 files write `Autocalculate`.
|
|
169
|
+
*
|
|
170
|
+
* The schema is well formed: across all 17 bundled versions no field declares a non-numeric string
|
|
171
|
+
* default on a numeric type with no string branch. It is simply stricter about WHICH sentinel
|
|
172
|
+
* belongs where than EnergyPlus is. Reading each field's branch literally produced 3,775 findings
|
|
173
|
+
* across the 760 example files of one release, every one against a model EnergyPlus reads happily.
|
|
174
|
+
*
|
|
175
|
+
* A parse finding says the value is not of the kind the field takes. Whether the exact sentinel is
|
|
176
|
+
* the one THIS field documents is a schema question, and `validateObject` already answers it.
|
|
177
|
+
*/
|
|
178
|
+
const SIZING_SENTINELS = new Set(['autosize', 'autocalculate']);
|
|
179
|
+
/** @internal */
|
|
180
|
+
function isNumericField(definition, field) {
|
|
181
|
+
const kind = definition.p[field]?.t;
|
|
182
|
+
return kind === 'n' || kind === 'i';
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Whether a string the numeric coercion rejected is legal for this field anyway.
|
|
186
|
+
*
|
|
187
|
+
* Consulted only when coercion has already failed, so the parse path pays nothing for it.
|
|
188
|
+
*
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
function stringIsLegal(definition, field, value) {
|
|
192
|
+
if (SIZING_SENTINELS.has(value.toLowerCase()))
|
|
193
|
+
return true;
|
|
194
|
+
const slim = definition.p[field];
|
|
195
|
+
if (slim === undefined)
|
|
196
|
+
return true;
|
|
197
|
+
// `auto` marks a collapsed `anyOf`. Without an `se` the string branch declared no enum, so any
|
|
198
|
+
// string satisfies it; with one, only its members do.
|
|
199
|
+
if (slim.se === undefined)
|
|
200
|
+
return slim.auto === 1;
|
|
201
|
+
const folded = value.toLowerCase();
|
|
202
|
+
return slim.se.some((allowed) => allowed.toLowerCase() === folded);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The 1-based line a field sits on, found by rescanning from the object's own offset.
|
|
206
|
+
*
|
|
207
|
+
* The lexer records one offset per object rather than a line per field, because a finding about a
|
|
208
|
+
* field is rare and an array per object is not. This walks forward counting separators, stepping
|
|
209
|
+
* over `!` comments so a comma inside one is not mistaken for one, which is the same rule the
|
|
210
|
+
* lexer itself follows.
|
|
211
|
+
*
|
|
212
|
+
* `index` counts into `RawObject.values`, which the lexer has already shifted the type name off.
|
|
213
|
+
* The scan starts at the type name, so it steps over one more separator than the index: the comma
|
|
214
|
+
* that ends `Building,` is what puts values[0] on the line after it.
|
|
215
|
+
*
|
|
216
|
+
* @internal
|
|
217
|
+
*/
|
|
218
|
+
function fieldLine(text, object, index) {
|
|
219
|
+
if (object.offset === undefined)
|
|
220
|
+
return object.line;
|
|
221
|
+
const separators = index + 1;
|
|
222
|
+
let seen = 0;
|
|
223
|
+
let position = object.offset;
|
|
224
|
+
while (position < text.length && seen < separators) {
|
|
225
|
+
const char = text[position];
|
|
226
|
+
if (char === '!') {
|
|
227
|
+
const newline = text.indexOf('\n', position);
|
|
228
|
+
if (newline < 0)
|
|
229
|
+
break;
|
|
230
|
+
position = newline + 1;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (char === ';')
|
|
234
|
+
break;
|
|
235
|
+
if (char === ',')
|
|
236
|
+
seen += 1;
|
|
237
|
+
position += 1;
|
|
238
|
+
}
|
|
239
|
+
if (seen < separators)
|
|
240
|
+
return object.line;
|
|
241
|
+
// Step over whitespace AND any comment between the separator and the value. A field's comma is
|
|
242
|
+
// routinely followed by `!- Field Name` on the same line, and stopping at the `!` would report
|
|
243
|
+
// the line the PREVIOUS value sits on, one too early.
|
|
244
|
+
while (position < text.length) {
|
|
245
|
+
const char = text[position] ?? '';
|
|
246
|
+
if (char === '!') {
|
|
247
|
+
const newline = text.indexOf('\n', position);
|
|
248
|
+
if (newline < 0)
|
|
249
|
+
break;
|
|
250
|
+
position = newline + 1;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (!/\s/.test(char))
|
|
254
|
+
break;
|
|
255
|
+
position += 1;
|
|
256
|
+
}
|
|
257
|
+
let line = object.line;
|
|
258
|
+
for (let i = object.offset; i < position; i += 1)
|
|
259
|
+
if (text[i] === '\n')
|
|
260
|
+
line += 1;
|
|
261
|
+
return line;
|
|
262
|
+
}
|
|
110
263
|
function coerce(definition, field, raw) {
|
|
111
264
|
return coerceValue(definition.p[field]?.t, raw);
|
|
112
265
|
}
|
|
@@ -137,11 +290,31 @@ function coerceValue(kind, raw) {
|
|
|
137
290
|
export class IdfParseError extends Error {
|
|
138
291
|
line;
|
|
139
292
|
typeName;
|
|
293
|
+
/**
|
|
294
|
+
* Every finding that stopped the parse.
|
|
295
|
+
*
|
|
296
|
+
* This error carried `line` and `typeName` from a single diagnostic, flattened into fields, and
|
|
297
|
+
* a caller who wanted the rest had nowhere to look. Python's `IDFParseError` has always carried
|
|
298
|
+
* the collection; this is the half of the difference that was real.
|
|
299
|
+
*
|
|
300
|
+
* `line` and `typeName` still resolve to the first finding's values, so no existing caller
|
|
301
|
+
* breaks (FR-013, FR-014). They are a convenience over `diagnostics[0]` rather than a second
|
|
302
|
+
* source of truth.
|
|
303
|
+
*/
|
|
304
|
+
diagnostics;
|
|
140
305
|
constructor(diagnostic) {
|
|
141
|
-
|
|
306
|
+
const diagnostics = Array.isArray(diagnostic)
|
|
307
|
+
? diagnostic
|
|
308
|
+
: [diagnostic];
|
|
309
|
+
const first = diagnostics[0];
|
|
310
|
+
if (first === undefined) {
|
|
311
|
+
throw new TypeError('IdfParseError needs at least one diagnostic');
|
|
312
|
+
}
|
|
313
|
+
super(`${first.message} (line ${first.line})`);
|
|
142
314
|
this.name = 'IdfParseError';
|
|
143
|
-
this.line =
|
|
144
|
-
this.typeName =
|
|
315
|
+
this.line = first.line;
|
|
316
|
+
this.typeName = first.typeName;
|
|
317
|
+
this.diagnostics = Object.freeze([...diagnostics]);
|
|
145
318
|
}
|
|
146
319
|
}
|
|
147
320
|
/**
|
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,MAA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,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IACrD,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,yEAAyE;IACzE,6EAA6E;IAC7E,8EAA8E;IAC9E,gBAAgB;IAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC5C,wEAAwE;IACxE,+CAA+C;IAC/C,MAAM,KAAK,GAAG,uCAAuC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrE,MAAM,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,qEAAqE;IACrE,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC9D,CAAC"}
|
package/dist/parse/lexer.d.ts
CHANGED
|
@@ -6,11 +6,47 @@ export interface RawObject {
|
|
|
6
6
|
values: string[];
|
|
7
7
|
/** 1-based line where the object starts, for diagnostics. */
|
|
8
8
|
line: number;
|
|
9
|
+
/** 1-based column where the object starts, for diagnostics. */
|
|
10
|
+
column?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Absolute offset of the object's first character in the source text.
|
|
13
|
+
*
|
|
14
|
+
* One number per object, so that a finding about a FIELD can be positioned without the lexer
|
|
15
|
+
* recording a line for every field of every object. The rescan that uses it runs only when a
|
|
16
|
+
* finding is being built.
|
|
17
|
+
*/
|
|
18
|
+
offset?: number;
|
|
9
19
|
}
|
|
10
20
|
export interface LexDiagnostic {
|
|
11
21
|
message: string;
|
|
12
22
|
line: number;
|
|
23
|
+
/**
|
|
24
|
+
* Machine-readable kind, from the vocabulary both libraries share.
|
|
25
|
+
*
|
|
26
|
+
* Derived from Python's exception hierarchy by dropping the `Error` suffix, so neither language
|
|
27
|
+
* invented it and the mapping stays mechanical. The conformance corpus compares a finding on
|
|
28
|
+
* `(code, line, typeName)` and never on `message`: wording is a presentation choice each library
|
|
29
|
+
* should stay free to improve, and pinning it would turn every improvement into a failure.
|
|
30
|
+
*/
|
|
31
|
+
code?: ParseDiagnosticCode;
|
|
32
|
+
/** 1-based column, when the lexer knew one. */
|
|
33
|
+
column?: number;
|
|
34
|
+
/** Path the text came from, when it came from a file rather than a string. */
|
|
35
|
+
filepath?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Object type the problem occurred in, when known.
|
|
38
|
+
*
|
|
39
|
+
* Declared here rather than only on `ParseDiagnostic` because the lexer knows it too: an
|
|
40
|
+
* unterminated object has read its type name before it runs out of input, and a finding that
|
|
41
|
+
* drops it says only that something went wrong somewhere.
|
|
42
|
+
*/
|
|
43
|
+
typeName?: string;
|
|
13
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The shared diagnostic vocabulary. The table lives in
|
|
47
|
+
* `idfkit-conformance/runners/compare.md`; a code outside it is a difference, not a near match.
|
|
48
|
+
*/
|
|
49
|
+
export type ParseDiagnosticCode = 'UnknownObjectType' | 'InvalidField' | 'Range' | 'DuplicateObject' | 'ParseError' | 'VersionMismatch' | 'UnsupportedVersion' | 'SchemaNotFound';
|
|
14
50
|
export interface LexOptions {
|
|
15
51
|
/** Report a problem instead of throwing. */
|
|
16
52
|
onDiagnostic?: (diagnostic: LexDiagnostic) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../src/parse/lexer.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"lexer.d.ts","sourceRoot":"","sources":["../../src/parse/lexer.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,WAAW,SAAS;IACxB,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAC3B,mBAAmB,GACnB,cAAc,GACd,OAAO,GACP,iBAAiB,GACjB,YAAY,GACZ,iBAAiB,GACjB,oBAAoB,GACpB,gBAAgB,CAAC;AAErB,MAAM,WAAW,UAAU;IACzB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,KAAK,IAAI,CAAC;CACpD;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,SAAS,EAAE,CAmJvE"}
|
package/dist/parse/lexer.js
CHANGED
|
@@ -29,6 +29,20 @@ export function lex(text, options = {}) {
|
|
|
29
29
|
let fieldStart = 0;
|
|
30
30
|
let objectLine = 1;
|
|
31
31
|
let objectStarted = false;
|
|
32
|
+
/** Offset of the first character of the current line, for turning an offset into a column. */
|
|
33
|
+
let lineStart = 0;
|
|
34
|
+
/**
|
|
35
|
+
* Column the current object's type name begins at, or 0 while none has been seen.
|
|
36
|
+
*
|
|
37
|
+
* The first NON-BLANK character, not the start of the field text: Python's regex matches the
|
|
38
|
+
* type name itself, so an object indented three spaces reports column 4 there and has to report
|
|
39
|
+
* column 4 here too, or the corpus compares two different notions of position.
|
|
40
|
+
*/
|
|
41
|
+
let objectColumn = 0;
|
|
42
|
+
/** Absolute offset of the current object's first non-blank character. */
|
|
43
|
+
let objectOffset = -1;
|
|
44
|
+
/** 1-based column of an offset on the line it falls in. Matches Python's `_line_and_column`. */
|
|
45
|
+
const columnAt = (offset) => offset - lineStart + 1;
|
|
32
46
|
const endField = (end) => {
|
|
33
47
|
chunks.push(text.slice(fieldStart, end));
|
|
34
48
|
const value = chunks.join('').trim();
|
|
@@ -37,6 +51,14 @@ export function lex(text, options = {}) {
|
|
|
37
51
|
};
|
|
38
52
|
while (index < length) {
|
|
39
53
|
const char = text[index];
|
|
54
|
+
// The first non-blank character of an object fixes where the object starts. Recorded here
|
|
55
|
+
// rather than at the delimiter, because by then the leading whitespace has been consumed and
|
|
56
|
+
// the offset that remains points at the padding rather than at the name.
|
|
57
|
+
if (objectColumn === 0 && char !== undefined && !/\s/.test(char)) {
|
|
58
|
+
objectLine = line;
|
|
59
|
+
objectColumn = columnAt(index);
|
|
60
|
+
objectOffset = index;
|
|
61
|
+
}
|
|
40
62
|
if (char === '!') {
|
|
41
63
|
// Preserve any field text seen before the comment, then resume after the
|
|
42
64
|
// newline. This is what lets `Zone1, !- Name` work: the comment is not
|
|
@@ -51,9 +73,12 @@ export function lex(text, options = {}) {
|
|
|
51
73
|
index = newline + 1;
|
|
52
74
|
fieldStart = index;
|
|
53
75
|
line += 1;
|
|
76
|
+
lineStart = index;
|
|
54
77
|
if (!objectStarted && chunks.join('').trim() === '') {
|
|
55
78
|
chunks = [];
|
|
56
79
|
objectLine = line;
|
|
80
|
+
objectColumn = 0;
|
|
81
|
+
objectOffset = -1;
|
|
57
82
|
}
|
|
58
83
|
continue;
|
|
59
84
|
}
|
|
@@ -70,18 +95,32 @@ export function lex(text, options = {}) {
|
|
|
70
95
|
fieldStart = index;
|
|
71
96
|
const typeName = values.shift() ?? '';
|
|
72
97
|
if (typeName === '') {
|
|
73
|
-
report?.({
|
|
98
|
+
report?.({
|
|
99
|
+
message: 'Object with no type name',
|
|
100
|
+
line: objectLine,
|
|
101
|
+
column: objectColumn || undefined,
|
|
102
|
+
code: 'ParseError',
|
|
103
|
+
});
|
|
74
104
|
}
|
|
75
105
|
else {
|
|
76
|
-
objects.push({
|
|
106
|
+
objects.push({
|
|
107
|
+
typeName,
|
|
108
|
+
values,
|
|
109
|
+
line: objectLine,
|
|
110
|
+
column: objectColumn || undefined,
|
|
111
|
+
offset: objectOffset >= 0 ? objectOffset : undefined,
|
|
112
|
+
});
|
|
77
113
|
}
|
|
78
114
|
values = [];
|
|
79
115
|
objectStarted = false;
|
|
80
116
|
objectLine = line;
|
|
117
|
+
objectColumn = 0;
|
|
118
|
+
objectOffset = -1;
|
|
81
119
|
continue;
|
|
82
120
|
}
|
|
83
121
|
if (char === '\n') {
|
|
84
122
|
line += 1;
|
|
123
|
+
lineStart = index + 1;
|
|
85
124
|
if (!objectStarted &&
|
|
86
125
|
chunks.join('').trim() === '' &&
|
|
87
126
|
text.slice(fieldStart, index).trim() === '') {
|
|
@@ -89,6 +128,8 @@ export function lex(text, options = {}) {
|
|
|
89
128
|
chunks = [];
|
|
90
129
|
fieldStart = index + 1;
|
|
91
130
|
objectLine = line;
|
|
131
|
+
objectColumn = 0;
|
|
132
|
+
objectOffset = -1;
|
|
92
133
|
}
|
|
93
134
|
}
|
|
94
135
|
index += 1;
|
|
@@ -98,6 +139,12 @@ export function lex(text, options = {}) {
|
|
|
98
139
|
report?.({
|
|
99
140
|
message: `Unterminated object near "${trailing.slice(0, 40) || values[0]}" (missing ";")`,
|
|
100
141
|
line: objectLine,
|
|
142
|
+
code: 'ParseError',
|
|
143
|
+
column: objectColumn || undefined,
|
|
144
|
+
// `values` has not been shifted, because the shift happens on `;` and there was none, so the
|
|
145
|
+
// type name is still at the front. Reporting it is what lets the corpus compare this finding
|
|
146
|
+
// against Python's on `(code, line, typeName)`.
|
|
147
|
+
typeName: values[0],
|
|
101
148
|
});
|
|
102
149
|
}
|
|
103
150
|
return objects;
|
package/dist/parse/lexer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/parse/lexer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lexer.js","sourceRoot":"","sources":["../../src/parse/lexer.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,UAAsB,EAAE;IACxD,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAE3B,sEAAsE;IACtE,IAAI,MAAM,GAAa,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,IAAI,MAAM,GAAa,EAAE,CAAC;IAE1B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,CAAC,CA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,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,EAAE,CAAC;YACP,OAAO,EAAE,6BAA6B,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,iBAAiB;YACzF,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,YAAY;YAClB,MAAM,EAAE,YAAY,IAAI,SAAS;YACjC,6FAA6F;YAC7F,6FAA6F;YAC7F,gDAAgD;YAChD,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;SACpB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/write/idf.d.ts
CHANGED
|
@@ -24,6 +24,36 @@ export interface WriteIdfOptions {
|
|
|
24
24
|
* @defaultValue true
|
|
25
25
|
*/
|
|
26
26
|
versionFirst?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* How object types are ordered.
|
|
29
|
+
*
|
|
30
|
+
* `'source'` keeps the order the types first appeared in the document, which is what this writer
|
|
31
|
+
* has always done and remains the default: no default moves (FR-017). `'sorted'` orders them by
|
|
32
|
+
* type name, which is the other language's default and what its `!-Option SortedOrder` header
|
|
33
|
+
* declares.
|
|
34
|
+
*
|
|
35
|
+
* An enumeration rather than a boolean, because three behaviours exist across the two languages
|
|
36
|
+
* and two formats and a flag cannot say which of the three is wanted.
|
|
37
|
+
*
|
|
38
|
+
* Orthogonal to `versionFirst`, which pins `Version` ahead of whichever order this selects.
|
|
39
|
+
*
|
|
40
|
+
* @defaultValue 'source'
|
|
41
|
+
*/
|
|
42
|
+
ordering?: 'sorted' | 'source';
|
|
43
|
+
/**
|
|
44
|
+
* Put each object on a single line, with no comments and no blank separators.
|
|
45
|
+
*
|
|
46
|
+
* The counterpart of the other language's `output_type="compressed"`, and it means the same
|
|
47
|
+
* thing: type name and values joined by commas, one object per line, no generator header, no
|
|
48
|
+
* blank line between objects. The corpus checks that the two agree structurally rather than
|
|
49
|
+
* textually, because the two writers differ on defaults that compressed output does not remove.
|
|
50
|
+
*
|
|
51
|
+
* `comments: false` is not this. That skips the padding and the comment and still puts every
|
|
52
|
+
* field on its own line, which is a different, coarser output that both languages already had.
|
|
53
|
+
*
|
|
54
|
+
* @defaultValue false
|
|
55
|
+
*/
|
|
56
|
+
compressed?: boolean;
|
|
27
57
|
}
|
|
28
58
|
/**
|
|
29
59
|
* Serialize a document to IDF text.
|
|
@@ -41,6 +71,8 @@ export interface ObjectWriteOptions {
|
|
|
41
71
|
comments: boolean;
|
|
42
72
|
commentColumn: number;
|
|
43
73
|
indent: string;
|
|
74
|
+
/** Put the whole object on one line. See `WriteIdfOptions.compressed`. */
|
|
75
|
+
compressed?: boolean;
|
|
44
76
|
}
|
|
45
77
|
/** Serialize one object. */
|
|
46
78
|
export declare function writeObject(obj: IdfObject, options: ObjectWriteOptions): string;
|
package/dist/write/idf.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idf.d.ts","sourceRoot":"","sources":["../../src/write/idf.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"idf.d.ts","sourceRoot":"","sources":["../../src/write/idf.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC/B;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,UAAU,EAC3C,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,EACxB,OAAO,GAAE,eAAoB,GAC5B,MAAM,CAkCR;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,kBAAkB,GAAG,MAAM,CA4D/E"}
|
package/dist/write/idf.js
CHANGED
|
@@ -10,12 +10,20 @@
|
|
|
10
10
|
* yet.
|
|
11
11
|
*/
|
|
12
12
|
export function writeIdf(document, options = {}) {
|
|
13
|
-
const
|
|
13
|
+
const compressed = options.compressed ?? false;
|
|
14
|
+
// Compressed output has no comments by definition. Asking for both is not an error, because the
|
|
15
|
+
// narrower request is unambiguous: comments cannot survive a single-line object.
|
|
16
|
+
const comments = compressed ? false : (options.comments ?? true);
|
|
14
17
|
const commentColumn = options.commentColumn ?? 30;
|
|
15
18
|
const indent = options.indent ?? ' ';
|
|
16
19
|
const versionFirst = options.versionFirst ?? true;
|
|
20
|
+
const ordering = options.ordering ?? 'source';
|
|
17
21
|
const parts = [];
|
|
18
22
|
const types = document.types();
|
|
23
|
+
// Sorted first, then Version pinned, so the two controls compose the way the other language's
|
|
24
|
+
// output does: its `SortedOrder` header describes the type ordering and Version sits above it.
|
|
25
|
+
if (ordering === 'sorted')
|
|
26
|
+
types.sort();
|
|
19
27
|
if (versionFirst && types.includes('Version')) {
|
|
20
28
|
types.splice(types.indexOf('Version'), 1);
|
|
21
29
|
types.unshift('Version');
|
|
@@ -25,9 +33,12 @@ export function writeIdf(document, options = {}) {
|
|
|
25
33
|
if (collection.size === 0)
|
|
26
34
|
continue;
|
|
27
35
|
for (const obj of collection) {
|
|
28
|
-
parts.push(writeObject(obj, { comments, commentColumn, indent }));
|
|
36
|
+
parts.push(writeObject(obj, { comments, commentColumn, indent, compressed }));
|
|
29
37
|
}
|
|
30
|
-
|
|
38
|
+
// The blank separator after each type is one of the two things compressed removes. The other
|
|
39
|
+
// is the per-field line break, in `writeObject`.
|
|
40
|
+
if (!compressed)
|
|
41
|
+
parts.push('');
|
|
31
42
|
}
|
|
32
43
|
return parts.join('\n');
|
|
33
44
|
}
|
|
@@ -60,10 +71,18 @@ export function writeObject(obj, options) {
|
|
|
60
71
|
}
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
|
-
|
|
74
|
+
// Compressed output carries no trailing newline of its own: `writeIdf` joins the parts with one,
|
|
75
|
+
// and adding a second here is what puts a blank line between objects. Removing that blank line
|
|
76
|
+
// is half of what compressed means.
|
|
64
77
|
if (cells.length === 0) {
|
|
65
|
-
return `${obj.typeName};\n`;
|
|
78
|
+
return options.compressed ? `${obj.typeName};` : `${obj.typeName};\n`;
|
|
79
|
+
}
|
|
80
|
+
if (options.compressed) {
|
|
81
|
+
// Type name and every value on one line, comma-separated, terminated once. The same shape the
|
|
82
|
+
// other language produces, whose writer joins the values and skips the header and separators.
|
|
83
|
+
return `${obj.typeName},${cells.map((cell) => cell.value).join(',')};`;
|
|
66
84
|
}
|
|
85
|
+
const lines = [`${obj.typeName},`];
|
|
67
86
|
cells.forEach((cell, index) => {
|
|
68
87
|
const terminator = index === cells.length - 1 ? ';' : ',';
|
|
69
88
|
const body = `${options.indent}${cell.value}${terminator}`;
|
package/dist/write/idf.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idf.js","sourceRoot":"","sources":["../../src/write/idf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"idf.js","sourceRoot":"","sources":["../../src/write/idf.ts"],"names":[],"mappings":"AA6DA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,QAAQ,CACtB,QAAwB,EACxB,UAA2B,EAAE;IAE7B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;IAC/C,gGAAgG;IAChG,iFAAiF;IACjF,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC;IACjE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,MAAM,CAAC;IACxC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC;IAClD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;IAE9C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC;IAE/B,8FAA8F;IAC9F,+FAA+F;IAC/F,IAAI,QAAQ,KAAK,QAAQ;QAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAExC,IAAI,YAAY,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9C,KAAK,CAAC,MAAM,CAAC,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;SACV,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACnB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACnC,IAAI,KAAK,GAAG,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACpD,OAAO,IAAI,CAAC,CAAC,CAAE,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idfkit/core",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.2",
|
|
4
4
|
"description": "Fast EnergyPlus IDF and epJSON parsing and manipulation for JavaScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"node": ">=20"
|
|
43
43
|
},
|
|
44
44
|
"idfkit": {
|
|
45
|
-
"conformance": "conformance-2026.
|
|
46
|
-
"governance": "governance-2026.
|
|
45
|
+
"conformance": "conformance-2026.8",
|
|
46
|
+
"governance": "governance-2026.10"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@idfkit/schemas": "0.2.0-rc.
|
|
49
|
+
"@idfkit/schemas": "0.2.0-rc.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@idfkit/types-v26-1": "*",
|