You can use leex, yecc, spell1 and some others.
- leex: A regular expression based lexical analyzer generator for Erlang, similar to lex or flex. A lexer file includes parts for - Definition,- Rulesand also Erlang codes.
 
- yecc: An LALR-1 parser generator for Erlang, similar to yacc. A parser generator file includes parts for - Non-terminals,- Terminals,- Rulesand- Root-symbols.
 
- spell1: An LL(1) parser generator for Erlang and LFE which is a Lisp dialect language on top of Erlang. 
- neotoma: A packrat parser-generator for Erlang for Parsing Expression Grammars (PEGs). 
Some open source projects that uses them:
- Efene: Alternative syntax for the Erlang Programming Language focusing on simplicity, ease of use. It uses leex and yecc for parsing the language syntax of Efene.
- ErlyDTL: Django templates for Erlang which uses leex and yecc to parse Django based template language.
- Tnesia: A time-series database which has a SQL-like language (TQL) which implemented with leex and yecc. 
This Slide includes some useful examples about how to use them.