diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-12-10 16:15:40 -0800 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-12-10 16:15:40 -0800 |
commit | 58bbdee39ce7b38e9dad0956e7b0e57319e8b0b8 (patch) | |
tree | 4a35ed6625b90744a4189b52b20ff33ddd922d80 /searchlib/src/main | |
parent | 169c1d9665efbeb678e2a50382d5cdc1da424447 (diff) |
Parse mixed tensors
Diffstat (limited to 'searchlib/src/main')
-rwxr-xr-x | searchlib/src/main/javacc/RankingExpressionParser.jj | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/searchlib/src/main/javacc/RankingExpressionParser.jj b/searchlib/src/main/javacc/RankingExpressionParser.jj index de3ad6b5d8c..6abd9396ecf 100755 --- a/searchlib/src/main/javacc/RankingExpressionParser.jj +++ b/searchlib/src/main/javacc/RankingExpressionParser.jj @@ -840,7 +840,8 @@ TensorFunctionNode tensorValueBody(TensorType type) : <COLON> ( dynamicTensor = mappedTensorValueBody(type) | - dynamicTensor = indexedTensorValueBody(type) + dynamicTensor = indexedTensorValueBody(type) | + dynamicTensor = mixedTensorValueBody(type) ) { return new TensorFunctionNode(dynamicTensor); } } @@ -857,8 +858,39 @@ DynamicTensor mappedTensorValueBody(TensorType type) : { return DynamicTensor.from(type, TensorFunctionNode.wrapScalars(cells)); } } +DynamicTensor mixedTensorValueBody(TensorType type) : +{ + java.util.Map cells = new LinkedHashMap(); +} +{ + <LCURLY> + mixedBlock(type, cells) + ( <COMMA> mixedBlock(type, cells))* + <RCURLY> + { return DynamicTensor.from(type, cells); } +} + DynamicTensor indexedTensorValueBody(TensorType type) : { + List cells; +} +{ + cells = indexedTensorCells() + { return DynamicTensor.from(type, TensorFunctionNode.wrapScalars(cells)); } +} + +void mixedBlock(TensorType type, Map cellMap) : +{ + String label; + List cells; +} +{ + label = tag() <COLON> cells = indexedTensorCells() + { TensorFunctionNode.wrapScalarBlock(label, cells, cellMap); } +} + +List indexedTensorCells() : +{ List cells = new ArrayList(); ExpressionNode value; } @@ -867,7 +899,7 @@ DynamicTensor indexedTensorValueBody(TensorType type) : ( (<LSQUARE>)* value = expression() (<RSQUARE>)* { cells.add(value); } )* ( <COMMA> (<LSQUARE>)* value = expression() (<RSQUARE>)* { cells.add(value); } )* // <RSQUARE> - { return DynamicTensor.from(type, TensorFunctionNode.wrapScalars(cells)); } + { return cells; } } void tensorCell(TensorType type, java.util.Map cells) : |