def build_valid_keywords_grammar(keywords=None):
from invenio_query_parser.parser import KeywordQuery, KeywordRule,NotKeywordValue, SimpleQuery, ValueQuery<EOL>if keywords:<EOL><INDENT>KeywordRule.grammar = attr('<STR_LIT:value>', re.compile(<EOL>r"<STR_LIT>".format("<STR_LIT:|>".join(keywords), re.I)))<EOL>NotKeywordValue.grammar = attr('<STR_LIT:value>', re.compile(<EOL>r'<STR_LIT>'.format(<EOL>"<STR_LIT>".join(keywords))))<EOL>SimpleQuery.grammar = attr(<EOL>'<STR_LIT>', [NotKeywordValue, KeywordQuery, ValueQuery])<EOL><DEDENT>else:<EOL><INDENT>KeywordRule.grammar = attr('<STR_LIT:value>', re.compile(r"<STR_LIT>"))<EOL>SimpleQuery.grammar = attr('<STR_LIT>', [KeywordQuery, ValueQuery])<EOL><DEDENT>
Update parser grammar to add a list of allowed keywords.