MapCSS/0.2/BNF
Jump to navigation
Jump to search
This page contains BNF for MapCSS 0.2. This grammar is SLR. Note that it requires a tokeniser that only produces a whitespace token immediately following an object.
ruleset ::= rule | ruleset rule;
rule ::= selectors declarations | import;
import ::= AT "import" "url" "(" QUOTED ")" ID ";";
selectors ::= uSelectors | uSelectors ",";
uSelectors ::= selector | uSelectors "," selector;
selector ::= subselector | selector subselector;
subselector ::= object SPACE | object zoom | object zoom tests | maybeClass;
zoom ::= PIPE "z" range | ;
range ::= NUMBER | NUMBER "-" NUMBER | NUMBER "-" | "-" NUMBER;
tests ::= test | tests test;
test ::= "[" condition "]";
condition ::= tag binary value | unary tag | tag;
tag ::= key | tag ":" key;
key ::= ID;
value ::= ID | REGEX | NUMBER;
binary ::= "=" | "!=" | "=~" | "<" | ">" | "<=" | ">=";
unary ::= "-" | "!";
maybeClass ::= class | "!" class;
class ::= "." ID | ":" ID;
object ::= "node" | "way" | "relation" | "area" | "line" | "canvas" | "*" | ;
declarations ::= declaration | declarations declaration;
declaration ::= "{" styleset "}" | "{" "}";
styleset ::= uStyleset | uStyleset ";" ;
uStyleset ::= style | uStyleset ";" style;
style ::= key ":" specifier;
specifier ::= named | sizes | colour | url | eval;
named ::= ID;
sizes ::= size | sizes "," size;
size ::= NUMBER units;
colour ::= HASHCOLOUR | "rgb" "(" NUMBER "," NUMBER "," NUMBER ")" | "rgba" "(" NUMBER "," NUMBER "," NUMBER "," NUMBER ")";
url ::= "url" "(" urlContent ")";
urlContent ::= QUOTED | eval;
units ::= "px" | "pt" | "%" | ;
eval ::= "eval" "(" QUOTED ")";
Compatibility issues
- With Potlatch 2
- Potlatch 2 uses the :area pseudo-class to detect areas. This grammar will trip here because area is a keyword not an identifier. The wiki page on 0.2 seems to suggest that :closed should be used here instead.
- Potlatch 2 does not expect URLs to be surrounded by url('blah'), this grammar does.
- With Kothic
- Kothic does not expect URLs to be surrounded by url('blah'), this grammar does.
- Kothic does not expect eval expressions to have quotes inside, this grammar does.