Hledger: Regex aliases do not allow forward-slash '/' character

Created on 5 Mar 2019  路  7Comments  路  Source: simonmichael/hledger

The hledger docs show a nice way to rewrite all account names to allow using a period character . instead of a colon : as the account separator:

alias /\./=:

Changing this to an escaped forward slash results in an unexpected syntax error:

hledger: hledger.journal:5:10:
  |
5 | alias /\// = :
  |          ^
unexpected '/'
expecting '='

It seems like the forward slash isn't escaped, so the regex ends early.

A BUG easy? journal

All 7 comments

Thanks for the report.

have done a tiny bit of Haskell before and might have a look at this tomorrow :)

Looks like regex alias parsing occurs at JournalReader.hs#L438. Line 442 reads the regex. But any / ends it, escaping isn't considered.

Would love to fix this so I can pretend my accounts are directories like a true *nix addict, but I'm not sure how to begin. Rewrite \/ to / and continue reading, perhaps? @simonmichael any chance you could point me to similar/related code, or some tutorials for the do construct?

@raehik I don't know either, off the top of my head. It's a parsing problem, not too hard I think. If I were you I would (after skimming a few of its tutorials, maybe) get familiar with megaparsec's api/combinators, something in there is bound to be helpful. Once you've done that you could also ask for ideas on #haskell.

(which you can find by starting at http://hackage.haskell.org/package/megaparsec)

Cheers for the links! I'll do some reading when I can, & I believe building locally worked fine so I can mess around.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artkpv picture artkpv  路  3Comments

simonmichael picture simonmichael  路  8Comments

varac picture varac  路  9Comments

lucianf picture lucianf  路  8Comments

adityag81 picture adityag81  路  5Comments