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

Richard A. O'Keefe ok@REDACTED
Mon Oct 3 23:30:09 CEST 2016



On 3/10/16 9:33 PM, Metin Akat wrote:
> Hi List,
>
> I am trying to implement a parser for Ledger
> (http://www.ledger-cli.org/) journal files.

Is there any precise specification of the format?
I skimmed through the manual but could not find one.

It seems to be a line-oriented format, so why not
tokenise a line at a time?

> Here is an example of such a journal:
>
>
> 2015/10/12 Exxon

This might yield [{date,...},{text,...}]
>     Expenses:Auto:Gas         10.00 EUR
This might yield
       [{indent,4},{text,...},{number,...},{text,..}
>     Liabilities:MasterCard      -10.00 EUR
This might yield
       [{indent,4},{text,...},{number,...},{text,...}
>
> P 2015/11/21 02:18:02 USD 1.1 EUR
This might yield
       [{text,...},{date,...},{time,...},{text,...},{number,...},{text,...}]

Oh, you are doing line at a time.
It's not clear why the *lexer* has to recognise P as a
pricetag token.  Why can't the *parser* recognise that the
first thing on the line isn't a date or an indent?

Another possibility, if you are lexing a line at a time,
is to jam a fake character (like Ctrl-A) at the beginning
of a line before handing it to leex.



More information about the erlang-questions mailing list