AttributeSpecifier.Match attributeMatch = null;
String pseudoNthClass = null;
boolean isNegation = false;
Selector negationSelector = null;
// line 1538 "../java/se/fishtank/css/selectors/scanner/Scanner.java"
{
cs = Scanner_start;
top = 0;
}
// line 221 "Scanner.java.rl"
// line 1546 "../java/se/fishtank/css/selectors/scanner/Scanner.java"
{
int _klen;
int _trans = 0;
int _acts;
int _nacts;
int _keys;
int _goto_targ = 0;
_goto: while (true) {
switch ( _goto_targ ) {
case 0:
if ( p == pe ) {
_goto_targ = 4;
continue _goto;
}
if ( cs == 0 ) {
_goto_targ = 5;
continue _goto;
}
case 1:
_match: do {
_keys = _Scanner_key_offsets[cs];
_trans = _Scanner_index_offsets[cs];
_klen = _Scanner_single_lengths[cs];
if ( _klen > 0 ) {
int _lower = _keys;
int _mid;
int _upper = _keys + _klen - 1;
while (true) {
if ( _upper < _lower )
break;
_mid = _lower + ((_upper-_lower) >> 1);
if ( data[p] < _Scanner_trans_keys[_mid] )
_upper = _mid - 1;
else if ( data[p] > _Scanner_trans_keys[_mid] )
_lower = _mid + 1;
else {
_trans += (_mid - _keys);
break _match;
}
}
_keys += _klen;
_trans += _klen;
}
_klen = _Scanner_range_lengths[cs];
if ( _klen > 0 ) {
int _lower = _keys;
int _mid;
int _upper = _keys + (_klen<<1) - 2;
while (true) {
if ( _upper < _lower )
break;
_mid = _lower + (((_upper-_lower) >> 1) & ~1);
if ( data[p] < _Scanner_trans_keys[_mid] )
_upper = _mid - 2;
else if ( data[p] > _Scanner_trans_keys[_mid+1] )
_lower = _mid + 2;
else {
_trans += ((_mid - _keys)>>1);
break _match;
}
}
_trans += _klen;
}
} while (false);
_trans = _Scanner_indicies[_trans];
cs = _Scanner_trans_targs[_trans];
if ( _Scanner_trans_actions[_trans] != 0 ) {
_acts = _Scanner_trans_actions[_trans];
_nacts = (int) _Scanner_actions[_acts++];
while ( _nacts-- > 0 )
{
switch ( _Scanner_actions[_acts++] )
{
case 0:
// line 44 "Scanner.java.rl"
{
AttributeSpecifier specifier;
if (attributeValue != null) {
specifier = new AttributeSpecifier(attributeName, attributeValue, attributeMatch);
} else {
specifier = new AttributeSpecifier(attributeName);
}
specifiers.add(specifier);
}
break;
case 1:
// line 55 "Scanner.java.rl"
{
attributeName = getSlice(mark, p);
}
break;
case 2:
// line 59 "Scanner.java.rl"
{
String m = getSlice(mark, p);
if ("=".equals(m)) {
attributeMatch = AttributeSpecifier.Match.EXACT;
} else if ("~=".equals(m)) {
attributeMatch = AttributeSpecifier.Match.LIST;
} else if ("|=".equals(m)) {
attributeMatch = AttributeSpecifier.Match.HYPHEN;
} else if ("^=".equals(m)) {
attributeMatch = AttributeSpecifier.Match.PREFIX;
} else if ("$=".equals(m)) {
attributeMatch = AttributeSpecifier.Match.SUFFIX;
} else if ("*=".equals(m)) {
attributeMatch = AttributeSpecifier.Match.CONTAINS;
}
}
break;
case 3:
// line 76 "Scanner.java.rl"
{
String value = getSlice(mark, p);
if (value.charAt(0) == '"' || value.charAt(0) == '\'') {
value = value.substring(1, value.length() - 1);
}
attributeValue = value;
}
break;
case 4:
// line 85 "Scanner.java.rl"
{
specifiers.add(new AttributeSpecifier("class",
getSlice(mark, p), AttributeSpecifier.Match.LIST));
}
break;
case 5:
// line 90 "Scanner.java.rl"
{
switch (data[p]) {
case ' ':
combinator = Selector.Combinator.DESCENDANT;
break;
case '>':
combinator = Selector.Combinator.CHILD;
break;
case '+':
combinator = Selector.Combinator.ADJACENT_SIBLING;
break;
case '~':
combinator = Selector.Combinator.GENERAL_SIBLING;
break;
}
}
break;
case 6:
// line 107 "Scanner.java.rl"
{
parts = new LinkedList<Selector>();
}
break;
case 7:
// line 111 "Scanner.java.rl"
{
selectors.add(parts);
}
break;
case 8:
// line 115 "Scanner.java.rl"
{
specifiers.add(new AttributeSpecifier("id",
getSlice(mark, p), AttributeSpecifier.Match.EXACT));
}
break;
case 9:
// line 120 "Scanner.java.rl"
{
mark = p;
}
break;
case 10:
// line 124 "Scanner.java.rl"
{
isNegation = true;
}
break;
case 11:
// line 128 "Scanner.java.rl"
{
specifiers.add(new NegationSpecifier(negationSelector));
isNegation = false;
}
break;
case 12:
// line 133 "Scanner.java.rl"
{
specifiers.add(new PseudoClassSpecifier(getSlice(mark, p)));
}
break;
case 13:
// line 137 "Scanner.java.rl"
{
specifiers.add(new PseudoNthSpecifier(pseudoNthClass, getSlice(mark, p)));
}
break;
case 14:
// line 141 "Scanner.java.rl"
{
pseudoNthClass = getSlice(mark, p);
}
break;
case 15:
// line 145 "Scanner.java.rl"
{
Selector selector;
List<Specifier> list = specifiers.isEmpty() ? null : specifiers;
if (isNegation) {
negationSelector = new Selector(negationTagName, list);
} else {
if (combinator == null) {
selector = new Selector(tagName, list);
} else {
selector = new Selector(tagName, combinator, list);
}
parts.add(selector);
tagName = Selector.UNIVERSAL_TAG;
combinator = null;
}
negationTagName = Selector.UNIVERSAL_TAG;
attributeName = null;
attributeValue = null;
attributeMatch = null;
pseudoNthClass = null;
specifiers = new LinkedList<Specifier>();
}
break;
case 16:
// line 170 "Scanner.java.rl"
{
if (isNegation) {
negationTagName = getSlice(mark, p);
} else {
tagName = getSlice(mark, p);
}
}
break;
case 17:
// line 28 "ScannerCommon.rl"
{ {stack[top++] = cs; cs = 150; _goto_targ = 2; if (true) continue _goto;} }
case 18:
// line 42 "ScannerCommon.rl"
{ {cs = stack[--top];_goto_targ = 2; if (true) continue _goto;} }
// line 1802 "../java/se/fishtank/css/selectors/scanner/Scanner.java"
}
}
}
case 2:
if ( cs == 0 ) {
_goto_targ = 5;
continue _goto;
}
if ( ++p != pe ) {
_goto_targ = 1;
continue _goto;
}
case 4:
if ( p == eof )
{
int __acts = _Scanner_eof_actions[cs];
int __nacts = (int) _Scanner_actions[__acts++];
while ( __nacts-- > 0 ) {
switch ( _Scanner_actions[__acts++] ) {
case 4:
// line 85 "Scanner.java.rl"
{
specifiers.add(new AttributeSpecifier("class",
getSlice(mark, p), AttributeSpecifier.Match.LIST));
}
break;
case 7:
// line 111 "Scanner.java.rl"
{
selectors.add(parts);
}
break;
case 8:
// line 115 "Scanner.java.rl"
{
specifiers.add(new AttributeSpecifier("id",
getSlice(mark, p), AttributeSpecifier.Match.EXACT));
}
break;
case 12:
// line 133 "Scanner.java.rl"
{
specifiers.add(new PseudoClassSpecifier(getSlice(mark, p)));
}
break;
case 15:
// line 145 "Scanner.java.rl"
{
Selector selector;
List<Specifier> list = specifiers.isEmpty() ? null : specifiers;
if (isNegation) {
negationSelector = new Selector(negationTagName, list);
} else {
if (combinator == null) {
selector = new Selector(tagName, list);
} else {
selector = new Selector(tagName, combinator, list);
}
parts.add(selector);
tagName = Selector.UNIVERSAL_TAG;
combinator = null;