use of com.gargoylesoftware.css.parser.Locator 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);
}
}
use of com.gargoylesoftware.css.parser.Locator in project LoboEvolution by LoboEvolution.
the class CSS3Parser method pageRule.
//
// page
// : PAGE_SYM S* pseudo_page? S*
// '{' S* declaration [ ';' S* declaration ]* '}' S*
// ;
//
public final void pageRule() throws ParseException {
String sel = null;
boolean start = false;
Locator locator;
try {
jj_consume_token(PAGE_SYM);
locator = createLocator(token);
label_24: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[38] = jj_gen;
break label_24;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENT:
case COLON:
{
sel = pageSelectorList();
break;
}
default:
jj_la1[39] = jj_gen;
;
}
jj_consume_token(LBRACE);
label_25: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[40] = jj_gen;
break label_25;
}
jj_consume_token(S);
}
start = true;
handleStartPage(null, sel, locator);
styleDeclaration();
jj_consume_token(RBRACE);
} catch (CSSParseException e) {
getErrorHandler().error(e);
error_skipblock("ignoringRule", e);
} catch (ParseException e) {
CSSParseException cpe = toCSSParseException("invalidPageRule", e);
getErrorHandler().error(cpe);
error_skipblock("ignoringRule", cpe);
} finally {
if (start) {
handleEndPage(null, sel);
}
}
}
use of com.gargoylesoftware.css.parser.Locator in project LoboEvolution by LoboEvolution.
the class CSS3Parser method fontFaceRule.
//
// font_face
// : FONT_FACE_SYM S*
// '{' S* declaration [ ';' S* declaration ]* '}' S*
// ;
//
public final void fontFaceRule() throws ParseException {
boolean start = false;
Locator locator;
try {
jj_consume_token(FONT_FACE_SYM);
locator = createLocator(token);
label_30: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[46] = jj_gen;
break label_30;
}
jj_consume_token(S);
}
jj_consume_token(LBRACE);
label_31: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[47] = jj_gen;
break label_31;
}
jj_consume_token(S);
}
start = true;
handleStartFontFace(locator);
styleDeclaration();
jj_consume_token(RBRACE);
} catch (ParseException e) {
throw toCSSParseException("invalidFontFaceRule", e);
} finally {
if (start) {
handleEndFontFace();
}
}
}
use of com.gargoylesoftware.css.parser.Locator in project LoboEvolution by LoboEvolution.
the class CSS3Parser method attrib.
//
// attrib
// : '[' S* IDENT S* [ [ '=' | INCLUDES | DASHMATCH | PREFIXMATCH | SUFFIXMATCH | SUBSTRINGMATCH ] S*
// [ IDENT | STRING ] S* ]? ']'
// ;
//
public final Condition attrib(boolean pseudoElementFound) throws ParseException {
Token t;
String name = null;
String value = null;
int type = 0;
Locator locator;
try {
jj_consume_token(LSQUARE);
locator = createLocator(token);
label_48: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[74] = jj_gen;
break label_48;
}
jj_consume_token(S);
}
if (pseudoElementFound) {
throw generateParseException();
}
t = jj_consume_token(IDENT);
name = unescape(t.image, false);
label_49: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[75] = jj_gen;
break label_49;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case INCLUDES:
case DASHMATCH:
case PREFIXMATCH:
case SUFFIXMATCH:
case SUBSTRINGMATCH:
case EQUALS:
{
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case PREFIXMATCH:
{
jj_consume_token(PREFIXMATCH);
type = 4;
break;
}
case SUFFIXMATCH:
{
jj_consume_token(SUFFIXMATCH);
type = 5;
break;
}
case SUBSTRINGMATCH:
{
jj_consume_token(SUBSTRINGMATCH);
type = 6;
break;
}
case EQUALS:
{
jj_consume_token(EQUALS);
type = 1;
break;
}
case INCLUDES:
{
jj_consume_token(INCLUDES);
type = 2;
break;
}
case DASHMATCH:
{
jj_consume_token(DASHMATCH);
type = 3;
break;
}
default:
jj_la1[76] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
label_50: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[77] = jj_gen;
break label_50;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENT:
{
t = jj_consume_token(IDENT);
value = unescape(t.image, false);
break;
}
case STRING:
{
t = jj_consume_token(STRING);
value = unescape(t.image, false);
break;
}
default:
jj_la1[78] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
label_51: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[79] = jj_gen;
break label_51;
}
jj_consume_token(S);
}
break;
}
default:
jj_la1[80] = jj_gen;
;
}
jj_consume_token(RSQUARE);
Condition c = null;
switch(type) {
case 0:
c = new AttributeCondition(name, null);
break;
case 1:
c = new AttributeCondition(name, value);
break;
case 2:
c = new OneOfAttributeCondition(name, value);
break;
case 3:
c = new BeginHyphenAttributeCondition(name, value);
break;
case 4:
c = new PrefixAttributeCondition(name, value);
break;
case 5:
c = new SuffixAttributeCondition(name, value);
break;
case 6:
c = new SubstringAttributeCondition(name, value);
break;
}
c.setLocator(locator);
return c;
} catch (ParseException e) {
throw toCSSParseException("invalidAttrib", e);
}
}
use of com.gargoylesoftware.css.parser.Locator in project LoboEvolution by LoboEvolution.
the class CSS3Parser method mediaRule.
//
// media
// : MEDIA_SYM S* medium [ COMMA S* medium ]* '{' S* ruleset* '}' S*
// ;
//
public final void mediaRule() throws ParseException {
boolean start = false;
MediaQueryList ml = new MediaQueryList();
Locator locator;
try {
jj_consume_token(MEDIA_SYM);
locator = createLocator(token);
label_9: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[17] = jj_gen;
break label_9;
}
jj_consume_token(S);
}
mediaList(ml);
start = true;
handleStartMedia(ml, locator);
jj_consume_token(LBRACE);
label_10: while (true) {
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case S:
{
;
break;
}
default:
jj_la1[18] = jj_gen;
break label_10;
}
jj_consume_token(S);
}
switch((jj_ntk == -1) ? jj_ntk_f() : jj_ntk) {
case IDENT:
case DOT:
case COLON:
case ASTERISK:
case LSQUARE:
case HASH:
case IMPORT_SYM:
case PAGE_SYM:
case MEDIA_SYM:
case ATKEYWORD:
{
mediaRuleList();
break;
}
default:
jj_la1[19] = jj_gen;
;
}
jj_consume_token(RBRACE);
} catch (CSSParseException e) {
getErrorHandler().error(e);
error_skipblock("ignoringRule", e);
} catch (ParseException e) {
CSSParseException cpe = toCSSParseException("invalidMediaRule", e);
getErrorHandler().error(cpe);
error_skipblock("ignoringRule", cpe);
} finally {
if (start) {
handleEndMedia(ml);
}
}
}
Aggregations