Skip to content

Instantly share code, notes, and snippets.

@jwhiteman
Created June 13, 2015 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jwhiteman/adee4036124b3f779153 to your computer and use it in GitHub Desktop.
Save jwhiteman/adee4036124b3f779153 to your computer and use it in GitHub Desktop.
List Parser
% 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment