@shapeshift-labs/frontier-lang-parser 0.3.82 → 0.3.84

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.
@@ -4,6 +4,7 @@ export function parseNativeSourceBlock(block) {
4
4
  const name = nameFrom(block.header);
5
5
  const losses = parseLosses(name, block.body);
6
6
  const nativeSourceId = idFrom(block.header, `native_${name}`);
7
+ const language = readWord('language', block.body) ?? readWord('sourceLanguage', block.body) ?? name;
7
8
  const evidence = parseEvidenceRecords(block.body);
8
9
  const sourceMaps = parseSourceMaps(block.body, {
9
10
  nativeSourceId,
@@ -13,7 +14,7 @@ export function parseNativeSourceBlock(block) {
13
14
  });
14
15
  const mergeCandidates = parseMergeCandidates(block.body, {
15
16
  nativeSourceId,
16
- language: readWord('language', block.body) ?? name,
17
+ language,
17
18
  sourcePath: readWord('sourcePath', block.body) ?? readWord('path', block.body),
18
19
  sourceMaps,
19
20
  evidence
@@ -21,13 +22,13 @@ export function parseNativeSourceBlock(block) {
21
22
  const node = nativeSourceNode({
22
23
  id: nativeSourceId,
23
24
  name,
24
- language: readWord('language', block.body) ?? name,
25
+ language,
25
26
  parser: readWord('parser', block.body),
26
27
  parserVersion: readWord('parserVersion', block.body),
27
28
  sourcePath: readWord('sourcePath', block.body) ?? readWord('path', block.body),
28
29
  sourceHash: readWord('sourceHash', block.body),
29
30
  symbol: readWord('symbol', block.body),
30
- frontierNodeIds: readList('frontierNodes', block.body),
31
+ frontierNodeIds: readList('frontierNodes', block.body) ?? readList('frontierNodeIds', block.body) ?? readList('frontierNodeId', block.body) ?? readList('frontierNode', block.body),
31
32
  sourceMapIds: sourceMaps.map((sourceMap) => sourceMap.id),
32
33
  mergeCandidateIds: mergeCandidates.map((candidate) => candidate.id),
33
34
  evidenceIds: evidence.map((record) => record.id),
@@ -139,7 +140,7 @@ function parseMergeCandidates(body, context) {
139
140
  const sourceMapMappingIds = readInlineList(rest, 'sourceMapMapping', 'sourceMapMappings', 'sourceMapMappingIds');
140
141
  return createSemanticMergeCandidateRecord(cleanRecord({
141
142
  id: idFrom(rest, `merge_candidate_${name}`),
142
- language: readInlineWord('language', rest) ?? context.language,
143
+ language: readInlineWord('language', rest) ?? readInlineWord('sourceLanguage', rest) ?? context.language,
143
144
  sourcePath: readInlineWord('sourcePath', rest) ?? readInlineWord('path', rest) ?? context.sourcePath,
144
145
  baseHash: readInlineWord('baseHash', rest),
145
146
  targetHash: readInlineWord('targetHash', rest),
@@ -10,6 +10,8 @@ const runtimeRows = words('host runtimeHost hostProfile sourceHost targetHost ca
10
10
  const semanticEditRows = words('script semanticEditScript projection semanticEditProjection replay semanticEditReplay');
11
11
  const gateAdmissionRows = words('gate evidence proofEvidence admission admissionDecision proofObligation obligation gap proofGap');
12
12
  const resourceRows = words('sourceLanguage language sourcePath path sourceHash status evidence evidenceIds resource owner loan alias move drop escape lifetime lifetimeRegion life outlives lifetimeRelation lifeRelation borrow borrowScope borrowRegion unsafe unsafeBoundary memory memoryRegion region layout dataLayout pointer ptr address access memoryAccess atomic volatile abi abiBoundary callBoundary sync synchronization synchronisation synchronizationEdge synchronisationEdge happensBefore happens-before hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation proofEvidence sourceMap sourcemap mapping sourceMapMapping missingEvidence');
13
+ const targetRows = words('language targetLanguage sourceLanguage package packageName emitPath targetPath sourcePath path sourceHash targetHash runtime runtimeHost moduleFormat projection lowering lower layer adapter adapterId readiness disposition status evidence proofEvidence proof loss missingEvidence gap proofGap sourceMap sourcemap mapping sourceMapMapping');
14
+ const nativeSourceRows = words('language sourceLanguage parser parserVersion sourcePath path sourceHash symbol frontierNodes frontierNode frontierNodeId frontierNodeIds loss evidence proofEvidence sourceMap sourcemap mapping sourceMapMapping mergeCandidate candidate');
13
15
  const coreFailClosed = (reason) => ({ failClosedUnknownRows: true, unknownRowReason: reason });
14
16
 
15
17
  export const ROW_SYNTAX_CONFIG = Object.freeze({
@@ -35,7 +37,7 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
35
37
  plugin: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
36
38
  pluginSurface: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
37
39
  pluginContract: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
38
- target: rowConfig('targetProjectionRow', 'target_projection_row', words('projection lowering layer')),
40
+ target: rowConfig('targetProjectionRow', 'target_projection_row', targetRows, normalizeTargetProjectionRow, coreFailClosed('unsupported-target-projection-row')),
39
41
  packageManifest: rowConfig('packageManifestRow', 'package_manifest_row', packageRows, normalizePackageManifestRow, coreFailClosed('unsupported-package-manifest-row')),
40
42
  packageGraph: rowConfig('packageManifestRow', 'package_manifest_row', packageRows, normalizePackageManifestRow, coreFailClosed('unsupported-package-manifest-row')),
41
43
  packageSurface: rowConfig('packageManifestRow', 'package_manifest_row', packageRows, normalizePackageManifestRow, coreFailClosed('unsupported-package-manifest-row')),
@@ -55,7 +57,7 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
55
57
  paradigm: rowConfig('paradigmRow', 'paradigm_row', words('valueSemantics mutationModel effectModel ownership ownershipModel lifetime lifetimeModel bindingScope binding dispatch typeModel moduleModel concurrency errorModel memoryModel evaluation metaprogramming interop lowering'), normalizeParadigmRow),
56
58
  paradigmSemantics: rowConfig('paradigmRow', 'paradigm_row', words('valueSemantics mutationModel effectModel ownership ownershipModel lifetime lifetimeModel bindingScope binding dispatch typeModel moduleModel concurrency errorModel memoryModel evaluation metaprogramming interop lowering'), normalizeParadigmRow),
57
59
  proof: rowConfig('proofRow', 'proof_row', words('contract refinement invariant termination temporal obligation artifact assumption')),
58
- nativeSource: rowConfig('nativeSourceRow', 'native_source_row', words('loss evidence proofEvidence sourceMap sourcemap mapping sourceMapMapping mergeCandidate candidate'), normalizeNativeSourceRow)
60
+ nativeSource: rowConfig('nativeSourceRow', 'native_source_row', nativeSourceRows, normalizeNativeSourceRow, coreFailClosed('unsupported-native-source-row'))
59
61
  });
60
62
 
61
63
  function rowConfig(childKind, idPrefix, rowKinds, normalize, options = {}) {
@@ -86,6 +88,19 @@ function normalizeRuntimeCapabilityRow(rowKind) {
86
88
  return rowKind;
87
89
  }
88
90
 
91
+ function normalizeTargetProjectionRow(rowKind) {
92
+ if (rowKind === 'targetLanguage') return 'language';
93
+ if (rowKind === 'package') return 'packageName';
94
+ if (rowKind === 'path') return 'sourcePath';
95
+ if (rowKind === 'targetPath') return 'emitPath';
96
+ if (rowKind === 'lower') return 'lowering';
97
+ if (rowKind === 'adapter') return 'adapterId';
98
+ if (rowKind === 'proof' || rowKind === 'proofEvidence') return 'evidence';
99
+ if (rowKind === 'gap') return 'proofGap';
100
+ if (rowKind === 'sourcemap' || rowKind === 'mapping' || rowKind === 'sourceMapMapping') return 'sourceMap';
101
+ return rowKind;
102
+ }
103
+
89
104
  function normalizeResourceGraphRow(rowKind) {
90
105
  if (rowKind === 'language') return 'sourceLanguage';
91
106
  if (rowKind === 'path') return 'sourcePath';
@@ -220,6 +235,9 @@ function normalizeParadigmRow(rowKind) {
220
235
  }
221
236
 
222
237
  function normalizeNativeSourceRow(rowKind) {
238
+ if (rowKind === 'sourceLanguage') return 'language';
239
+ if (rowKind === 'path') return 'sourcePath';
240
+ if (rowKind === 'frontierNode' || rowKind === 'frontierNodeId' || rowKind === 'frontierNodeIds') return 'frontierNodes';
223
241
  if (rowKind === 'proofEvidence') return 'evidence';
224
242
  if (rowKind === 'sourcemap' || rowKind === 'mapping' || rowKind === 'sourceMapMapping') return 'sourceMap';
225
243
  if (rowKind === 'candidate') return 'mergeCandidate';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshift-labs/frontier-lang-parser",
3
- "version": "0.3.82",
3
+ "version": "0.3.84",
4
4
  "description": "Parser for the first Frontier Lang .frontier syntax slice.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build": "node scripts/build.mjs",
25
- "test": "npm run build && node test/smoke.mjs && node test/source-syntax-family-summary-smoke.mjs && node test/resource-graph-source-syntax-smoke.mjs && node test/member-identity-smoke.mjs && node test/generic-row-parse-identity-smoke.mjs && node test/type-variant-payload-smoke.mjs && node test/type-generic-ref-smoke.mjs && node test/type-parameter-constraints-smoke.mjs && node test/type-structural-expression-smoke.mjs && node test/action-body-smoke.mjs && node test/action-structured-literals-smoke.mjs && node test/action-return-smoke.mjs && node test/action-else-smoke.mjs && node test/action-match-smoke.mjs && node test/action-for-in-smoke.mjs && node test/action-repeat-smoke.mjs && node test/action-call-smoke.mjs && node test/semantic-operation-edit-smoke.mjs && node test/target-projection-aggregate-smoke.mjs && node test/conversion-constraint-fields-smoke.mjs && node test/conversion-evidence-smoke.mjs && node test/gate-admission-evidence-smoke.mjs && node test/package-canvas-surface-smoke.mjs && node test/view-render-graph-smoke.mjs && node test/view-source-syntax-smoke.mjs && node test/resource-graph-smoke.mjs && node test/machine-graph-smoke.mjs && node test/interlingua-smoke.mjs && node test/dialect-registry-smoke.mjs",
25
+ "test": "npm run build && node test/smoke.mjs && node test/source-syntax-family-summary-smoke.mjs && node test/resource-graph-source-syntax-smoke.mjs && node test/tgt-source-smoke.mjs && node test/native-source-rows-smoke.mjs && node test/member-identity-smoke.mjs && node test/generic-row-parse-identity-smoke.mjs && node test/type-variant-payload-smoke.mjs && node test/type-generic-ref-smoke.mjs && node test/type-parameter-constraints-smoke.mjs && node test/type-structural-expression-smoke.mjs && node test/action-body-smoke.mjs && node test/action-structured-literals-smoke.mjs && node test/action-return-smoke.mjs && node test/action-else-smoke.mjs && node test/action-match-smoke.mjs && node test/action-for-in-smoke.mjs && node test/action-repeat-smoke.mjs && node test/action-call-smoke.mjs && node test/semantic-operation-edit-smoke.mjs && node test/target-projection-aggregate-smoke.mjs && node test/conversion-constraint-fields-smoke.mjs && node test/conversion-evidence-smoke.mjs && node test/gate-admission-evidence-smoke.mjs && node test/package-canvas-surface-smoke.mjs && node test/view-render-graph-smoke.mjs && node test/view-source-syntax-smoke.mjs && node test/resource-graph-smoke.mjs && node test/machine-graph-smoke.mjs && node test/interlingua-smoke.mjs && node test/dialect-registry-smoke.mjs",
26
26
  "typecheck": "node ./node_modules/typescript/bin/tsc --noEmit -p test/tsconfig.json",
27
27
  "fuzz": "npm run build && node fuzz/smoke.mjs",
28
28
  "bench": "npm run build && node bench/smoke.mjs",