processSelectorExpression method
In CSS3, the expressions are identifiers, strings, or of the form "an+b".
: [ [ PLUS | '-' | DIMENSION | NUMBER | STRING | IDENT ] S* ]+
num [0-9]+|[0-9]*\.[0-9]+
PLUS '+'
DIMENSION {num}{ident}
NUMBER {num}
Implementation
List<String> /* SelectorExpression | LiteralTerm */ processSelectorExpression() {
var expressions = <String>[];
Token? termToken;
var keepParsing = true;
while (keepParsing) {
switch (_peek()) {
case TokenKind.PLUS:
case TokenKind.MINUS:
case TokenKind.INTEGER:
case TokenKind.PERCENT:
case TokenKind.DOUBLE:
termToken = _next();
expressions.add(termToken.text);
break;
case TokenKind.SINGLE_QUOTE:
final value = processQuotedString(false);
return ["'${_escapeString(value, single: true)}'"];
case TokenKind.DOUBLE_QUOTE:
final value = processQuotedString(false);
return ['"${_escapeString(value)}"'];
case TokenKind.IDENTIFIER:
final value = identifier(); // Snarf up the ident we'll remap, maybe.
expressions.add(value.name);
break;
default:
keepParsing = false;
}
}
return expressions;
}