Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "top of set" and "bottom of set" expressions #10

Merged
merged 8 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions com.b2international.snomed.ecl.examples/Basic/Bottom.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* The expression constraint below evaluates to all concepts in the substrate that do not have a child or descendant within the sub-expression.
* In this example the "bottom" descendants are leafs of the sub-hierarchy starting with 224777007|Physical environment| and concepts like
* 224786002 |Open air environment| will not be present in the result set as they also have a child concept within the same sub-hierarchy.
*/

!!< (<< 224777007|Physical environment|)
7 changes: 7 additions & 0 deletions com.b2international.snomed.ecl.examples/Basic/Top.ecl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* The expression constraint below evaluates to all concepts in the substrate that do not have a parent or ancestor within the sub-expression.
* In this example the "top" ancestors are 260787004|Physical object| and 373873005|Pharmaceutical / biologic product| as the concept is a
* drug-device combination product.
*/

!!> (>> 411114003|Drug coated stent|)
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getParentOrSelfOfAccess().getGroup(), "rule__ParentOrSelfOf__Group__0");
builder.put(grammarAccess.getAncestorOfAccess().getGroup(), "rule__AncestorOf__Group__0");
builder.put(grammarAccess.getAncestorOrSelfOfAccess().getGroup(), "rule__AncestorOrSelfOf__Group__0");
builder.put(grammarAccess.getTopAccess().getGroup(), "rule__Top__Group__0");
builder.put(grammarAccess.getBottomAccess().getGroup(), "rule__Bottom__Group__0");
builder.put(grammarAccess.getMemberOfAccess().getGroup(), "rule__MemberOf__Group__0");
builder.put(grammarAccess.getMemberOfAccess().getGroup_1(), "rule__MemberOf__Group_1__0");
builder.put(grammarAccess.getMemberOfAccess().getGroup_1_1(), "rule__MemberOf__Group_1_1__0");
Expand Down Expand Up @@ -192,6 +194,8 @@ private static void init(ImmutableMap.Builder<AbstractElement, String> builder,
builder.put(grammarAccess.getParentOrSelfOfAccess().getConstraintAssignment_1(), "rule__ParentOrSelfOf__ConstraintAssignment_1");
builder.put(grammarAccess.getAncestorOfAccess().getConstraintAssignment_1(), "rule__AncestorOf__ConstraintAssignment_1");
builder.put(grammarAccess.getAncestorOrSelfOfAccess().getConstraintAssignment_1(), "rule__AncestorOrSelfOf__ConstraintAssignment_1");
builder.put(grammarAccess.getTopAccess().getConstraintAssignment_1(), "rule__Top__ConstraintAssignment_1");
builder.put(grammarAccess.getBottomAccess().getConstraintAssignment_1(), "rule__Bottom__ConstraintAssignment_1");
builder.put(grammarAccess.getMemberOfAccess().getRefsetFieldsAssignment_1_1_0(), "rule__MemberOf__RefsetFieldsAssignment_1_1_0");
builder.put(grammarAccess.getMemberOfAccess().getRefsetFieldsAssignment_1_1_1_1(), "rule__MemberOf__RefsetFieldsAssignment_1_1_1_1");
builder.put(grammarAccess.getMemberOfAccess().getConstraintAssignment_2(), "rule__MemberOf__ConstraintAssignment_2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,56 @@ finally {
restoreStackSize(stackSize);
}

// Entry rule entryRuleTop
entryRuleTop
:
{ before(grammarAccess.getTopRule()); }
ruleTop
{ after(grammarAccess.getTopRule()); }
EOF
;

// Rule Top
ruleTop
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getTopAccess().getGroup()); }
(rule__Top__Group__0)
{ after(grammarAccess.getTopAccess().getGroup()); }
)
;
finally {
restoreStackSize(stackSize);
}

// Entry rule entryRuleBottom
entryRuleBottom
:
{ before(grammarAccess.getBottomRule()); }
ruleBottom
{ after(grammarAccess.getBottomRule()); }
EOF
;

// Rule Bottom
ruleBottom
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getBottomAccess().getGroup()); }
(rule__Bottom__Group__0)
{ after(grammarAccess.getBottomAccess().getGroup()); }
)
;
finally {
restoreStackSize(stackSize);
}

// Entry rule entryRuleMemberOf
entryRuleMemberOf
:
Expand Down Expand Up @@ -2649,9 +2699,21 @@ rule__SubExpressionConstraint__Alternatives
)
|
(
{ before(grammarAccess.getSubExpressionConstraintAccess().getEclFocusConceptParserRuleCall_8()); }
{ before(grammarAccess.getSubExpressionConstraintAccess().getTopParserRuleCall_8()); }
ruleTop
{ after(grammarAccess.getSubExpressionConstraintAccess().getTopParserRuleCall_8()); }
)
|
(
{ before(grammarAccess.getSubExpressionConstraintAccess().getBottomParserRuleCall_9()); }
ruleBottom
{ after(grammarAccess.getSubExpressionConstraintAccess().getBottomParserRuleCall_9()); }
)
|
(
{ before(grammarAccess.getSubExpressionConstraintAccess().getEclFocusConceptParserRuleCall_10()); }
ruleEclFocusConcept
{ after(grammarAccess.getSubExpressionConstraintAccess().getEclFocusConceptParserRuleCall_8()); }
{ after(grammarAccess.getSubExpressionConstraintAccess().getEclFocusConceptParserRuleCall_10()); }
)
;
finally {
Expand Down Expand Up @@ -5289,6 +5351,114 @@ finally {
}


rule__Top__Group__0
@init {
int stackSize = keepStackSize();
}
:
rule__Top__Group__0__Impl
rule__Top__Group__1
;
finally {
restoreStackSize(stackSize);
}

rule__Top__Group__0__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getTopAccess().getDBL_EM_GTTerminalRuleCall_0()); }
RULE_DBL_EM_GT
{ after(grammarAccess.getTopAccess().getDBL_EM_GTTerminalRuleCall_0()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__Top__Group__1
@init {
int stackSize = keepStackSize();
}
:
rule__Top__Group__1__Impl
;
finally {
restoreStackSize(stackSize);
}

rule__Top__Group__1__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getTopAccess().getConstraintAssignment_1()); }
(rule__Top__ConstraintAssignment_1)
{ after(grammarAccess.getTopAccess().getConstraintAssignment_1()); }
)
;
finally {
restoreStackSize(stackSize);
}


rule__Bottom__Group__0
@init {
int stackSize = keepStackSize();
}
:
rule__Bottom__Group__0__Impl
rule__Bottom__Group__1
;
finally {
restoreStackSize(stackSize);
}

rule__Bottom__Group__0__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getBottomAccess().getDBL_EM_LTTerminalRuleCall_0()); }
RULE_DBL_EM_LT
{ after(grammarAccess.getBottomAccess().getDBL_EM_LTTerminalRuleCall_0()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__Bottom__Group__1
@init {
int stackSize = keepStackSize();
}
:
rule__Bottom__Group__1__Impl
;
finally {
restoreStackSize(stackSize);
}

rule__Bottom__Group__1__Impl
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getBottomAccess().getConstraintAssignment_1()); }
(rule__Bottom__ConstraintAssignment_1)
{ after(grammarAccess.getBottomAccess().getConstraintAssignment_1()); }
)
;
finally {
restoreStackSize(stackSize);
}


rule__MemberOf__Group__0
@init {
int stackSize = keepStackSize();
Expand Down Expand Up @@ -10796,6 +10966,36 @@ finally {
restoreStackSize(stackSize);
}

rule__Top__ConstraintAssignment_1
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getTopAccess().getConstraintEclFocusConceptParserRuleCall_1_0()); }
ruleEclFocusConcept
{ after(grammarAccess.getTopAccess().getConstraintEclFocusConceptParserRuleCall_1_0()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__Bottom__ConstraintAssignment_1
@init {
int stackSize = keepStackSize();
}
:
(
{ before(grammarAccess.getBottomAccess().getConstraintEclFocusConceptParserRuleCall_1_0()); }
ruleEclFocusConcept
{ after(grammarAccess.getBottomAccess().getConstraintEclFocusConceptParserRuleCall_1_0()); }
)
;
finally {
restoreStackSize(stackSize);
}

rule__MemberOf__RefsetFieldsAssignment_1_1_0
@init {
int stackSize = keepStackSize();
Expand Down Expand Up @@ -12185,6 +12385,10 @@ RULE_LT_EM : '<!';

RULE_GT_EM : '>!';

RULE_DBL_EM_LT : '!!<';

RULE_DBL_EM_GT : '!!>';

RULE_GTE : '>=';

RULE_LTE : '<=';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
RULE_ACCEPTABLE_IN_KEYWORD=27
RULE_ACTIVE_KEYWORD=34
RULE_ALPHA=10
RULE_CARET=61
RULE_CARET=63
RULE_CASE_SIGNIFICANCE_ID_KEYWORD=22
RULE_COLON=53
RULE_COMMA=7
RULE_CONCEPT_SHORT_KEYWORD=11
RULE_CONJUNCTION_KEYWORD=6
RULE_CURLY_CLOSE=68
RULE_CURLY_OPEN=67
RULE_CURLY_CLOSE=70
RULE_CURLY_OPEN=69
RULE_DASH=8
RULE_DBL_EM_GT=61
RULE_DBL_EM_LT=62
RULE_DBL_GT=60
RULE_DBL_GT_EM=59
RULE_DBL_LT=57
Expand All @@ -22,8 +24,8 @@ RULE_DIALECT_KEYWORD=33
RULE_DIGIT=5
RULE_DISJUNCTION_KEYWORD=46
RULE_DOT=54
RULE_DOUBLE_CURLY_CLOSE=72
RULE_DOUBLE_CURLY_OPEN=71
RULE_DOUBLE_CURLY_CLOSE=74
RULE_DOUBLE_CURLY_OPEN=73
RULE_EFFECTIVE_TIME_KEYWORD=26
RULE_EQUAL=47
RULE_EXACT_KEYWORD=37
Expand All @@ -32,7 +34,7 @@ RULE_FALSE_KEYWORD=20
RULE_GT=49
RULE_GTE=51
RULE_GT_EM=58
RULE_HASH=70
RULE_HASH=72
RULE_HISTORY_KEYWORD=21
RULE_ID_KEYWORD=15
RULE_KEYWORD=16
Expand All @@ -45,28 +47,28 @@ RULE_MATCH_KEYWORD=38
RULE_MAX_KEYWORD=45
RULE_MEMBER_SHORT_KEYWORD=13
RULE_MIN_KEYWORD=43
RULE_ML_COMMENT=74
RULE_ML_COMMENT=76
RULE_MODULEID_KEYWORD=32
RULE_MOD_KEYWORD=44
RULE_NOT_EQUAL=48
RULE_PIPE_DELIMITED_STRING=73
RULE_PIPE_DELIMITED_STRING=75
RULE_PLUS=18
RULE_PREFERRED_IN_KEYWORD=28
RULE_REGEX_KEYWORD=39
RULE_REVERSED=14
RULE_ROUND_CLOSE=66
RULE_ROUND_OPEN=65
RULE_ROUND_CLOSE=68
RULE_ROUND_OPEN=67
RULE_SEMANTIC_TAG_KEYWORD=29
RULE_SL_COMMENT=75
RULE_SQUARE_CLOSE=63
RULE_SQUARE_OPEN=62
RULE_SL_COMMENT=77
RULE_SQUARE_CLOSE=65
RULE_SQUARE_OPEN=64
RULE_STRING=4
RULE_TERM_KEYWORD=40
RULE_TO=69
RULE_TO=71
RULE_TRUE_KEYWORD=19
RULE_TYPEID_KEYWORD=35
RULE_TYPE_KEYWORD=41
RULE_UNDERSCORE=9
RULE_WILDCARD=17
RULE_WILD_KEYWORD=42
RULE_WS=64
RULE_WS=66
Loading
Loading