[erlang-questions] Leex does not support ^ and $ in regexps, is there a workaround?

Metin Akat akat.metin@REDACTED
Mon Oct 3 10:33:54 CEST 2016


Hi List,

I am trying to implement a parser for Ledger (http://www.ledger-cli.org/)
journal files.
Here is an example of such a journal:


2015/10/12 Exxon
    Expenses:Auto:Gas         10.00 EUR
    Liabilities:MasterCard      -10.00 EUR

P 2015/11/21 02:18:02 USD 1.1 EUR

Here is my the current implementation: https://github.com/loxs/ledgerparse
My plan is to do lexing and parsing line by line and write my own
combinator to generate larger structures (as is in the example, one
transaction is more than one line)

So I am now starting to implement the various possible lines and I am stuck
at trying to implement the price definition (the line which is  "P
2015/11/21 02:18:02 USD 1.1 EUR")

Leex does not support ^ for beginning of line and I somehow need to
instruct the lexer to parse the leading "P" as a "pricetag token" instead
of just a "word" which can occur in various other places of the journal.

So my question is: How do I tackle this? Do I just accept "P" as a WORD
token and somehow instruct yecc to parse based on the WORD's value? Is it
even possible to do?

Any ideas are very welcome, thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161003/7ce5bb49/attachment.htm>


More information about the erlang-questions mailing list