Hi,
I'm writing a parser in Emacs Lisp. It's a parser for text files looking like this:
rule:
int: 1, 2, 3, ...
string: and, or, then, when
text:
----------
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque
in tellus. In pharetra consequat augue. In congue. Curabitur
pellentesque iaculis eros. Proin magna odio, posuere sed, commodo nec,
varius nec, tortor.
----------
more: ...
rule:
...
I don't really care about the key (int, string, ...). I want the value. So for the file above int has value "1, 2, 3, ...", string "and, or, then, when" and text "Lorem ..." (excluding the dashes).
I'm thinking about two different solutions, but I don't which one to use. Should I:
create a simple parser that loops through all lines and for each line matches it with some regex and then group the parts I want out?
do a more sophisticated parser with a lexer and a parser?
Right now the files are quite simple and I guess I don't need to do something as advance as the second option. But these files may get a bit more complicated, so I want to make it easy to extend.
How would you solve this?