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.
This commit is contained in:
Kevin 2020-05-11 20:14:40 -04:00
parent 826ad27552
commit 650eb73721

View File

@ -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`