summaryrefslogtreecommitdiffstats
path: root/integration
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-05-30 11:26:21 +0200
committerJon Bratseth <bratseth@gmail.com>2022-05-30 11:26:21 +0200
commitee53e8f4be27b357834f171326ccf88d3adc9997 (patch)
treeb3b805223427268bb4cf39bf2d8b56a48337983a /integration
parent63e0ca74266f7422cbcd528ff7c8327634ca2a88 (diff)
Grammar fixes
Diffstat (limited to 'integration')
-rw-r--r--integration/intellij/src/main/bnf/ai/vespa/intellij/schema/parser/sd.bnf23
1 files changed, 17 insertions, 6 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 59028366edf..4eb57044441 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
@@ -220,7 +220,9 @@ FunctionDefinition ::= (function | macro) inline? IdentifierVal Arguments
implements=["ai.vespa.intellij.schema.psi.SdFunctionDefinitionInterface" "ai.vespa.intellij.schema.psi.SdNamedElement"]
}
-Arguments ::= '()' | ( ClauseStart ArgumentDefinition (CommaSeparator ArgumentDefinition)* ClauseEnd )
+// Not using ClauseEnd here to avoid consuming trailing NL's, which must be left to terminate single-line
+// rank feature lists in summary/match/rank-features
+Arguments ::= '()' | ( ClauseStart ArgumentDefinition (CommaSeparator ArgumentDefinition)* (NL)* ')' )
// When used in function declarations this should really be IdentifierVal only
ArgumentDefinition ::= IdentifierVal | INTEGER_REG | STRING_REG | STRING_REG_SINGLE_QUOTE
@@ -228,11 +230,11 @@ ArgumentDefinition ::= IdentifierVal | INTEGER_REG | STRING_REG | STRING_REG_SIN
implements=["ai.vespa.intellij.schema.psi.SdDeclaration" "ai.vespa.intellij.schema.psi.SdNamedElement"]
}
-SummaryFeaturesDefinition ::= summary-features ((':' RankFeature+ (NL)+) | ((inherits IdentifierWithDashVal)? BlockStart ( RankFeature | NL )* BlockEnd))
+SummaryFeaturesDefinition ::= summary-features ((':' (RankFeature)+ (NL)+) | ((inherits IdentifierWithDashVal)? BlockStart ( RankFeature | NL )* BlockEnd))
-MatchFeaturesDefinition ::= match-features ((':' RankFeature+ (NL)+) | ((inherits IdentifierWithDashVal)? BlockStart ( RankFeature | NL )* BlockEnd))
+MatchFeaturesDefinition ::= match-features ((':' (RankFeature)+ (NL)+) | ((inherits IdentifierWithDashVal)? BlockStart ( RankFeature | NL )* BlockEnd))
-RankFeaturesDefinition ::= rank-features ((':' RankFeature+ (NL)+) | (BlockStart ( RankFeature | NL )* BlockEnd))
+RankFeaturesDefinition ::= rank-features ((':' (RankFeature)+ (NL)+) | (BlockStart ( RankFeature | NL )* BlockEnd))
ConstantsDefinition ::= constants BlockStart ( InnerConstantDefinition | NL )* BlockEnd
@@ -240,7 +242,7 @@ InnerConstantDefinition ::= ( ("constant" ClauseStart IdentifierVal ClauseEnd )
(':')? ( TensorType | "double" )?
(':')? ( TensorValue | AnyNumber | (file ':' FilePath) | (uri ':' UriPath))
-RankFeature ::= IdentifierVal (Arguments)? ( '.' IdentifierVal )*
+RankFeature ::= ForEachFeature | ( IdentifierVal (Arguments)? ( '.' IdentifierVal )* )
{ mixin="ai.vespa.intellij.schema.psi.impl.SdNamedElementImpl"
implements=["ai.vespa.intellij.schema.psi.SdDeclaration" "ai.vespa.intellij.schema.psi.SdNamedElement"]
}
@@ -249,6 +251,15 @@ QueryFeature ::= "query" '(' IdentifierWithDashVal ')'
implements=["ai.vespa.intellij.schema.psi.SdDeclaration" "ai.vespa.intellij.schema.psi.SdNamedElement"]
}
+// Needs special handling due to the nested rank feature, and the condition
+ForEachFeature ::= "foreach" ClauseStart
+ IdentifierVal CommaSeparator // dimension
+ IdentifierVal CommaSeparator // variable
+ RankFeature CommaSeparator // feature
+ ( ('>' AnyNumber) | ('<' AnyNumber) | "true" | STRING_REG ) CommaSeparator // condition
+ IdentifierVal // operation
+ ClauseEnd
+
//-------------------------
//---- Document rules -----
//-------------------------
@@ -371,7 +382,7 @@ IdentifierWithDashVal ::= IdentifierVal ('-' ( IdentifierVal | INTEGER_REG ) )*
{ mixin="ai.vespa.intellij.schema.psi.impl.SdIdentifierMixin"
implements=["ai.vespa.intellij.schema.psi.SdIdentifier"]
}
-DottedIdentifierWithDash ::= IdentifierWithDashVal ('.' IdentifierWithDashVal)*
+DottedIdentifierWithDash ::= IdentifierWithDashVal ('.' IdentifierWithDashVal )*
BlockStart ::= (NL)* '{' (NL)*
BlockEnd ::= (NL)* '}' (NL)*