Skip to content

Commit

Permalink
Allow >[role] and <[role]
Browse files Browse the repository at this point in the history
  • Loading branch information
Famlam authored and frodrigo committed Nov 18, 2023
1 parent b1ce311 commit c43f0b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions mapcss/MapCSS.g4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mapcss/MapCSSListenerL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
6 changes: 6 additions & 0 deletions plugins/tests/test_mapcss_parsing_evaluation.validator.mapcss
Original file line number Diff line number Diff line change
Expand Up @@ -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";}

0 comments on commit c43f0b0

Please sign in to comment.