Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.