use of tec.uom.se.function.LogConverter in project uom-se by unitsofmeasurement.
the class LocalUnitFormatParser method ExponentExpr.
public final Unit ExponentExpr() throws TokenException {
Unit result = AbstractUnit.ONE;
Exponent exponent = null;
Token token = null;
if (jj_2_2(2147483647)) {
switch((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
case INTEGER:
token = consumeToken(INTEGER);
break;
case E:
token = consumeToken(E);
break;
default:
laA[5] = genInt;
consumeToken(-1);
throw new TokenException();
}
consumeToken(CARET);
result = AtomicExpr();
double base;
if (token.kind == INTEGER) {
base = Integer.parseInt(token.image);
} else {
base = StrictMath.E;
}
{
return result.transform(new LogConverter(base).inverse());
}
} else {
switch((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
case OPEN_PAREN:
case INTEGER:
case FLOATING_POINT:
case UNIT_IDENTIFIER:
result = AtomicExpr();
switch((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
case CARET:
case SUPERSCRIPT_INTEGER:
exponent = Exp();
break;
default:
laA[6] = genInt;
}
if (exponent != null) {
if (exponent.pow != 1) {
result = result.pow(exponent.pow);
}
if (exponent.root != 1) {
result = result.root(exponent.root);
}
}
{
return result;
}
case LOG:
case NAT_LOG:
switch((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
case LOG:
consumeToken(LOG);
switch((nextTokenIndex == -1) ? jj_ntk() : nextTokenIndex) {
case INTEGER:
token = consumeToken(INTEGER);
break;
default:
laA[7] = genInt;
}
break;
case NAT_LOG:
token = consumeToken(NAT_LOG);
break;
default:
laA[8] = genInt;
consumeToken(-1);
throw new TokenException();
}
consumeToken(OPEN_PAREN);
result = AddExpr();
consumeToken(CLOSE_PAREN);
double base = 10;
if (token != null) {
if (token.kind == INTEGER) {
base = Integer.parseInt(token.image);
} else if (token.kind == NAT_LOG) {
base = StrictMath.E;
}
}
{
return result.transform(new LogConverter(base));
}
default:
laA[9] = genInt;
consumeToken(-1);
throw new TokenException();
}
}
}
use of tec.uom.se.function.LogConverter in project uom-se by unitsofmeasurement.
the class UnitFormatParser method exponentExpr.
@SuppressWarnings("unused")
Unit<?> exponentExpr() throws TokenException {
Unit<?> result = AbstractUnit.ONE;
Exponent exponent = null;
Token token = null;
if (jj_2_2(2147483647)) {
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case INTEGER:
token = jj_consume_token(INTEGER);
break;
case E:
token = jj_consume_token(E);
break;
default:
jj_la1[5] = jj_gen;
jj_consume_token(-1);
throw new TokenException();
}
jj_consume_token(CARET);
result = atomicExpr();
double base;
if (token.kind == INTEGER) {
base = Integer.parseInt(token.image);
} else {
base = E;
}
{
if (true)
return result.transform(new LogConverter(base).inverse());
}
} else {
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case OPEN_PAREN:
case INTEGER:
case FLOATING_POINT:
case UNIT_IDENTIFIER:
result = atomicExpr();
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case CARET:
case SUPERSCRIPT_INTEGER:
exponent = exp();
break;
default:
jj_la1[6] = jj_gen;
}
if (exponent != null) {
if (exponent.pow != 1) {
result = result.pow(exponent.pow);
}
if (exponent.root != 1) {
result = result.root(exponent.root);
}
}
{
if (true)
return result;
}
// break;
case LOG:
case NAT_LOG:
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case LOG:
jj_consume_token(LOG);
switch((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case INTEGER:
token = jj_consume_token(INTEGER);
break;
default:
jj_la1[7] = jj_gen;
}
break;
case NAT_LOG:
token = jj_consume_token(NAT_LOG);
break;
default:
jj_la1[8] = jj_gen;
jj_consume_token(-1);
throw new TokenException();
}
jj_consume_token(OPEN_PAREN);
result = addExpr();
jj_consume_token(CLOSE_PAREN);
double base = 10;
if (token != null) {
if (token.kind == INTEGER) {
base = Integer.parseInt(token.image);
} else if (token.kind == NAT_LOG) {
base = E;
}
}
{
if (true)
return result.transform(new LogConverter(base));
}
default:
jj_la1[9] = jj_gen;
jj_consume_token(-1);
throw new TokenException();
}
}
throw new Error("Missing return statement in function");
}
Aggregations