diff options
-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) : |