@aehrc/ecl-core 1.4.0 → 1.6.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/canonical/canonical-printer.d.ts.map +1 -1
- package/dist/canonical/normaliser.d.ts.map +1 -1
- package/dist/formatter/ast-printer.d.ts.map +1 -1
- package/dist/index.cjs +77 -21
- package/dist/index.mjs +77 -21
- package/dist/parser/ast.d.ts +14 -2
- package/dist/parser/ast.d.ts.map +1 -1
- package/dist/parser/concept-extractor.d.ts.map +1 -1
- package/dist/parser/visitor.d.ts +5 -2
- package/dist/parser/visitor.d.ts.map +1 -1
- package/dist/semantic-tokens.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonical-printer.d.ts","sourceRoot":"","sources":["../../src/canonical/canonical-printer.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAKtB,KAAK,oBAAoB,EAG1B,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,GAAG,iBAAiB,EACvC,UAAU,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,CAKR;
|
|
1
|
+
{"version":3,"file":"canonical-printer.d.ts","sourceRoot":"","sources":["../../src/canonical/canonical-printer.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EAKtB,KAAK,oBAAoB,EAG1B,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,GAAG,iBAAiB,EACvC,UAAU,EAAE,MAAM,EAClB,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,CAKR;AAwID;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAiBrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normaliser.d.ts","sourceRoot":"","sources":["../../src/canonical/normaliser.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"normaliser.d.ts","sourceRoot":"","sources":["../../src/canonical/normaliser.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,cAAc,EAgBpB,MAAM,eAAe,CAAC;AAGvB;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,GAAG,cAAc,CAEpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-printer.d.ts","sourceRoot":"","sources":["../../src/formatter/ast-printer.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,cAAc,EAUpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGnD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAK3G;
|
|
1
|
+
{"version":3,"file":"ast-printer.d.ts","sourceRoot":"","sources":["../../src/formatter/ast-printer.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,cAAc,EAUpB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAGnD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAK3G;AAkbD,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGnD"}
|
package/dist/index.cjs
CHANGED
|
@@ -41695,6 +41695,7 @@ var NodeType = /* @__PURE__ */ function(NodeType) {
|
|
|
41695
41695
|
NodeType["AttributeName"] = "AttributeName";
|
|
41696
41696
|
NodeType["AttributeValue"] = "AttributeValue";
|
|
41697
41697
|
NodeType["Wildcard"] = "Wildcard";
|
|
41698
|
+
NodeType["AlternateIdentifier"] = "AlternateIdentifier";
|
|
41698
41699
|
NodeType["FilterConstraint"] = "FilterConstraint";
|
|
41699
41700
|
NodeType["HistorySupplement"] = "HistorySupplement";
|
|
41700
41701
|
return NodeType;
|
|
@@ -41759,6 +41760,7 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41759
41760
|
range: this.getRange(ctx),
|
|
41760
41761
|
operator,
|
|
41761
41762
|
memberOf: memberOfCtx ? true : void 0,
|
|
41763
|
+
memberFields: memberOfCtx ? this.memberFields(memberOfCtx) : void 0,
|
|
41762
41764
|
focus: innerExpr
|
|
41763
41765
|
};
|
|
41764
41766
|
this.attachFiltersAndHistory(ctx, node);
|
|
@@ -41777,6 +41779,7 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41777
41779
|
range: this.getRange(ctx),
|
|
41778
41780
|
operator,
|
|
41779
41781
|
memberOf: memberOfCtx ? true : void 0,
|
|
41782
|
+
memberFields: memberOfCtx ? this.memberFields(memberOfCtx) : void 0,
|
|
41780
41783
|
focus
|
|
41781
41784
|
};
|
|
41782
41785
|
this.attachFiltersAndHistory(ctx, node);
|
|
@@ -41785,15 +41788,29 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41785
41788
|
visitEclfocusconcept(ctx) {
|
|
41786
41789
|
const conceptRef = ctx.eclconceptreference();
|
|
41787
41790
|
if (conceptRef) return this.visit(conceptRef);
|
|
41788
|
-
|
|
41791
|
+
const altId = ctx.altidentifier();
|
|
41792
|
+
if (altId) return this.alternateIdentifier(altId);
|
|
41793
|
+
return {
|
|
41789
41794
|
type: NodeType.Wildcard,
|
|
41790
41795
|
range: this.getRange(ctx)
|
|
41791
41796
|
};
|
|
41797
|
+
}
|
|
41798
|
+
alternateIdentifier(ctx) {
|
|
41799
|
+
const scheme = ctx.altidentifierschemealias()?.text ?? "";
|
|
41800
|
+
const quoted = ctx.altidentifiercodewithinquotes();
|
|
41801
|
+
const code = quoted ? quoted.text : ctx.altidentifiercodewithoutquotes()?.text ?? "";
|
|
41792
41802
|
return {
|
|
41793
|
-
type: NodeType.
|
|
41794
|
-
range: this.getRange(ctx)
|
|
41803
|
+
type: NodeType.AlternateIdentifier,
|
|
41804
|
+
range: this.getRange(ctx),
|
|
41805
|
+
identifier: quoted ? `"${scheme}#${code}"` : `${scheme}#${code}`,
|
|
41806
|
+
term: ctx.term()?.text
|
|
41795
41807
|
};
|
|
41796
41808
|
}
|
|
41809
|
+
/** Field names from `^ [a, b]`, `['*']` for `^ [*]`, undefined for a plain `^`. */
|
|
41810
|
+
memberFields(ctx) {
|
|
41811
|
+
if (ctx.wildcard()) return ["*"];
|
|
41812
|
+
return ctx.refsetfieldnameset()?.refsetfieldname().map((f) => f.text);
|
|
41813
|
+
}
|
|
41797
41814
|
visitEclconceptreference(ctx) {
|
|
41798
41815
|
const conceptId = ctx.conceptid().text;
|
|
41799
41816
|
const termCtx = ctx.term();
|
|
@@ -41814,6 +41831,8 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41814
41831
|
else if (ctx.ancestororselfof()) op = ">>";
|
|
41815
41832
|
else if (ctx.parentof()) op = ">!";
|
|
41816
41833
|
else if (ctx.parentorselfof()) op = ">>!";
|
|
41834
|
+
else if (ctx.top()) op = "!!>";
|
|
41835
|
+
else if (ctx.bottom()) op = "!!<";
|
|
41817
41836
|
return {
|
|
41818
41837
|
type: NodeType.ConstraintOperator,
|
|
41819
41838
|
range: this.getRange(ctx),
|
|
@@ -41973,7 +41992,7 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41973
41992
|
const nameSubExpr = nameCtx.subexpressionconstraint();
|
|
41974
41993
|
const nameNode = this.visit(nameSubExpr);
|
|
41975
41994
|
let attrName;
|
|
41976
|
-
if (nameNode?.focus?.type === NodeType.ConceptReference) {
|
|
41995
|
+
if (nameNode?.focus?.type === NodeType.ConceptReference && !nameNode.operator && !nameNode.memberOf && !nameNode.filters?.length && !nameNode.historySupplement) {
|
|
41977
41996
|
const conceptRef = nameNode.focus;
|
|
41978
41997
|
attrName = {
|
|
41979
41998
|
type: NodeType.AttributeName,
|
|
@@ -42024,12 +42043,14 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
42024
42043
|
rawValue: ctx.text
|
|
42025
42044
|
};
|
|
42026
42045
|
const cardinalityCtx = ctx.cardinality();
|
|
42046
|
+
const comparisonCtx = exprCompOp ?? ctx.numericcomparisonoperator() ?? ctx.stringcomparisonoperator() ?? ctx.booleancomparisonoperator();
|
|
42027
42047
|
return {
|
|
42028
42048
|
type: NodeType.Attribute,
|
|
42029
42049
|
range: this.getRange(ctx),
|
|
42030
42050
|
name: attrName,
|
|
42031
42051
|
value,
|
|
42032
42052
|
reversed,
|
|
42053
|
+
comparison: comparisonCtx ? comparisonCtx.text : void 0,
|
|
42033
42054
|
cardinality: cardinalityCtx ? "[" + cardinalityCtx.text + "]" : void 0
|
|
42034
42055
|
};
|
|
42035
42056
|
}
|
|
@@ -42865,6 +42886,7 @@ function extractConceptIds(ast, options) {
|
|
|
42865
42886
|
case NodeType.ConstraintOperator:
|
|
42866
42887
|
case NodeType.LogicalOperator:
|
|
42867
42888
|
case NodeType.Wildcard:
|
|
42889
|
+
case NodeType.AlternateIdentifier:
|
|
42868
42890
|
}
|
|
42869
42891
|
}
|
|
42870
42892
|
visitNode(ast);
|
|
@@ -44693,7 +44715,7 @@ function printExpression$1(node, depth, column, opts, src, isRoot = false) {
|
|
|
44693
44715
|
function printSubExpression$1(node, depth, column, opts, src, isRoot = false) {
|
|
44694
44716
|
let result = "";
|
|
44695
44717
|
if (node.operator) result += node.operator.operator + " ";
|
|
44696
|
-
if (node.memberOf) result += "^ ";
|
|
44718
|
+
if (node.memberOf) result += node.memberFields ? `^ [${node.memberFields.join(", ")}] ` : "^ ";
|
|
44697
44719
|
switch (node.focus.type) {
|
|
44698
44720
|
case NodeType.ConceptReference:
|
|
44699
44721
|
result += printConceptReference$1(node.focus);
|
|
@@ -44701,6 +44723,9 @@ function printSubExpression$1(node, depth, column, opts, src, isRoot = false) {
|
|
|
44701
44723
|
case NodeType.Wildcard:
|
|
44702
44724
|
result += "*";
|
|
44703
44725
|
break;
|
|
44726
|
+
case NodeType.AlternateIdentifier:
|
|
44727
|
+
result += node.focus.term ? node.focus.identifier + normalizeTerm(node.focus.term) : node.focus.identifier;
|
|
44728
|
+
break;
|
|
44704
44729
|
case NodeType.ExpressionConstraint: {
|
|
44705
44730
|
const innerExpr = node.focus;
|
|
44706
44731
|
if (opts.removeRedundantParentheses && !node.operator && !node.memberOf && !node.filters && !node.historySupplement) {
|
|
@@ -44875,10 +44900,8 @@ function printAttribute$1(node, depth, column, opts, src) {
|
|
|
44875
44900
|
if (node.name.conceptId) name = node.name.term ? node.name.conceptId + normalizeTerm(node.name.term) : node.name.conceptId;
|
|
44876
44901
|
else if (node.name.expression) name = printSubExpression$1(node.name.expression, depth, column, opts, src);
|
|
44877
44902
|
else name = src.slice(node.name.range.start.offset, node.name.range.end.offset);
|
|
44878
|
-
const
|
|
44879
|
-
const
|
|
44880
|
-
const compOp = opMatch ? opMatch[1] : "=";
|
|
44881
|
-
const hasHashPrefix = between.includes("#");
|
|
44903
|
+
const compOp = node.comparison ?? "=";
|
|
44904
|
+
const hasHashPrefix = src.slice(node.name.range.end.offset, node.value.range.start.offset).includes("#");
|
|
44882
44905
|
let value;
|
|
44883
44906
|
if (node.value.expression) value = printSubExpression$1(node.value.expression, depth, column + name.length + 3, opts, src);
|
|
44884
44907
|
else if (node.value.rawValue) value = hasHashPrefix ? "#" + node.value.rawValue : node.value.rawValue;
|
|
@@ -44902,22 +44925,27 @@ function lastLineLength(text) {
|
|
|
44902
44925
|
*/
|
|
44903
44926
|
function printCanonical(ast, sourceText, outerOperator) {
|
|
44904
44927
|
if (ast.type === NodeType.SubExpressionConstraint) return printSubExpression(ast, sourceText, outerOperator);
|
|
44905
|
-
return printExpression(ast, sourceText, outerOperator);
|
|
44928
|
+
return printExpression(ast, sourceText, outerOperator, outerOperator === void 0);
|
|
44906
44929
|
}
|
|
44907
|
-
|
|
44930
|
+
/**
|
|
44931
|
+
* `topLevel` is true where a full expression constraint is legal without parentheses: the whole
|
|
44932
|
+
* expression, or directly inside a pair of parentheses. Refined and dotted expressions are only
|
|
44933
|
+
* legal unparenthesised there.
|
|
44934
|
+
*/
|
|
44935
|
+
function printExpression(node, src, outerOperator, topLevel = false) {
|
|
44908
44936
|
const inner = node.expression;
|
|
44909
44937
|
switch (inner.type) {
|
|
44910
|
-
case NodeType.SubExpressionConstraint: return printSubExpression(inner, src, outerOperator);
|
|
44938
|
+
case NodeType.SubExpressionConstraint: return printSubExpression(inner, src, outerOperator, topLevel);
|
|
44911
44939
|
case NodeType.CompoundExpression: return printCompoundExpression(inner, src);
|
|
44912
44940
|
case NodeType.RefinedExpression: return printRefinedExpression(inner, src);
|
|
44913
44941
|
case NodeType.DottedExpression: return printDottedExpression(inner, src);
|
|
44914
44942
|
default: return String(inner);
|
|
44915
44943
|
}
|
|
44916
44944
|
}
|
|
44917
|
-
function printSubExpression(node, src, outerOperator) {
|
|
44945
|
+
function printSubExpression(node, src, outerOperator, topLevel = false) {
|
|
44918
44946
|
let result = "";
|
|
44919
44947
|
if (node.operator) result += node.operator.operator;
|
|
44920
|
-
if (node.memberOf) result += "^";
|
|
44948
|
+
if (node.memberOf) result += node.memberFields ? `^[${node.memberFields.join(",")}]` : "^";
|
|
44921
44949
|
switch (node.focus.type) {
|
|
44922
44950
|
case NodeType.ConceptReference:
|
|
44923
44951
|
result += printConceptReference(node.focus);
|
|
@@ -44925,11 +44953,12 @@ function printSubExpression(node, src, outerOperator) {
|
|
|
44925
44953
|
case NodeType.Wildcard:
|
|
44926
44954
|
result += "*";
|
|
44927
44955
|
break;
|
|
44956
|
+
case NodeType.AlternateIdentifier:
|
|
44957
|
+
result += node.focus.identifier;
|
|
44958
|
+
break;
|
|
44928
44959
|
case NodeType.ExpressionConstraint: {
|
|
44929
44960
|
const innerExpr = node.focus.expression;
|
|
44930
|
-
|
|
44931
|
-
else if (outerOperator && innerExpr.operator.operator === outerOperator) result += printExpression(node.focus, src, outerOperator);
|
|
44932
|
-
else result += "(" + printExpression(node.focus, src) + ")";
|
|
44961
|
+
result += parensRedundant(node, innerExpr, outerOperator, topLevel) ? printExpression(node.focus, src, outerOperator, topLevel) : "(" + printExpression(node.focus, src, void 0, true) + ")";
|
|
44933
44962
|
break;
|
|
44934
44963
|
}
|
|
44935
44964
|
}
|
|
@@ -44943,6 +44972,20 @@ function printSubExpression(node, src, outerOperator) {
|
|
|
44943
44972
|
}
|
|
44944
44973
|
return result;
|
|
44945
44974
|
}
|
|
44975
|
+
/** §5.5 redundant parenthesis removal: can the parens around `inner` (the focus of `node`) be dropped? */
|
|
44976
|
+
function parensRedundant(node, inner, outerOperator, topLevel) {
|
|
44977
|
+
if ((node.operator || node.memberOf) && !isBareFocus(inner)) return false;
|
|
44978
|
+
if ((node.filters?.length || node.historySupplement) && inner.type !== NodeType.SubExpressionConstraint) return false;
|
|
44979
|
+
if (inner.type === NodeType.SubExpressionConstraint) return true;
|
|
44980
|
+
const plain = !node.operator && !node.memberOf && !node.filters?.length && !node.historySupplement;
|
|
44981
|
+
if (topLevel && plain) return true;
|
|
44982
|
+
if (inner.type !== NodeType.CompoundExpression) return false;
|
|
44983
|
+
return inner.operator.operator !== "MINUS" && outerOperator !== void 0 && inner.operator.operator === outerOperator;
|
|
44984
|
+
}
|
|
44985
|
+
/** True when the expression is just a concept reference or wildcard, with nothing applied to it. */
|
|
44986
|
+
function isBareFocus(expr) {
|
|
44987
|
+
return expr.type === NodeType.SubExpressionConstraint && !expr.operator && !expr.memberOf && !expr.filters?.length && !expr.historySupplement && (expr.focus.type !== NodeType.ExpressionConstraint || isBareFocus(expr.focus.expression));
|
|
44988
|
+
}
|
|
44946
44989
|
function printCompoundExpression(node, src) {
|
|
44947
44990
|
const op = node.operator.operator;
|
|
44948
44991
|
return node.operands.map((operand) => printSubExpression(operand, src, op)).join(` ${op} `);
|
|
@@ -44981,10 +45024,8 @@ function printAttribute(node, src) {
|
|
|
44981
45024
|
if (node.name.conceptId) name = node.name.conceptId;
|
|
44982
45025
|
else if (node.name.expression) name = printSubExpression(node.name.expression, src);
|
|
44983
45026
|
else name = src.slice(node.name.range.start.offset, node.name.range.end.offset).trim();
|
|
44984
|
-
const
|
|
44985
|
-
const
|
|
44986
|
-
const compOp = opMatch ? opMatch[1] : "=";
|
|
44987
|
-
const hasHashPrefix = between.includes("#");
|
|
45027
|
+
const compOp = node.comparison ?? "=";
|
|
45028
|
+
const hasHashPrefix = src.slice(node.name.range.end.offset, node.value.range.start.offset).includes("#");
|
|
44988
45029
|
let value;
|
|
44989
45030
|
if (node.value.expression) value = printSubExpression(node.value.expression, src);
|
|
44990
45031
|
else if (node.value.rawValue) value = hasHashPrefix ? "#" + node.value.rawValue : node.value.rawValue;
|
|
@@ -45027,6 +45068,14 @@ function normaliseExpression(node, src) {
|
|
|
45027
45068
|
expression: normalised
|
|
45028
45069
|
};
|
|
45029
45070
|
}
|
|
45071
|
+
/**
|
|
45072
|
+
* `"LOINC#54486-6"` and `LOINC#54486-6` are the same code; quotes are only needed when the code
|
|
45073
|
+
* has characters the unquoted grammar form (alpha, digit, `-`, `.`, `_`) cannot hold.
|
|
45074
|
+
*/
|
|
45075
|
+
function unquoteIdentifier(identifier) {
|
|
45076
|
+
const unquoted = /^"([A-Za-z][A-Za-z0-9-]*#[A-Za-z0-9._-]+)"$/.exec(identifier);
|
|
45077
|
+
return unquoted ? unquoted[1] : identifier;
|
|
45078
|
+
}
|
|
45030
45079
|
function normaliseSubExpression(node, src) {
|
|
45031
45080
|
let focus;
|
|
45032
45081
|
switch (node.focus.type) {
|
|
@@ -45036,6 +45085,13 @@ function normaliseSubExpression(node, src) {
|
|
|
45036
45085
|
case NodeType.Wildcard:
|
|
45037
45086
|
focus = { ...node.focus };
|
|
45038
45087
|
break;
|
|
45088
|
+
case NodeType.AlternateIdentifier:
|
|
45089
|
+
focus = {
|
|
45090
|
+
...node.focus,
|
|
45091
|
+
identifier: unquoteIdentifier(node.focus.identifier),
|
|
45092
|
+
term: void 0
|
|
45093
|
+
};
|
|
45094
|
+
break;
|
|
45039
45095
|
case NodeType.ExpressionConstraint: focus = normaliseExpression(node.focus, src);
|
|
45040
45096
|
}
|
|
45041
45097
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -41698,6 +41698,7 @@ var NodeType = /* @__PURE__ */ function(NodeType) {
|
|
|
41698
41698
|
NodeType["AttributeName"] = "AttributeName";
|
|
41699
41699
|
NodeType["AttributeValue"] = "AttributeValue";
|
|
41700
41700
|
NodeType["Wildcard"] = "Wildcard";
|
|
41701
|
+
NodeType["AlternateIdentifier"] = "AlternateIdentifier";
|
|
41701
41702
|
NodeType["FilterConstraint"] = "FilterConstraint";
|
|
41702
41703
|
NodeType["HistorySupplement"] = "HistorySupplement";
|
|
41703
41704
|
return NodeType;
|
|
@@ -41762,6 +41763,7 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41762
41763
|
range: this.getRange(ctx),
|
|
41763
41764
|
operator,
|
|
41764
41765
|
memberOf: memberOfCtx ? true : void 0,
|
|
41766
|
+
memberFields: memberOfCtx ? this.memberFields(memberOfCtx) : void 0,
|
|
41765
41767
|
focus: innerExpr
|
|
41766
41768
|
};
|
|
41767
41769
|
this.attachFiltersAndHistory(ctx, node);
|
|
@@ -41780,6 +41782,7 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41780
41782
|
range: this.getRange(ctx),
|
|
41781
41783
|
operator,
|
|
41782
41784
|
memberOf: memberOfCtx ? true : void 0,
|
|
41785
|
+
memberFields: memberOfCtx ? this.memberFields(memberOfCtx) : void 0,
|
|
41783
41786
|
focus
|
|
41784
41787
|
};
|
|
41785
41788
|
this.attachFiltersAndHistory(ctx, node);
|
|
@@ -41788,15 +41791,29 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41788
41791
|
visitEclfocusconcept(ctx) {
|
|
41789
41792
|
const conceptRef = ctx.eclconceptreference();
|
|
41790
41793
|
if (conceptRef) return this.visit(conceptRef);
|
|
41791
|
-
|
|
41794
|
+
const altId = ctx.altidentifier();
|
|
41795
|
+
if (altId) return this.alternateIdentifier(altId);
|
|
41796
|
+
return {
|
|
41792
41797
|
type: NodeType.Wildcard,
|
|
41793
41798
|
range: this.getRange(ctx)
|
|
41794
41799
|
};
|
|
41800
|
+
}
|
|
41801
|
+
alternateIdentifier(ctx) {
|
|
41802
|
+
const scheme = ctx.altidentifierschemealias()?.text ?? "";
|
|
41803
|
+
const quoted = ctx.altidentifiercodewithinquotes();
|
|
41804
|
+
const code = quoted ? quoted.text : ctx.altidentifiercodewithoutquotes()?.text ?? "";
|
|
41795
41805
|
return {
|
|
41796
|
-
type: NodeType.
|
|
41797
|
-
range: this.getRange(ctx)
|
|
41806
|
+
type: NodeType.AlternateIdentifier,
|
|
41807
|
+
range: this.getRange(ctx),
|
|
41808
|
+
identifier: quoted ? `"${scheme}#${code}"` : `${scheme}#${code}`,
|
|
41809
|
+
term: ctx.term()?.text
|
|
41798
41810
|
};
|
|
41799
41811
|
}
|
|
41812
|
+
/** Field names from `^ [a, b]`, `['*']` for `^ [*]`, undefined for a plain `^`. */
|
|
41813
|
+
memberFields(ctx) {
|
|
41814
|
+
if (ctx.wildcard()) return ["*"];
|
|
41815
|
+
return ctx.refsetfieldnameset()?.refsetfieldname().map((f) => f.text);
|
|
41816
|
+
}
|
|
41800
41817
|
visitEclconceptreference(ctx) {
|
|
41801
41818
|
const conceptId = ctx.conceptid().text;
|
|
41802
41819
|
const termCtx = ctx.term();
|
|
@@ -41817,6 +41834,8 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41817
41834
|
else if (ctx.ancestororselfof()) op = ">>";
|
|
41818
41835
|
else if (ctx.parentof()) op = ">!";
|
|
41819
41836
|
else if (ctx.parentorselfof()) op = ">>!";
|
|
41837
|
+
else if (ctx.top()) op = "!!>";
|
|
41838
|
+
else if (ctx.bottom()) op = "!!<";
|
|
41820
41839
|
return {
|
|
41821
41840
|
type: NodeType.ConstraintOperator,
|
|
41822
41841
|
range: this.getRange(ctx),
|
|
@@ -41976,7 +41995,7 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
41976
41995
|
const nameSubExpr = nameCtx.subexpressionconstraint();
|
|
41977
41996
|
const nameNode = this.visit(nameSubExpr);
|
|
41978
41997
|
let attrName;
|
|
41979
|
-
if (nameNode?.focus?.type === NodeType.ConceptReference) {
|
|
41998
|
+
if (nameNode?.focus?.type === NodeType.ConceptReference && !nameNode.operator && !nameNode.memberOf && !nameNode.filters?.length && !nameNode.historySupplement) {
|
|
41980
41999
|
const conceptRef = nameNode.focus;
|
|
41981
42000
|
attrName = {
|
|
41982
42001
|
type: NodeType.AttributeName,
|
|
@@ -42027,12 +42046,14 @@ var ECLASTVisitor = class extends import_AbstractParseTreeVisitor.AbstractParseT
|
|
|
42027
42046
|
rawValue: ctx.text
|
|
42028
42047
|
};
|
|
42029
42048
|
const cardinalityCtx = ctx.cardinality();
|
|
42049
|
+
const comparisonCtx = exprCompOp ?? ctx.numericcomparisonoperator() ?? ctx.stringcomparisonoperator() ?? ctx.booleancomparisonoperator();
|
|
42030
42050
|
return {
|
|
42031
42051
|
type: NodeType.Attribute,
|
|
42032
42052
|
range: this.getRange(ctx),
|
|
42033
42053
|
name: attrName,
|
|
42034
42054
|
value,
|
|
42035
42055
|
reversed,
|
|
42056
|
+
comparison: comparisonCtx ? comparisonCtx.text : void 0,
|
|
42036
42057
|
cardinality: cardinalityCtx ? "[" + cardinalityCtx.text + "]" : void 0
|
|
42037
42058
|
};
|
|
42038
42059
|
}
|
|
@@ -42868,6 +42889,7 @@ function extractConceptIds(ast, options) {
|
|
|
42868
42889
|
case NodeType.ConstraintOperator:
|
|
42869
42890
|
case NodeType.LogicalOperator:
|
|
42870
42891
|
case NodeType.Wildcard:
|
|
42892
|
+
case NodeType.AlternateIdentifier:
|
|
42871
42893
|
}
|
|
42872
42894
|
}
|
|
42873
42895
|
visitNode(ast);
|
|
@@ -44696,7 +44718,7 @@ function printExpression$1(node, depth, column, opts, src, isRoot = false) {
|
|
|
44696
44718
|
function printSubExpression$1(node, depth, column, opts, src, isRoot = false) {
|
|
44697
44719
|
let result = "";
|
|
44698
44720
|
if (node.operator) result += node.operator.operator + " ";
|
|
44699
|
-
if (node.memberOf) result += "^ ";
|
|
44721
|
+
if (node.memberOf) result += node.memberFields ? `^ [${node.memberFields.join(", ")}] ` : "^ ";
|
|
44700
44722
|
switch (node.focus.type) {
|
|
44701
44723
|
case NodeType.ConceptReference:
|
|
44702
44724
|
result += printConceptReference$1(node.focus);
|
|
@@ -44704,6 +44726,9 @@ function printSubExpression$1(node, depth, column, opts, src, isRoot = false) {
|
|
|
44704
44726
|
case NodeType.Wildcard:
|
|
44705
44727
|
result += "*";
|
|
44706
44728
|
break;
|
|
44729
|
+
case NodeType.AlternateIdentifier:
|
|
44730
|
+
result += node.focus.term ? node.focus.identifier + normalizeTerm(node.focus.term) : node.focus.identifier;
|
|
44731
|
+
break;
|
|
44707
44732
|
case NodeType.ExpressionConstraint: {
|
|
44708
44733
|
const innerExpr = node.focus;
|
|
44709
44734
|
if (opts.removeRedundantParentheses && !node.operator && !node.memberOf && !node.filters && !node.historySupplement) {
|
|
@@ -44878,10 +44903,8 @@ function printAttribute$1(node, depth, column, opts, src) {
|
|
|
44878
44903
|
if (node.name.conceptId) name = node.name.term ? node.name.conceptId + normalizeTerm(node.name.term) : node.name.conceptId;
|
|
44879
44904
|
else if (node.name.expression) name = printSubExpression$1(node.name.expression, depth, column, opts, src);
|
|
44880
44905
|
else name = src.slice(node.name.range.start.offset, node.name.range.end.offset);
|
|
44881
|
-
const
|
|
44882
|
-
const
|
|
44883
|
-
const compOp = opMatch ? opMatch[1] : "=";
|
|
44884
|
-
const hasHashPrefix = between.includes("#");
|
|
44906
|
+
const compOp = node.comparison ?? "=";
|
|
44907
|
+
const hasHashPrefix = src.slice(node.name.range.end.offset, node.value.range.start.offset).includes("#");
|
|
44885
44908
|
let value;
|
|
44886
44909
|
if (node.value.expression) value = printSubExpression$1(node.value.expression, depth, column + name.length + 3, opts, src);
|
|
44887
44910
|
else if (node.value.rawValue) value = hasHashPrefix ? "#" + node.value.rawValue : node.value.rawValue;
|
|
@@ -44905,22 +44928,27 @@ function lastLineLength(text) {
|
|
|
44905
44928
|
*/
|
|
44906
44929
|
function printCanonical(ast, sourceText, outerOperator) {
|
|
44907
44930
|
if (ast.type === NodeType.SubExpressionConstraint) return printSubExpression(ast, sourceText, outerOperator);
|
|
44908
|
-
return printExpression(ast, sourceText, outerOperator);
|
|
44931
|
+
return printExpression(ast, sourceText, outerOperator, outerOperator === void 0);
|
|
44909
44932
|
}
|
|
44910
|
-
|
|
44933
|
+
/**
|
|
44934
|
+
* `topLevel` is true where a full expression constraint is legal without parentheses: the whole
|
|
44935
|
+
* expression, or directly inside a pair of parentheses. Refined and dotted expressions are only
|
|
44936
|
+
* legal unparenthesised there.
|
|
44937
|
+
*/
|
|
44938
|
+
function printExpression(node, src, outerOperator, topLevel = false) {
|
|
44911
44939
|
const inner = node.expression;
|
|
44912
44940
|
switch (inner.type) {
|
|
44913
|
-
case NodeType.SubExpressionConstraint: return printSubExpression(inner, src, outerOperator);
|
|
44941
|
+
case NodeType.SubExpressionConstraint: return printSubExpression(inner, src, outerOperator, topLevel);
|
|
44914
44942
|
case NodeType.CompoundExpression: return printCompoundExpression(inner, src);
|
|
44915
44943
|
case NodeType.RefinedExpression: return printRefinedExpression(inner, src);
|
|
44916
44944
|
case NodeType.DottedExpression: return printDottedExpression(inner, src);
|
|
44917
44945
|
default: return String(inner);
|
|
44918
44946
|
}
|
|
44919
44947
|
}
|
|
44920
|
-
function printSubExpression(node, src, outerOperator) {
|
|
44948
|
+
function printSubExpression(node, src, outerOperator, topLevel = false) {
|
|
44921
44949
|
let result = "";
|
|
44922
44950
|
if (node.operator) result += node.operator.operator;
|
|
44923
|
-
if (node.memberOf) result += "^";
|
|
44951
|
+
if (node.memberOf) result += node.memberFields ? `^[${node.memberFields.join(",")}]` : "^";
|
|
44924
44952
|
switch (node.focus.type) {
|
|
44925
44953
|
case NodeType.ConceptReference:
|
|
44926
44954
|
result += printConceptReference(node.focus);
|
|
@@ -44928,11 +44956,12 @@ function printSubExpression(node, src, outerOperator) {
|
|
|
44928
44956
|
case NodeType.Wildcard:
|
|
44929
44957
|
result += "*";
|
|
44930
44958
|
break;
|
|
44959
|
+
case NodeType.AlternateIdentifier:
|
|
44960
|
+
result += node.focus.identifier;
|
|
44961
|
+
break;
|
|
44931
44962
|
case NodeType.ExpressionConstraint: {
|
|
44932
44963
|
const innerExpr = node.focus.expression;
|
|
44933
|
-
|
|
44934
|
-
else if (outerOperator && innerExpr.operator.operator === outerOperator) result += printExpression(node.focus, src, outerOperator);
|
|
44935
|
-
else result += "(" + printExpression(node.focus, src) + ")";
|
|
44964
|
+
result += parensRedundant(node, innerExpr, outerOperator, topLevel) ? printExpression(node.focus, src, outerOperator, topLevel) : "(" + printExpression(node.focus, src, void 0, true) + ")";
|
|
44936
44965
|
break;
|
|
44937
44966
|
}
|
|
44938
44967
|
}
|
|
@@ -44946,6 +44975,20 @@ function printSubExpression(node, src, outerOperator) {
|
|
|
44946
44975
|
}
|
|
44947
44976
|
return result;
|
|
44948
44977
|
}
|
|
44978
|
+
/** §5.5 redundant parenthesis removal: can the parens around `inner` (the focus of `node`) be dropped? */
|
|
44979
|
+
function parensRedundant(node, inner, outerOperator, topLevel) {
|
|
44980
|
+
if ((node.operator || node.memberOf) && !isBareFocus(inner)) return false;
|
|
44981
|
+
if ((node.filters?.length || node.historySupplement) && inner.type !== NodeType.SubExpressionConstraint) return false;
|
|
44982
|
+
if (inner.type === NodeType.SubExpressionConstraint) return true;
|
|
44983
|
+
const plain = !node.operator && !node.memberOf && !node.filters?.length && !node.historySupplement;
|
|
44984
|
+
if (topLevel && plain) return true;
|
|
44985
|
+
if (inner.type !== NodeType.CompoundExpression) return false;
|
|
44986
|
+
return inner.operator.operator !== "MINUS" && outerOperator !== void 0 && inner.operator.operator === outerOperator;
|
|
44987
|
+
}
|
|
44988
|
+
/** True when the expression is just a concept reference or wildcard, with nothing applied to it. */
|
|
44989
|
+
function isBareFocus(expr) {
|
|
44990
|
+
return expr.type === NodeType.SubExpressionConstraint && !expr.operator && !expr.memberOf && !expr.filters?.length && !expr.historySupplement && (expr.focus.type !== NodeType.ExpressionConstraint || isBareFocus(expr.focus.expression));
|
|
44991
|
+
}
|
|
44949
44992
|
function printCompoundExpression(node, src) {
|
|
44950
44993
|
const op = node.operator.operator;
|
|
44951
44994
|
return node.operands.map((operand) => printSubExpression(operand, src, op)).join(` ${op} `);
|
|
@@ -44984,10 +45027,8 @@ function printAttribute(node, src) {
|
|
|
44984
45027
|
if (node.name.conceptId) name = node.name.conceptId;
|
|
44985
45028
|
else if (node.name.expression) name = printSubExpression(node.name.expression, src);
|
|
44986
45029
|
else name = src.slice(node.name.range.start.offset, node.name.range.end.offset).trim();
|
|
44987
|
-
const
|
|
44988
|
-
const
|
|
44989
|
-
const compOp = opMatch ? opMatch[1] : "=";
|
|
44990
|
-
const hasHashPrefix = between.includes("#");
|
|
45030
|
+
const compOp = node.comparison ?? "=";
|
|
45031
|
+
const hasHashPrefix = src.slice(node.name.range.end.offset, node.value.range.start.offset).includes("#");
|
|
44991
45032
|
let value;
|
|
44992
45033
|
if (node.value.expression) value = printSubExpression(node.value.expression, src);
|
|
44993
45034
|
else if (node.value.rawValue) value = hasHashPrefix ? "#" + node.value.rawValue : node.value.rawValue;
|
|
@@ -45030,6 +45071,14 @@ function normaliseExpression(node, src) {
|
|
|
45030
45071
|
expression: normalised
|
|
45031
45072
|
};
|
|
45032
45073
|
}
|
|
45074
|
+
/**
|
|
45075
|
+
* `"LOINC#54486-6"` and `LOINC#54486-6` are the same code; quotes are only needed when the code
|
|
45076
|
+
* has characters the unquoted grammar form (alpha, digit, `-`, `.`, `_`) cannot hold.
|
|
45077
|
+
*/
|
|
45078
|
+
function unquoteIdentifier(identifier) {
|
|
45079
|
+
const unquoted = /^"([A-Za-z][A-Za-z0-9-]*#[A-Za-z0-9._-]+)"$/.exec(identifier);
|
|
45080
|
+
return unquoted ? unquoted[1] : identifier;
|
|
45081
|
+
}
|
|
45033
45082
|
function normaliseSubExpression(node, src) {
|
|
45034
45083
|
let focus;
|
|
45035
45084
|
switch (node.focus.type) {
|
|
@@ -45039,6 +45088,13 @@ function normaliseSubExpression(node, src) {
|
|
|
45039
45088
|
case NodeType.Wildcard:
|
|
45040
45089
|
focus = { ...node.focus };
|
|
45041
45090
|
break;
|
|
45091
|
+
case NodeType.AlternateIdentifier:
|
|
45092
|
+
focus = {
|
|
45093
|
+
...node.focus,
|
|
45094
|
+
identifier: unquoteIdentifier(node.focus.identifier),
|
|
45095
|
+
term: void 0
|
|
45096
|
+
};
|
|
45097
|
+
break;
|
|
45042
45098
|
case NodeType.ExpressionConstraint: focus = normaliseExpression(node.focus, src);
|
|
45043
45099
|
}
|
|
45044
45100
|
return {
|
package/dist/parser/ast.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export declare enum NodeType {
|
|
|
24
24
|
AttributeName = "AttributeName",
|
|
25
25
|
AttributeValue = "AttributeValue",
|
|
26
26
|
Wildcard = "Wildcard",
|
|
27
|
+
AlternateIdentifier = "AlternateIdentifier",
|
|
27
28
|
FilterConstraint = "FilterConstraint",
|
|
28
29
|
HistorySupplement = "HistorySupplement"
|
|
29
30
|
}
|
|
@@ -39,7 +40,9 @@ export interface SubExpressionNode extends ASTNode {
|
|
|
39
40
|
type: NodeType.SubExpressionConstraint;
|
|
40
41
|
operator?: OperatorNode;
|
|
41
42
|
memberOf?: boolean;
|
|
42
|
-
|
|
43
|
+
/** Member field selection (`^ [refsetId, referencedComponentId]`), `['*']` for `^ [*]`. */
|
|
44
|
+
memberFields?: string[];
|
|
45
|
+
focus: ConceptReferenceNode | WildcardNode | AlternateIdentifierNode | ExpressionNode;
|
|
43
46
|
filters?: FilterConstraintNode[];
|
|
44
47
|
historySupplement?: HistorySupplementNode;
|
|
45
48
|
}
|
|
@@ -69,7 +72,7 @@ export interface ConceptReferenceNode extends ASTNode {
|
|
|
69
72
|
}
|
|
70
73
|
export interface OperatorNode extends ASTNode {
|
|
71
74
|
type: NodeType.ConstraintOperator;
|
|
72
|
-
operator: '<' | '<<' | '>' | '>>' | '<!' | '<<!' | '>!' | '>>!';
|
|
75
|
+
operator: '<' | '<<' | '>' | '>>' | '<!' | '<<!' | '>!' | '>>!' | '!!>' | '!!<';
|
|
73
76
|
}
|
|
74
77
|
export interface LogicalOperatorNode extends ASTNode {
|
|
75
78
|
type: NodeType.LogicalOperator;
|
|
@@ -131,6 +134,8 @@ export interface AttributeNode extends ASTNode {
|
|
|
131
134
|
name: AttributeNameNode;
|
|
132
135
|
value: AttributeValueNode;
|
|
133
136
|
reversed?: boolean;
|
|
137
|
+
/** Comparison between name and value; `=` when absent. */
|
|
138
|
+
comparison?: '=' | '!=' | '<' | '<=' | '>' | '>=';
|
|
134
139
|
/** Raw cardinality text including brackets, e.g. `[0..1]`. */
|
|
135
140
|
cardinality?: string;
|
|
136
141
|
}
|
|
@@ -148,6 +153,13 @@ export interface AttributeValueNode extends ASTNode {
|
|
|
148
153
|
export interface WildcardNode extends ASTNode {
|
|
149
154
|
type: NodeType.Wildcard;
|
|
150
155
|
}
|
|
156
|
+
/** A code from another code system, e.g. `LOINC#54486-6` or `"LOINC#54486-6"`. */
|
|
157
|
+
export interface AlternateIdentifierNode extends ASTNode {
|
|
158
|
+
type: NodeType.AlternateIdentifier;
|
|
159
|
+
/** The identifier as written, without the term: scheme alias, `#`, code, and any quotes. */
|
|
160
|
+
identifier: string;
|
|
161
|
+
term?: string;
|
|
162
|
+
}
|
|
151
163
|
export interface FilterConstraintNode extends ASTNode {
|
|
152
164
|
type: NodeType.FilterConstraint;
|
|
153
165
|
filterType: 'description' | 'concept' | 'member';
|
package/dist/parser/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/parser/ast.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,oBAAY,QAAQ;IAClB,oBAAoB,yBAAyB;IAC7C,uBAAuB,4BAA4B;IACnD,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,gBAAgB,qBAAqB;IACrC,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;IACrC,kBAAkB,uBAAuB;IACzC,eAAe,oBAAoB;IACnC,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,cAAc,mBAAmB;IACjC,QAAQ,aAAa;IACrB,gBAAgB,qBAAqB;IACrC,iBAAiB,sBAAsB;CACxC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,cAAe,SAAQ,OAAO;IAC7C,IAAI,EAAE,QAAQ,CAAC,oB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,GAAG,KAAK,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,CAAC;CACnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concept-extractor.d.ts","sourceRoot":"","sources":["../../src/parser/concept-extractor.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,
|
|
1
|
+
{"version":3,"file":"concept-extractor.d.ts","sourceRoot":"","sources":["../../src/parser/concept-extractor.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,EAkBd,KAAK,EACN,MAAM,OAAO,CAAC;AAsBf,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,gBAAgB,EAAE,CAqH9G;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKhE"}
|
package/dist/parser/visitor.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ECLVisitor } from './generated/grammar/ECLVisitor';
|
|
2
2
|
import { AbstractParseTreeVisitor } from 'antlr4ts/tree/AbstractParseTreeVisitor';
|
|
3
|
-
import { ExpressionNode, ConceptReferenceNode, SubExpressionNode, CompoundExpressionNode, RefinedExpressionNode, DottedExpressionNode, DottedAttributeNode, OperatorNode, RefinementNode, AttributeNode, WildcardNode, FilterConstraintNode, HistorySupplementNode } from './ast';
|
|
3
|
+
import { ExpressionNode, ConceptReferenceNode, SubExpressionNode, CompoundExpressionNode, RefinedExpressionNode, DottedExpressionNode, DottedAttributeNode, OperatorNode, RefinementNode, AttributeNode, WildcardNode, AlternateIdentifierNode, FilterConstraintNode, HistorySupplementNode } from './ast';
|
|
4
4
|
import * as ECL from './generated/grammar/ECLParser';
|
|
5
5
|
export declare class ECLASTVisitor extends AbstractParseTreeVisitor<any> implements ECLVisitor<any> {
|
|
6
6
|
protected defaultResult(): any;
|
|
7
7
|
private getRange;
|
|
8
8
|
visitExpressionconstraint(ctx: ECL.ExpressionconstraintContext): ExpressionNode;
|
|
9
9
|
visitSubexpressionconstraint(ctx: ECL.SubexpressionconstraintContext): SubExpressionNode;
|
|
10
|
-
visitEclfocusconcept(ctx: ECL.EclfocusconceptContext): ConceptReferenceNode | WildcardNode;
|
|
10
|
+
visitEclfocusconcept(ctx: ECL.EclfocusconceptContext): ConceptReferenceNode | WildcardNode | AlternateIdentifierNode;
|
|
11
|
+
private alternateIdentifier;
|
|
12
|
+
/** Field names from `^ [a, b]`, `['*']` for `^ [*]`, undefined for a plain `^`. */
|
|
13
|
+
private memberFields;
|
|
11
14
|
visitEclconceptreference(ctx: ECL.EclconceptreferenceContext): ConceptReferenceNode;
|
|
12
15
|
visitConstraintoperator(ctx: ECL.ConstraintoperatorContext): OperatorNode;
|
|
13
16
|
visitCompoundexpressionconstraint(ctx: ECL.CompoundexpressionconstraintContext): CompoundExpressionNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visitor.d.ts","sourceRoot":"","sources":["../../src/parser/visitor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,KAAK,GAAG,MAAM,+BAA+B,CAAC;AACrD,OAAO,EACL,cAAc,EAGd,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,cAAc,EAGd,aAAa,EAGb,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,OAAO,CAAC;AAGf,qBAAa,aAAc,SAAQ,wBAAwB,CAAC,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OAAO,CAAC,gCAAgC;IAwBxC,OAAO,CAAC,+BAA+B;IAyBvC,gFAAgF;IAChF,OAAO,CAAC,uBAAuB;IAQ/B,mFAAmF;IACnF,OAAO,CAAC,mBAAmB;IAqB3B,iGAAiG;IACjG,OAAO,CAAC,2BAA2B;CAapC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic-tokens.d.ts","sourceRoot":"","sources":["../src/semantic-tokens.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"semantic-tokens.d.ts","sourceRoot":"","sources":["../src/semantic-tokens.ts"],"names":[],"mappings":"AAkDA,8CAA8C;AAC9C,eAAO,MAAM,aAAa,0GAUhB,CAAC;AAEX,eAAO,MAAM,iBAAiB,EAAE,MAAM,EAAO,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AA8FD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAgNnE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aehrc/ecl-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"node-fetch": "^2.7.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@types/node": "^26.
|
|
53
|
+
"@types/node": "^26.6.3",
|
|
54
54
|
"@types/node-fetch": "^2.6.9",
|
|
55
55
|
"antlr4ts-cli": "^0.5.0-alpha.4",
|
|
56
56
|
"rimraf": "^5.0.5",
|
|
57
57
|
"typescript": "^6.0.2",
|
|
58
58
|
"vite": "^8.2.2",
|
|
59
|
-
"vite-plugin-dts": "^5.
|
|
59
|
+
"vite-plugin-dts": "^5.1.1",
|
|
60
60
|
"vite-plugin-node-polyfills": "^0.28.0"
|
|
61
61
|
}
|
|
62
62
|
}
|