diff options
author | Jon Bratseth <bratseth@gmail.com> | 2022-02-13 15:42:38 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2022-02-13 15:42:38 +0100 |
commit | 90e705497a710bfb0ac7710206e7963dea7ece3e (patch) | |
tree | e68fd96ce4f0de5dbf47ecf99fd5730f1bd68e68 /integration/intellij/src | |
parent | 05a4c4765c83b2d727650001d7ac9b7cc968e653 (diff) |
Parse literal tensor expressions
Diffstat (limited to 'integration/intellij/src')
-rw-r--r-- | integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf | 26 | ||||
-rw-r--r-- | integration/intellij/src/test/applications/rankprofilemodularity/test.sd | 16 |
2 files changed, 31 insertions, 11 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 330c074fde8..3fceebb6391 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 @@ -107,11 +107,14 @@ AnnotationFieldDefinition ::= field IdentifierVal type FieldTypeName '{' '}' } //------------------------- -//--- Expressions rules --- -// Note - these must end by "Expr" - see this line above: extends(".*Expr")=RankingExpression +// Expressions rules +// +// NOTE: These must end by "Expr" - see this line above: extends(".*Expr")=RankingExpression +// The *Expr alternatives are consumed greedily so order matters. //------------------------- -RankingExpression ::= FilePathExpr | ParenthesisedExpr | BooleanExpr | ArithmeticExpr | IfFunctionExpr | - QueryDefinitionExpr | FunctionCallExpr | InListRankingExpr | PrimitiveExpr | SliceExpr +RankingExpression ::= LiteralTensorExpr | FilePathExpr | ParenthesisedExpr | BooleanExpr | ArithmeticExpr | IfFunctionExpr | + QueryDefinitionExpr | FunctionCallExpr | InListRankingExpr | PrimitiveExpr | + SliceExpr FilePathExpr ::= file ':' (FilePath | WordWrapper) @@ -131,18 +134,23 @@ ParenthesisedExpr ::= '(' RankingExpression ')' PrimitiveExpr ::= ( (('-')? INTEGER_REG) | (('-')? FLOAT_REG) | IdentifierVal | RankFeature | STRING_REG ) -SliceExpr ::= RankingExpression ( MapSlice | IndexSlice | TensorAddress ) +SliceExpr ::= RankingExpression ( SliceKey | SliceIndex | FullTensorAddress ) -MapSlice ::= '{' Label '}' +SliceKey ::= '{' Label '}' +SliceIndex ::= '[' RankingExpression ']' -IndexSlice ::= '[' RankingExpression ']' - -TensorAddress ::= '{' KeyValue ( ',' KeyValue )* '}' +FullTensorAddress ::= '{' KeyValue ( ',' KeyValue )* '}' KeyValue ::= IdentifierVal ':' ( Label | RankingExpression ) Label ::= IdentifierVal | STRING_REG +LiteralTensorExpr ::= TensorType ':' '{' TensorValue ( ',' TensorValue )* '}' + +TensorValue ::= CellAddress ':' RankingExpression + +CellAddress ::= Label | FullTensorAddress + //------------------------- //-- Rank Profile rules --- //------------------------- diff --git a/integration/intellij/src/test/applications/rankprofilemodularity/test.sd b/integration/intellij/src/test/applications/rankprofilemodularity/test.sd index ad977f56051..d6c8e649b90 100644 --- a/integration/intellij/src/test/applications/rankprofilemodularity/test.sd +++ b/integration/intellij/src/test/applications/rankprofilemodularity/test.sd @@ -6,6 +6,9 @@ schema test { indexing: index } + field myTensor type tensor(x{}) { + } + } rank-profile default inherits outside_schema2 { @@ -21,8 +24,17 @@ schema test { } function tensorFunction(tensor1, tensor2, tensor3, tensor4, tensor) { - expression: tensor1{key} + tensor2[1] + tensor3{key:key1,x:1} + tensor4{key:key1,x:(3-2)} + - tensor1{"key"} + tensor3{key:"key1",x:1} + expression { + tensor1{key} + + tensor2[1] + + tensor3{key:key1,x:1} + + tensor4{key:key1,x:(3-2)} + + tensor1{"key"} + + tensor3{key:"key1",x:1} + + tensor(x{}):{x1:3, x2:4} + + tensor(x{}):{x1:t1[1], x2:t1[0]} + + tensor(x{},y[2]):{{x:x1, y:0}:3, {x:x2, y:1}:4} + } } } |