* Handle all CSS2 functions.
* @exception ParseException exception during the parse
*/
final public LexicalUnitImpl function(char operator, LexicalUnitImpl prev) throws ParseException {
Token n;
LexicalUnit params = null;
n = jj_consume_token(FUNCTION);
label_68:
while (true) {
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case S:
;
break;
default:
jj_la1[105] = jj_gen;
break label_68;
}
jj_consume_token(S);
}
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case PLUS:
case MINUS:
case STRING:
case IDENT:
case NUMBER:
case URL:
case NAMESPACE_IDENT:
case PERCENTAGE:
case PT:
case MM:
case CM:
case PC:
case IN:
case PX:
case EMS:
case EXS:
case DEG:
case RAD:
case GRAD:
case MS:
case SECOND:
case HZ:
case KHZ:
case DIMEN:
case HASH:
case UNICODERANGE:
case FUNCTION:
params = expr();
break;
default:
jj_la1[106] = jj_gen;
;
}
jj_consume_token(LPARAN);
if (operator != ' ') {
{if (true) throw new CSSParseException("invalid operator before a function.",
getLocator());}
}
String f = convertIdent(n.image);
LexicalUnitImpl l = (LexicalUnitImpl) params;
boolean loop = true;
if ("rgb(".equals(f)) {
// this is a RGB declaration (e.g. rgb(255, 50%, 0) )
int i = 0;
while (loop && l != null && i < 5) {
switch (i) {
case 0:
case 2:
case 4:
if ((l.getLexicalUnitType() != LexicalUnit.SAC_INTEGER)
&& (l.getLexicalUnitType() != LexicalUnit.SAC_PERCENTAGE)) {
loop = false;
}
break;
case 1:
case 3:
if (l.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) {
loop = false;
}
break;
default:
{if (true) throw new ParseException("implementation error");}
}
if (loop) {
l = (LexicalUnitImpl) l.getNextLexicalUnit();
i ++;
}
}
if ((i == 5) && loop && (l == null)) {
{if (true) return LexicalUnitImpl.createRGBColor(n.beginLine,
n.beginColumn,
prev, params);}
} else {
if (errorHandler != null) {
String errorText;
Locator loc;
if (i < 5) {
if (params == null) {
loc = new LocatorImpl(this, n.beginLine,
n.beginColumn-1);
errorText = "not enough parameters.";
} else if (l == null) {
loc = new LocatorImpl(this, n.beginLine,
n.beginColumn-1);
errorText = "not enough parameters: "
+ params.toString();
} else {
loc = new LocatorImpl(this, l.getLineNumber(),
l.getColumnNumber());
errorText = "invalid parameter: "
+ l.toString();