summaryrefslogtreecommitdiffstats
path: root/integration
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-03-16 16:57:41 +0100
committerJon Bratseth <bratseth@gmail.com>2022-03-16 16:57:41 +0100
commitfd9798a06fbfe73de0e25f28b09678bba642f09d (patch)
tree597a740c784e6fa55681be1cb9dc1252725d08fa /integration
parent89c00be86b2de199ab125d0bc662e6b429dc662d (diff)
Parse operators properly
Diffstat (limited to 'integration')
-rw-r--r--integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf14
-rw-r--r--integration/intellij/src/main/jflex/ai/vespa/intellij/schema/lexer/sd.flex33
-rw-r--r--integration/intellij/src/test/applications/rankprofilemodularity/test/outside_schema1.profile2
3 files changed, 31 insertions, 18 deletions
diff --git a/integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf b/integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf
index 6a5b59984e4..8bec7d1bbd8 100644
--- a/integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf
+++ b/integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf
@@ -34,8 +34,6 @@
COMMA = 'regexp:[,]'
//BLOCK_START = '{'
//BLOCK_END = '}'
- COMPARISON_OPERATOR = 'regexp:[<>]|(==)|(<=)|(>=)|(~=)'
- ARITHMETIC_OPERATOR = 'regexp:[\-+*/%]'
INTEGER_REG = 'regexp:[0-9]+'
FLOAT_REG = 'regexp:[0-9]+[.][0-9]+[e]?'
STRING_REG = 'regexp:\"([^\"\\]*(\\.[^\"\\]*)*)\"' // TODO: Should also support single-quotes
@@ -122,9 +120,13 @@ IfFunctionExpr ::= "if" '(' RankingExpression COMMA RankingExpression COMMA Rank
InListRankingExpr ::= RankingExpression "in" '[' RankingExpression (COMMA RankingExpression)* ']'
-BooleanExpr ::= RankingExpression COMPARISON_OPERATOR RankingExpression
-
-ArithmeticExpr ::= RankingExpression ARITHMETIC_OPERATOR RankingExpression
+BooleanExpr ::= RankingExpression ComparisonOperator RankingExpression
+
+ComparisonOperator ::= '<' | '>' | "==" | "<=" | ">=" | "~=" | "!="
+
+ArithmeticExpr ::= RankingExpression ArithmeticOperator RankingExpression
+
+ArithmeticOperator ::= '+' | '-' | '*' | '/' | '%' | '^' | "||" | "&&"
QueryDefinitionExpr ::= QueryDefinition | ItemRawScoreDefinition
@@ -286,7 +288,7 @@ IndexingStatementOptions ::= summary | attribute | index | set_language | lowerc
(input (DottedIdentifier | IndexingStuff)+) |
('{' IndexingStatementOptions '}') | IndexingStuff+
private IndexingStuff ::= WordWrapper | INTEGER_REG | FLOAT_REG | STRING_REG | ('{' IndexingStatement '}') |
- ':' | ('|' IndexingStatementOptions) | ';' | '.' | '(' | ')' | ARITHMETIC_OPERATOR | COMPARISON_OPERATOR
+ ':' | ('|' IndexingStatementOptions) | ';' | '.' | '(' | ')' | ArithmeticOperator | ComparisonOperator
// Attribute
AttributeDefinition ::= attribute ((':' SimpleAttributeProperty) | ('{' (ComplexAttributeProperty | SimpleAttributeProperty)+ '}'))
SimpleAttributeProperty ::= fast-search | fast-access | paged | mutable | enable-bit-vectors | enable-only-bit-vector | WordWrapper // Does not support zero-or-one occurrences
diff --git a/integration/intellij/src/main/jflex/ai/vespa/intellij/schema/lexer/sd.flex b/integration/intellij/src/main/jflex/ai/vespa/intellij/schema/lexer/sd.flex
index f3064612b43..eaaab813202 100644
--- a/integration/intellij/src/main/jflex/ai/vespa/intellij/schema/lexer/sd.flex
+++ b/integration/intellij/src/main/jflex/ai/vespa/intellij/schema/lexer/sd.flex
@@ -40,8 +40,6 @@ COMMA= [,]
//BLOCK_END= \}
INTEGER = [0-9]+
FLOAT = {INTEGER}[.][0-9]+[e]?
-COMPARISON_OPERATOR = [<>]|(==)|(<=)|(>=)|(\~=)
-ARITHMETIC_OPERATOR = [\-+*/%]
STRING = \"([^\"\\]*(\\.[^\"\\]*)*)\"
WORD = \w+
@@ -50,15 +48,13 @@ WORD = \w+
<YYINITIAL> {
/**
- In here, we match keywords. So if a keyword is found, this returns a token which corresponds to that keyword.
+ Here we match keywords. If a keyword is found, this returns a token which corresponds to that keyword.
These tokens are generated using the 'sd.bnf' file and located in the SdTypes class.
These tokens are Parsed uses these return values to match token squence to a parser rule.
+
+ This list of keywords has to be synchronized with sd.bnf file. If you add a keyword here, you should add it to the
+ sd.bnf file as well (to the rule KeywordOrIdentifier / KeywordNotIdentifier).
*/
-
- /**
- This list of keywords has to be synchronized with sd.bnf file. If you add a keyword here, you should add it to the
- sd.bnf file as well (to the rule KeywordOrIdentifier / KeywordNotIdentifier).
- */
"search" { return SEARCH; }
"schema" { return SCHEMA; }
@@ -219,7 +215,24 @@ WORD = \w+
"evaluation-point" { return EVALUATION_POINT; }
"pre-post-filter-tipping-point" { return PRE_POST_FILTER_TIPPING_POINT; }
-
+
+ "<" { return COMPARISON_OPERATOR; }
+ ">" { return COMPARISON_OPERATOR; }
+ "==" { return COMPARISON_OPERATOR; }
+ "<=" { return COMPARISON_OPERATOR; }
+ ">=" { return COMPARISON_OPERATOR; }
+ "~=" { return COMPARISON_OPERATOR; }
+ "!=" { return COMPARISON_OPERATOR; }
+
+ "+" { return ARITHMETIC_OPERATOR; }
+ "-" { return ARITHMETIC_OPERATOR; }
+ "*" { return ARITHMETIC_OPERATOR; }
+ "/" { return ARITHMETIC_OPERATOR; }
+ "%" { return ARITHMETIC_OPERATOR; }
+ "^" { return ARITHMETIC_OPERATOR; }
+ "||" { return ARITHMETIC_OPERATOR; }
+ "&&" { return ARITHMETIC_OPERATOR; }
+
// Here we check for character sequences which matches regular expressions defined above.
{ID} { return ID_REG; }
{ID_WITH_DASH} { return ID_WITH_DASH_REG; }
@@ -233,8 +246,6 @@ WORD = \w+
//{BLOCK_END} { return BLOCK_END; }
{INTEGER} { return INTEGER_REG; }
{FLOAT} { return FLOAT_REG; }
- {ARITHMETIC_OPERATOR} { return ARITHMETIC_OPERATOR; }
- {COMPARISON_OPERATOR} { return COMPARISON_OPERATOR; }
{WORD} { return WORD_REG; }
{STRING} { return STRING_REG; }
diff --git a/integration/intellij/src/test/applications/rankprofilemodularity/test/outside_schema1.profile b/integration/intellij/src/test/applications/rankprofilemodularity/test/outside_schema1.profile
index c7803b41bdd..af27290c5f7 100644
--- a/integration/intellij/src/test/applications/rankprofilemodularity/test/outside_schema1.profile
+++ b/integration/intellij/src/test/applications/rankprofilemodularity/test/outside_schema1.profile
@@ -5,7 +5,7 @@ rank-profile outside_schema1 inherits in_schema1 {
}
function local1() {
- expression: local12 + local3 + local12
+ expression: local12 + local3 + local12 + a && b || c >= d
}
function local12() {