From c43f0b0adabb49cef127a95e18f8340c2228f3c8 Mon Sep 17 00:00:00 2001 From: Famlam Date: Sat, 18 Nov 2023 13:34:45 +0100 Subject: [PATCH] Allow >[role] and <[role] --- mapcss/MapCSS.g4 | 6 ++++-- mapcss/MapCSSListenerL.py | 2 +- .../tests/test_mapcss_parsing_evaluation.validator.mapcss | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mapcss/MapCSS.g4 b/mapcss/MapCSS.g4 index 2c62f46db..ab5019859 100644 --- a/mapcss/MapCSS.g4 +++ b/mapcss/MapCSS.g4 @@ -156,11 +156,13 @@ rule_ selector : simple_selector | simple_selector simple_selector - | simple_selector OP_GT (link_selector | pseudo_class_selector)* simple_selector + | simple_selector parent_child_selector_operator (link_selector | pseudo_class_selector)* simple_selector | simple_selector simple_selector_operator simple_selector ; -simple_selector_operator : OP_LT | OP_INCLUDED_IN | OP_INTERSECTS | OP_SUBSET | OP_SUPERSET | OP_NOSUBSET | OP_NOSUPERSET; +parent_child_selector_operator : OP_GT | OP_LT; + +simple_selector_operator : OP_INCLUDED_IN | OP_INTERSECTS | OP_SUBSET | OP_SUPERSET | OP_NOSUBSET | OP_NOSUPERSET; link_selector : LBRACKET cssident /* ROLE */ valueOperator valueExpression RBRACKET diff --git a/mapcss/MapCSSListenerL.py b/mapcss/MapCSSListenerL.py index 5902c66b2..e0f576b41 100644 --- a/mapcss/MapCSSListenerL.py +++ b/mapcss/MapCSSListenerL.py @@ -39,7 +39,7 @@ def exitSelector(self, ctx:MapCSSParser.SelectorContext): 'type': 'selector', 'text': ctx.getText(), 'simple_selectors': self.simple_selectors, - 'operator': (ctx.simple_selector_operator() and ctx.simple_selector_operator().getText()) or (ctx.OP_GT() and ctx.OP_GT().getText()), + 'operator': (ctx.simple_selector_operator() and ctx.simple_selector_operator().getText()) or (ctx.parent_child_selector_operator() and ctx.parent_child_selector_operator().getText()), 'link_selectors': self.link_selectors, 'pseudo_class': self.pseudo_class}) diff --git a/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss b/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss index f89d23099..dd5fa2187 100644 --- a/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss +++ b/plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss @@ -433,3 +433,9 @@ node[URL_decode("M%C3%A1rio Leopoldo Pereira da C%C3%A2mara") == "Mário Leopold throwWarning: "test"; assertMatch: "node x=abcde"; } + + +way[x] > node[x] {throwWarning: "I should be dropped!"; assertNoMatch: "way x=1"; assertNoMatch: "node x=1";} +node[x] < way[x] {throwWarning: "I should be dropped!"; assertNoMatch: "way x=1"; assertNoMatch: "node x=1";} +way[x] >[index!=4] node[x] {throwWarning: "I should be dropped!"; assertNoMatch: "way x=1"; assertNoMatch: "node x=1";} +node[x] <[index!=4] way[x] {throwWarning: "I should be dropped!"; assertNoMatch: "way x=1"; assertNoMatch: "node x=1";}