Skip to content

Commit

Permalink
support one item map
Browse files Browse the repository at this point in the history
>>> {}
\#{}
>>> {a: 1}
\#{a => 1}
  • Loading branch information
marianoguerra committed Sep 28, 2016
1 parent 3d90624 commit 079172e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/otl_lexer.xrl
Expand Up @@ -36,6 +36,7 @@ CloseMap = \}
ConsOp = ::
Sep = ,
Dot = \.
Colon = :
Concat = (\+\+|--)

String = "(\\\^.|\\.|[^\"])*"
Expand Down Expand Up @@ -75,6 +76,7 @@ Rules.
{ConsOp} : make_token(cons_op, TokenLine, TokenChars).
{Sep} : make_token(sep, TokenLine, TokenChars).
{Dot} : make_token(dot, TokenLine, TokenChars).
{Colon} : make_token(colon, TokenLine, TokenChars).

{Concat} : make_token(concat_op, TokenLine, TokenChars).

Expand Down
6 changes: 5 additions & 1 deletion src/otl_parser.yrl
Expand Up @@ -10,7 +10,7 @@ Nonterminals
match
literal
list tuple map
list_items seq_items
list_items seq_items map_item
fn_call.

Terminals
Expand All @@ -28,6 +28,7 @@ Terminals
sep
concat_op
dot
colon
nl.

Rootsymbol
Expand Down Expand Up @@ -90,6 +91,9 @@ list -> open_list close_list : {nil, line('$1')}.
list -> open_list list_items close_list : '$2'.

map -> open_map close_map : {map, line('$1'), []}.
map -> open_map map_item close_map : {map, line('$1'), ['$2']}.

map_item -> literal colon literal : {map_field_assoc, line('$1'), '$1', '$3'}.

list_items -> literal : {cons, line('$1'), '$1', {nil, line('$1')}}.
list_items -> literal sep : {cons, line('$1'), '$1', {nil, line('$1')}}.
Expand Down

0 comments on commit 079172e

Please sign in to comment.