Skip to content

Instantly share code, notes, and snippets.

@kwmiebach
Forked from jwhiteman/list_parser.yrl
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save kwmiebach/ad0f883403dfbabea6e9 to your computer and use it in GitHub Desktop.

Select an option

Save kwmiebach/ad0f883403dfbabea6e9 to your computer and use it in GitHub Desktop.
% Andrea Leopardi's list parser
% http://andrealeopardi.com/posts/tokenizing-and-parsing-in-elixir-using-leex-and-yecc/
Nonterminals list elems elem.
Terminals '[' ']' ',' int atom.
Rootsymbol list.
list -> '[' ']' : [].
list -> '[' elems ']' : '$2'.
elems -> elem : ['$1'].
elems -> elem ',' elems : ['$1'|'$3'].
elem -> int : extract_token('$1').
elem -> atom : extract_token('$1').
elem -> list : '$1'.
Erlang code.
extract_token({_Token, _Line, Value}) -> Value;
extract_token({_Token, Value}) -> Value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment