diff options
author | Jon Bratseth <bratseth@oath.com> | 2019-01-11 14:54:17 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-01-31 13:02:29 +0100 |
commit | 23835c0ef5dfe290b3d08aa69a820bf268f5f7a0 (patch) | |
tree | 297a1b081b3f467e0fcd7c79d33a89ae61fe0d2c /config-model/src/main/javacc | |
parent | e6dd1ced58cf74b76bbadc92fb2ee4f0c3c4a92d (diff) |
Disallow dash in search definition, document, field and function names
Diffstat (limited to 'config-model/src/main/javacc')
-rw-r--r-- | config-model/src/main/javacc/SDParser.jj | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 883dfc7ac72..60af7d7ab83 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -357,7 +357,8 @@ TOKEN : | < CONSTANTS: "constants" > | < FILE: "file" > | < URI: "uri" > -| < IDENTIFIER: ["a"-"z","A"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_","-"])* > +| < IDENTIFIER: ["a"-"z","A"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_"])* > +| < IDENTIFIER_WITH_DASH: ["a"-"z","A"-"Z", "_"] (["a"-"z","A"-"Z","0"-"9","_","-"])* > | < QUOTEDSTRING: "\"" ( ~["\""] )* "\"" > | < CONTEXT: ["a"-"z","A"-"Z"] (["a"-"z", "A"-"Z", "0"-"9"])* > | < DOUBLE: ("-")? (["0"-"9"])+ "." (["0"-"9"])+ > @@ -669,14 +670,15 @@ void fieldSetItem(String setName, Search search) : ( <FIELDS><COLON> field=identifier() { search.fieldSets().addUserFieldSetItem(setName, field); } ( <COMMA> field=identifier() { search.fieldSets().addUserFieldSetItem(setName, field); } )* ) | - ( <QUERYCOMMAND> <COLON> (queryCommand = identifier() | queryCommand = quotedString())) { search.fieldSets().userFieldSets().get(setName).queryCommands().add(queryCommand);} + ( <QUERYCOMMAND> <COLON> (queryCommand = identifierWithDash() | queryCommand = quotedString())) { search.fieldSets().userFieldSets().get(setName).queryCommands().add(queryCommand);} | ( match(matchSettings) ) { matchSettings.applyOperations(); search.fieldSets().userFieldSets().get(setName).setMatching(matchSettings.getMatching());} } /** * This rule consumes a annotation block from within either a document element or a search element. - * @param search The search object to add content to. + + * @param search the search object to add content to. */ void annotationOutside(Search search) : { @@ -698,6 +700,7 @@ void annotationOutside(Search search) : /** * This rule consumes a annotation block from within either a document element. + * * @param document The document object to add content to. */ void annotation(Search search, SDDocumentType document) : @@ -1183,7 +1186,7 @@ Object sortingSetting(SortingOperation sorting, String attributeName) : | <QUATERNARY> { sorting.setStrength(Sorting.Strength.QUATERNARY); } | <IDENTICAL> { sorting.setStrength(Sorting.Strength.IDENTICAL); } ) - | <LOCALE> <COLON> locale = identifier() { sorting.setLocale(locale); } + | <LOCALE> <COLON> locale = identifierWithDash() { sorting.setLocale(locale); } ) { return null; } } @@ -1426,7 +1429,7 @@ void summaryProperty(SummaryInFieldLongOperation field) : String name, value; } { - name = identifier() <COLON> (value = identifier() | value = quotedString()) + name = identifierWithDash() <COLON> (value = identifierWithDash() | value = quotedString()) { field.addProperty(new SummaryField.Property(name, value)); } } @@ -1441,7 +1444,7 @@ void fieldStemming(FieldOperationContainer field) : StemmingOperation op = new StemmingOperation(); } { - <STEMMING> <COLON> setting = identifier() + <STEMMING> <COLON> setting = identifierWithDash() { op.setSetting(setting); field.addOperation(op); @@ -1458,7 +1461,7 @@ void searchStemming(Search search) : String setting; } { - <STEMMING> <COLON> setting = identifier() + <STEMMING> <COLON> setting = identifierWithDash() { search.setStemming(Stemming.get(setting)); } } @@ -1473,7 +1476,7 @@ void normalizing(FieldOperationContainer field) : String setting; } { - <NORMALIZING> <COLON> setting = identifier() + <NORMALIZING> <COLON> setting = identifierWithDash() { field.addOperation(new NormalizingOperation(setting)); } @@ -1527,7 +1530,7 @@ void queryCommand(FieldOperationContainer container) : QueryCommandOperation field = new QueryCommandOperation(); } { - <QUERYCOMMAND> <COLON> command = identifier() + <QUERYCOMMAND> <COLON> command = identifierWithDash() { field.addQueryCommand(command); container.addOperation(field); @@ -1540,7 +1543,7 @@ void alias(FieldOperationContainer container) : String alias; } { - <ALIAS> [aliasedName = identifier()] <COLON> alias = identifier() + <ALIAS> [aliasedName = identifier()] <COLON> alias = identifierWithDash() { AliasOperation op = new AliasOperation(aliasedName, alias); container.addOperation(op); @@ -1773,9 +1776,9 @@ Object indexBody(IndexOperation index) : double threshold; } { - ( <PREFIX> { index.setPrefix(true); } - | <ALIAS> <COLON> str = identifier() { index.addAlias(str); } - | <STEMMING> <COLON> str = identifier() { index.setStemming(str); } + ( <PREFIX> { index.setPrefix(true); } + | <ALIAS> <COLON> str = identifierWithDash() { index.addAlias(str); } + | <STEMMING> <COLON> str = identifierWithDash() { index.setStemming(str); } | <ARITY> <COLON> arity = integer() { index.setArity(arity); } | <LOWERBOUND> <COLON> num = consumeLong() { index.setLowerBound(num); } | <UPPERBOUND> <COLON> num = consumeLong() { index.setUpperBound(num); } @@ -1855,7 +1858,7 @@ void rankProfile(Search search) : RankProfile profile; } { - ( <RANKPROFILE> name = identifier() + ( <RANKPROFILE> name = identifierWithDash() { if (documentsOnly) { profile = new DocumentsOnlyRankProfile(name, search, rankProfileRegistry); @@ -1912,7 +1915,7 @@ void inheritsRankProfile(RankProfile profile) : String str; } { - <INHERITS> str = identifier() + <INHERITS> str = identifierWithDash() { profile.setInherited(str); } } @@ -2211,9 +2214,9 @@ String rankPropertyItem() : String image, ret = ""; } { - ( ( image = identifier() { ret += image; } - | image = quotedString() { ret += image; } - | ( "(" | ")" | <DOT> | <COMMA> ) { ret += token.image; } )+ ) + ( ( image = identifierWithDash() { ret += image; } + | image = quotedString() { ret += image; } + | ( "(" | ")" | <DOT> | <COMMA> ) { ret += token.image; } )+ ) { return ret; } } @@ -2454,6 +2457,16 @@ String expression() : { return exp; } } +String identifierWithDash() : +{ + String identifier; +} +{ + ( identifier = identifier() { return identifier; } ) + | + ( <IDENTIFIER_WITH_DASH> { return token.image; } ) +} + /** * This rule consumes an identifier. This must be kept in sync with all word tokens that should be parseable as * identifiers. |