Skip to content

Commit

Permalink
support empty map
Browse files Browse the repository at this point in the history
>>> {}
\#{}
  • Loading branch information
marianoguerra committed Sep 28, 2016
1 parent c9cd61a commit 3d90624
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/otl_lexer.xrl
Expand Up @@ -30,6 +30,9 @@ Close = \)
OpenList = \[
CloseList = \]

OpenMap = \{
CloseMap = \}

ConsOp = ::
Sep = ,
Dot = \.
Expand Down Expand Up @@ -66,6 +69,9 @@ Rules.
{OpenList} : make_token(open_list, TokenLine, TokenChars).
{CloseList} : make_token(close_list, TokenLine, TokenChars).

{OpenMap} : make_token(open_map, TokenLine, TokenChars).
{CloseMap} : make_token(close_map , TokenLine, TokenChars).

{ConsOp} : make_token(cons_op, TokenLine, TokenChars).
{Sep} : make_token(sep, TokenLine, TokenChars).
{Dot} : make_token(dot, TokenLine, TokenChars).
Expand Down
6 changes: 5 additions & 1 deletion src/otl_parser.yrl
Expand Up @@ -9,7 +9,7 @@ Nonterminals
bool_and_op
match
literal
list tuple
list tuple map
list_items seq_items
fn_call.

Expand All @@ -23,6 +23,7 @@ Terminals
atom
open close
open_list close_list
open_map close_map
cons_op
sep
concat_op
Expand Down Expand Up @@ -82,11 +83,14 @@ literal -> atom : '$1'.
literal -> open bool_or_op close : '$2'.
literal -> list : '$1'.
literal -> tuple : '$1'.
literal -> map : '$1'.
literal -> fn_call : '$1'.

list -> open_list close_list : {nil, line('$1')}.
list -> open_list list_items close_list : '$2'.

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

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

0 comments on commit 3d90624

Please sign in to comment.