[OLINGO-434] Fixed wrong MINUS position in Antlr file

This commit is contained in:
Michael Bolz 2014-10-07 15:28:52 +02:00
parent d3dac46edc
commit 4a4b110f99
4 changed files with 18 additions and 7 deletions

View File

@ -132,7 +132,9 @@ TRUE : 'true';
FALSE : 'false';
BOOLEAN : T R U E | F A L S E;
PLUS : '+';
SIGN : PLUS | '%2B' |'-';
MINUS : '-';
SIGN : PLUS | '%2B' | '-';
INT : SIGN? DIGITS;
DECIMAL : INT '.' DIGITS (('e'|'E') SIGN? DIGITS)?;
NANINFINITY : 'NaN' | '-INF' | 'INF';
@ -184,7 +186,7 @@ OR : 'or';
NOT : 'not';
MINUS :'-';
IT : '$it';
ITSLASH : '$it/';

View File

@ -2166,8 +2166,8 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
@Override
public ExpressionImpl visitAltUnary(@NotNull UriParserParser.AltUnaryContext ctx) {
UnaryImpl unary = new UnaryImpl();
unary.setOperator(ctx.unary().NOT() == null?UnaryOperatorKind.MINUS:UnaryOperatorKind.NOT);
unary.setOperand((ExpressionImpl)ctx.commonExpr().accept(this));
unary.setOperator(ctx.unary().NOT() == null? UnaryOperatorKind.MINUS: UnaryOperatorKind.NOT);
unary.setOperand((ExpressionImpl) ctx.commonExpr().accept(this));
return unary;
}
@ -2177,5 +2177,4 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
alias.setParameter("@"+ctx.odataIdentifier().getChild(0).getText());
return alias;
}
}

View File

@ -48,6 +48,11 @@ public class TestLexer {
// ; 0. URI
// ;------------------------------------------------------------------------------
@Test
public void testUnary() {
test.run("- a eq a").isAllInput();
}
@Test
public void testUriTokens() {
test.globalMode(UriLexer.MODE_QUERY);

View File

@ -566,6 +566,12 @@ public class TestUriParserImpl {
}
@Test
public void testUnary() throws UriParserException {
testFilter.runESabc("not a").isCompr("<not <a>>");
testFilter.runESabc("- a eq a").isCompr("<<- <a>> eq <a>>");
}
@Test
public void testFilterComplexMixedPriority() throws UriParserException {
testFilter.runESabc("a or c and e ").isCompr("< <a> or < <c> and <e> >>");
@ -576,7 +582,6 @@ public class TestUriParserImpl {
testFilter.runESabc("a eq b or c and e eq f").isCompr("<<<a> eq <b>> or < <c> and <<e> eq <f>>>>");
testFilter.runESabc("a eq b or c eq d and e ").isCompr("<<<a> eq <b>> or <<<c> eq <d>> and <e> >>");
testFilter.runESabc("a eq b or c eq d and e eq f").isCompr("<<<a> eq <b>> or <<<c> eq <d>> and <<e> eq <f>>>>");
testFilter.runESabc("not a").isCompr("<not <a>>");
}
@Test
@ -1055,7 +1060,7 @@ public class TestUriParserImpl {
@Test
public void testAlias() throws Exception {
testUri.run("ESAllPrim?$filter=PropertyInt16 eq @p1&@p1=1)")
testUri.run("ESAllPrim", "$filter=PropertyInt16 eq @p1&@p1=1)")
.goFilter().is("<<PropertyInt16> eq <@p1>>");
}