use of com.gargoylesoftware.css.parser.condition.LangCondition in project LoboEvolution by LoboEvolution.
the class CSS3Parser method pseudo.
//
// pseudo
// : ':' (':')?
// [ IDENT
// | FUNCTION_NOT S* selector() S* ')'
// | FUNCTION_LANG S* IDENT S* ')'
// | FUNCTION S* ((PLUS | MINUS | DIMENSION | NUMBER | STRING | IDENT)? S*)+ ')'
// ]
// ;
//
public final Object pseudo(boolean pseudoElementFound) throws ParseException {
Token t;
String function;
String arg;
boolean doubleColon = false;
Locator locator;
try {
jj_consume_token(COLON);
locator = createLocator(token);
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case COLON:
{
jj_consume_token(COLON);
doubleColon = true;
break;
}
default:
jj_la1[81] = jj_gen;
;
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENT:
{
t = jj_consume_token(IDENT);
String s = unescape(t.image, false);
if (pseudoElementFound) {
throw toCSSParseException("duplicatePseudo", new String[] { s }, locator);
}
if ("first-line".equals(s) || "first-letter".equals(s) || "before".equals(s) || "after".equals(s)) {
return new PseudoElementSelector(s, locator, doubleColon);
}
return new PseudoClassCondition(s, locator, doubleColon);
}
case FUNCTION_NOT:
{
t = jj_consume_token(FUNCTION_NOT);
function = unescape(t.image, false);
label_52: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[82] = jj_gen;
break label_52;
}
jj_consume_token(S);
}
arg = negation_arg();
if ("".equals(arg)) {
arg = "*";
}
label_53: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[83] = jj_gen;
break label_53;
}
jj_consume_token(S);
}
jj_consume_token(RROUND);
if (pseudoElementFound) {
throw toCSSParseException("duplicatePseudo", new String[] { function + arg + ")" }, locator);
}
return new PseudoClassCondition(function + arg + ")", locator, doubleColon);
}
case FUNCTION_LANG:
{
t = jj_consume_token(FUNCTION_LANG);
function = unescape(t.image, false);
label_54: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[84] = jj_gen;
break label_54;
}
jj_consume_token(S);
}
t = jj_consume_token(IDENT);
String lang = unescape(t.image, false);
label_55: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[85] = jj_gen;
break label_55;
}
jj_consume_token(S);
}
jj_consume_token(RROUND);
if (pseudoElementFound) {
throw toCSSParseException("duplicatePseudo", new String[] { "lang(" + lang + ")" }, locator);
}
return new LangCondition(lang, locator);
}
case FUNCTION:
{
t = jj_consume_token(FUNCTION);
function = unescape(t.image, false);
StringBuilder args = new StringBuilder();
label_56: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[86] = jj_gen;
break label_56;
}
jj_consume_token(S);
}
label_57: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case PLUS:
{
t = jj_consume_token(PLUS);
break;
}
case MINUS:
{
t = jj_consume_token(MINUS);
break;
}
case DIMENSION:
{
t = jj_consume_token(DIMENSION);
break;
}
case NUMBER:
{
t = jj_consume_token(NUMBER);
break;
}
case STRING:
{
t = jj_consume_token(STRING);
break;
}
case IDENT:
{
t = jj_consume_token(IDENT);
break;
}
default:
jj_la1[87] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
args.append(unescape(t.image, false));
label_58: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[88] = jj_gen;
break label_58;
}
t = jj_consume_token(S);
args.append(unescape(t.image, false));
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case NUMBER:
case IDENT:
case STRING:
case MINUS:
case PLUS:
case DIMENSION:
{
;
break;
}
default:
jj_la1[89] = jj_gen;
break label_57;
}
}
jj_consume_token(RROUND);
if (pseudoElementFound) {
throw toCSSParseException("duplicatePseudo", new String[] { function + args.toString().trim() + ")" }, locator);
}
return new PseudoClassCondition(function + args.toString().trim() + ")", locator, doubleColon);
}
default:
jj_la1[90] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} catch (ParseException e) {
throw toCSSParseException("invalidPseudo", e);
}
}
Aggregations