From: Kevin Date: Tue, 12 May 2020 00:14:40 +0000 (-0400) Subject: Add support dictionary literals to grammar X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=650eb7372159cbb7b04ab413e9df0b43bdc30bb7;p=thirdparty%2Fjinja.git Add support dictionary literals to grammar This also allows dictionary values to be variables instead of just regular identifiers, a change which might be made to other literals such as lists and tuples in the future as we determine what those also support. --- diff --git a/grammar.ebnf b/grammar.ebnf index 53bb8254..0f97c06f 100644 --- a/grammar.ebnf +++ b/grammar.ebnf @@ -329,10 +329,25 @@ LITERAL | STRING_LITERAL | NUMBER_LITERAL | BOOLEAN_LITERAL + | DICTIONARY_LITERAL | LIST_LITERAL | TUPLE_LITERAL ; +DICTIONARY_LITERAL + = + literal_type:`dictionary` + ( + | ( "{" {SP}* value+:dictionary_key_value { {SP}* "," {SP}* value+:dictionary_key_value } {SP}* "}" ) + | ( "{" {SP}* "}" ) + ) + ; + +dictionary_key_value + = + key:STRING_LITERAL {SP}* ":" {SP}* value:variable_identifier + ; + LIST_LITERAL = literal_type:`list`