}
public Pseudo handlePseudo(HiddenTokenAwareTree token) {
List<HiddenTokenAwareTree> children = token.getChildren();
if (children.size() == 0 || children.size() == 1)
throw new BugHappened(GRAMMAR_MISMATCH, token);
// the child number 0 is a :
HiddenTokenAwareTree t = children.get(1);
if (t.getType() == LessLexer.COLON) {
return createPseudoElement(token, 2, false);
}
if (COLONLESS_PSEUDOELEMENTS.contains(t.getText().toLowerCase())) {
return createPseudoElement(token, 1, true);
}
if (children.size() == 2)
return new PseudoClass(token, children.get(1).getText());
if (children.size() == 3) {
HiddenTokenAwareTree parameter = children.get(2);
//FIXME: this is not really sufficient for all cases less.js supports (1@{num}n+3)
if (parameter.getType() == LessLexer.INTERPOLATED_VARIABLE)
return new PseudoClass(token, children.get(1).getText(), toInterpolabledVariable(parameter, parameter.getText()));
return new PseudoClass(token, children.get(1).getText(), switchOn(parameter));
}
throw new BugHappened(GRAMMAR_MISMATCH, token);
}