Skip to content

Commit

Permalink
[#5955] Support exponentiation operator
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Apr 17, 2017
1 parent 413cfae commit 17293ce
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions jOOQ/src/main/java/org/jooq/impl/ParserImpl.java
Expand Up @@ -2335,16 +2335,29 @@ else if (parseIf(ctx, '-'))
}

private static final FieldOrRow parseFactor(ParserContext ctx, Type type) {
FieldOrRow r = parseTerm(ctx, type);
FieldOrRow r = parseExp(ctx, type);

if (N.is(type) && r instanceof Field)
for (;;)
if (parseIf(ctx, '*'))
r = ((Field) r).mul((Field) parseTerm(ctx, type));
r = ((Field) r).mul((Field) parseExp(ctx, type));
else if (parseIf(ctx, '/'))
r = ((Field) r).div((Field) parseTerm(ctx, type));
r = ((Field) r).div((Field) parseExp(ctx, type));
else if (parseIf(ctx, '%'))
r = ((Field) r).mod((Field) parseTerm(ctx, type));
r = ((Field) r).mod((Field) parseExp(ctx, type));
else
break;

return r;
}

private static final FieldOrRow parseExp(ParserContext ctx, Type type) {
FieldOrRow r = parseTerm(ctx, type);

if (N.is(type) && r instanceof Field)
for (;;)
if (parseIf(ctx, '^'))
r = ((Field) r).pow(toField(ctx, parseTerm(ctx, type)));
else
break;

Expand Down

0 comments on commit 17293ce

Please sign in to comment.