@shapeshift-labs/frontier-lang-parser 0.3.78 → 0.3.80
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,7 +4,7 @@ import { readTypeExpressionSyntaxChildren } from './source-syntax-type-expressio
|
|
|
4
4
|
import { readViewSyntaxChildren } from './source-syntax-view-children.js';
|
|
5
5
|
import { inspectTypeExpressionSyntax } from './type-expressions.js';
|
|
6
6
|
import { inspectVariantPayload } from './type-variants.js';
|
|
7
|
-
const ROW_NAME_PATTERN = '([
|
|
7
|
+
const ROW_NAME_PATTERN = '([^\\s{}]+)';
|
|
8
8
|
|
|
9
9
|
export function readSourceSyntaxChildren(source, block, options = {}) {
|
|
10
10
|
let children = [];
|
|
@@ -277,8 +277,8 @@ function genericUnknownRowChild(source, block, options, line, config, rowKind, n
|
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
function unknownGenericRowsFailClosed(config) { return config.
|
|
281
|
-
function unsupportedGenericRowReason(config) { return config.
|
|
280
|
+
function unknownGenericRowsFailClosed(config) { return config.failClosedUnknownRows === true; }
|
|
281
|
+
function unsupportedGenericRowReason(config) { return config.unknownRowReason ?? 'unsupported-generic-row'; }
|
|
282
282
|
|
|
283
283
|
function readBodyLines(source, block) { return readTextLines(source, block.bodyStartOffset, block.bodyEndOffset); }
|
|
284
284
|
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
const appRows = words('mount provide provides required requires require route event asset gate gap proofGap evidence proofEvidence');
|
|
1
|
+
const appRows = words('role sourcePath path sourceHash host hostId mount provide provides required requires require route event asset gate gap proofGap evidence proofEvidence');
|
|
2
2
|
const canvasRows = words('element command state stateWrite trace gap proofGap evidence proofEvidence');
|
|
3
3
|
const constraintRows = words('variable var constraint hard soft preference prefer collapse admission');
|
|
4
4
|
const dialectRows = words('dialect record extern');
|
|
5
5
|
const interlinguaRows = words('layer constraint edge obligation proofObligation proof lowering lower source sourceLift lift evidence');
|
|
6
6
|
const machineRows = words('label directive register reg flag conditionFlag basicBlock block instruction inst instr op opcode operand arg memoryEffect memoryAccess load store atomic fence memory mem effect controlEdge edge branch call return ret interrupt irq exception proof proofObligation obligation gap proofGap evidence proofEvidence');
|
|
7
|
+
const migrationRows = words('from fromVersion to toVersion change invariant invariants');
|
|
7
8
|
const packageRows = words('metadata dependency script export gap proofGap evidence proofEvidence');
|
|
8
9
|
const runtimeRows = words('host runtimeHost hostProfile sourceHost targetHost capability hostCapability hostBinding binding requirement runtimeRequirement requiredRuntime evidence proofEvidence gap proofGap');
|
|
9
10
|
const semanticEditRows = words('script semanticEditScript projection semanticEditProjection replay semanticEditReplay');
|
|
10
11
|
const gateAdmissionRows = words('gate evidence proofEvidence admission admissionDecision proofObligation obligation gap proofGap');
|
|
12
|
+
const coreFailClosed = (reason) => ({ failClosedUnknownRows: true, unknownRowReason: reason });
|
|
11
13
|
|
|
12
14
|
export const ROW_SYNTAX_CONFIG = Object.freeze({
|
|
13
15
|
interlingua: rowConfig('interlinguaRow', 'interlingua_row', interlinguaRows, normalizeInterlinguaRow),
|
|
@@ -19,14 +21,19 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
|
|
|
19
21
|
runtimeHosts: rowConfig('runtimeCapabilityRow', 'runtime_capability_row', runtimeRows, normalizeRuntimeCapabilityRow),
|
|
20
22
|
resourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('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 hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
|
|
21
23
|
semanticResourceGraph: rowConfig('resourceGraphRow', 'resource_graph_row', words('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 hb fence fenceEdge barrier barrierEdge trap traps undefined undefinedBehavior undefinedBehaviour ub conflict proof proofObligation obligation'), normalizeResourceGraphRow),
|
|
22
|
-
machineGraph: rowConfig('machineGraphRow', 'machine_graph_row', machineRows, normalizeMachineGraphRow),
|
|
23
|
-
executionGraph: rowConfig('machineGraphRow', 'machine_graph_row', machineRows, normalizeMachineGraphRow),
|
|
24
|
-
lowLevelGraph: rowConfig('machineGraphRow', 'machine_graph_row', machineRows, normalizeMachineGraphRow),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
machineGraph: rowConfig('machineGraphRow', 'machine_graph_row', machineRows, normalizeMachineGraphRow, coreFailClosed('unsupported-machine-graph-row')),
|
|
25
|
+
executionGraph: rowConfig('machineGraphRow', 'machine_graph_row', machineRows, normalizeMachineGraphRow, coreFailClosed('unsupported-machine-graph-row')),
|
|
26
|
+
lowLevelGraph: rowConfig('machineGraphRow', 'machine_graph_row', machineRows, normalizeMachineGraphRow, coreFailClosed('unsupported-machine-graph-row')),
|
|
27
|
+
migration: rowConfig('migrationRow', 'migration_row', migrationRows, normalizeMigrationRow, coreFailClosed('unsupported-migration-row')),
|
|
28
|
+
capability: rowConfig('capabilityRow', 'capability_row', words('capability category input returns effects resources adapter unsupported unsupportedTarget'), normalizeCapabilityRow, coreFailClosed('unsupported-capability-row')),
|
|
29
|
+
effect: rowConfig('effectRow', 'effect_row', words('capability input returns resources'), undefined, coreFailClosed('unsupported-effect-row')),
|
|
30
|
+
extern: rowConfig('externRow', 'extern_row', words('language target symbol input returns effects uses resources'), normalizeExternRow, coreFailClosed('unsupported-extern-row')),
|
|
31
|
+
lattice: rowConfig('latticeRow', 'lattice_row', words('carrier law laws frontierCrdt frontier-crdt lawChecker'), normalizeLatticeRow, coreFailClosed('unsupported-lattice-row')),
|
|
32
|
+
applicationSurface: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
|
|
33
|
+
appHost: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
|
|
34
|
+
plugin: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
|
|
35
|
+
pluginSurface: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
|
|
36
|
+
pluginContract: rowConfig('applicationSurfaceRow', 'application_surface_row', appRows, normalizeApplicationSurfaceRow, coreFailClosed('unsupported-application-surface-row')),
|
|
30
37
|
target: rowConfig('targetProjectionRow', 'target_projection_row', words('projection lowering layer')),
|
|
31
38
|
packageManifest: rowConfig('packageManifestRow', 'package_manifest_row', packageRows, normalizeProofEvidenceRows),
|
|
32
39
|
packageGraph: rowConfig('packageManifestRow', 'package_manifest_row', packageRows, normalizeProofEvidenceRows),
|
|
@@ -37,9 +44,9 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
|
|
|
37
44
|
possibilitySpace: rowConfig('constraintSpaceRow', 'constraint_space_row', constraintRows, normalizeConstraintSpaceRow),
|
|
38
45
|
decisionGraph: rowConfig('decisionGraphRow', 'decision_graph_row', words('node edge chunk gate evidence semanticChange change patchEvent patch admissionDecision admission candidateDecision candidate mergeDecision merge replay tournament tournamentCandidate panelProjection panel rsiLoop improvementFeedback feedback'), normalizeDecisionGraphRow),
|
|
39
46
|
admissionGraph: rowConfig('decisionGraphRow', 'decision_graph_row', words('node edge chunk gate evidence semanticChange change patchEvent patch admissionDecision admission candidateDecision candidate mergeDecision merge replay tournament tournamentCandidate panelProjection panel rsiLoop improvementFeedback feedback'), normalizeDecisionGraphRow),
|
|
40
|
-
gateEvidence: rowConfig('gateAdmissionEvidenceRow', 'gate_admission_evidence_row', gateAdmissionRows, normalizeGateAdmissionRow),
|
|
41
|
-
admissionEvidence: rowConfig('gateAdmissionEvidenceRow', 'gate_admission_evidence_row', gateAdmissionRows, normalizeGateAdmissionRow),
|
|
42
|
-
routeEvidence: rowConfig('gateAdmissionEvidenceRow', 'gate_admission_evidence_row', gateAdmissionRows, normalizeGateAdmissionRow),
|
|
47
|
+
gateEvidence: rowConfig('gateAdmissionEvidenceRow', 'gate_admission_evidence_row', gateAdmissionRows, normalizeGateAdmissionRow, coreFailClosed('unsupported-gate-admission-row')),
|
|
48
|
+
admissionEvidence: rowConfig('gateAdmissionEvidenceRow', 'gate_admission_evidence_row', gateAdmissionRows, normalizeGateAdmissionRow, coreFailClosed('unsupported-gate-admission-row')),
|
|
49
|
+
routeEvidence: rowConfig('gateAdmissionEvidenceRow', 'gate_admission_evidence_row', gateAdmissionRows, normalizeGateAdmissionRow, coreFailClosed('unsupported-gate-admission-row')),
|
|
43
50
|
operations: rowConfig('semanticOperationRow', 'semantic_operation_row', words('operation op'), normalizeOperationRow),
|
|
44
51
|
semanticOperations: rowConfig('semanticOperationRow', 'semantic_operation_row', words('operation op'), normalizeOperationRow),
|
|
45
52
|
semanticEdits: rowConfig('semanticEditRecordRow', 'semantic_edit_record_row', semanticEditRows, normalizeSemanticEditRow),
|
|
@@ -50,8 +57,8 @@ export const ROW_SYNTAX_CONFIG = Object.freeze({
|
|
|
50
57
|
nativeSource: rowConfig('nativeSourceRow', 'native_source_row', words('loss evidence proofEvidence sourceMap sourcemap mapping sourceMapMapping mergeCandidate candidate'), normalizeNativeSourceRow)
|
|
51
58
|
});
|
|
52
59
|
|
|
53
|
-
function rowConfig(childKind, idPrefix, rowKinds, normalize) {
|
|
54
|
-
return { childKind, idPrefix, rowKinds: new Set(rowKinds), normalize };
|
|
60
|
+
function rowConfig(childKind, idPrefix, rowKinds, normalize, options = {}) {
|
|
61
|
+
return { childKind, idPrefix, rowKinds: new Set(rowKinds), normalize, ...options };
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
function words(source) { return source.split(/\s+/); }
|
|
@@ -111,7 +118,33 @@ function normalizeMachineGraphRow(rowKind) {
|
|
|
111
118
|
return rowKind;
|
|
112
119
|
}
|
|
113
120
|
|
|
121
|
+
function normalizeMigrationRow(rowKind) {
|
|
122
|
+
if (rowKind === 'from') return 'fromVersion';
|
|
123
|
+
if (rowKind === 'to') return 'toVersion';
|
|
124
|
+
if (rowKind === 'invariant') return 'invariants';
|
|
125
|
+
return rowKind;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function normalizeCapabilityRow(rowKind) {
|
|
129
|
+
if (rowKind === 'unsupported') return 'unsupportedTarget';
|
|
130
|
+
return rowKind;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function normalizeExternRow(rowKind) {
|
|
134
|
+
if (rowKind === 'target') return 'language';
|
|
135
|
+
if (rowKind === 'uses') return 'effects';
|
|
136
|
+
return rowKind;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function normalizeLatticeRow(rowKind) {
|
|
140
|
+
if (rowKind === 'law') return 'laws';
|
|
141
|
+
if (rowKind === 'frontier-crdt') return 'frontierCrdt';
|
|
142
|
+
return rowKind;
|
|
143
|
+
}
|
|
144
|
+
|
|
114
145
|
function normalizeApplicationSurfaceRow(rowKind) {
|
|
146
|
+
if (rowKind === 'path') return 'sourcePath';
|
|
147
|
+
if (rowKind === 'hostId') return 'host';
|
|
115
148
|
if (rowKind === 'provide' || rowKind === 'provides') return 'provided-surface';
|
|
116
149
|
if (rowKind === 'required' || rowKind === 'requires' || rowKind === 'require') return 'required-capability';
|
|
117
150
|
if (rowKind === 'proofEvidence') return 'evidence';
|