howeyc / ledger

Command line double-entry accounting program
https://howeyc.github.io/ledger/
ISC License
461 stars 43 forks source link

More forgiving parser #4

Closed devurandom closed 8 years ago

devurandom commented 8 years ago

Thanks for this nice tool!

I had some trouble figuring out how to write ledger files. Initially I started with the following, which caused segfaults in lweb:

2016/02/20\tPayee
\tAccountA\t-100
\tAccountB

After a few tries, weird crashes and lweb sending application/x-gzip files my way, I figured out that it has to look like this (only spaces, no tabs, but a double-space before the amount):

2016/02/20 Payee
 AccountA  -100
 AccountB

Maybe the parser could be relaxed a bit, to also accept tabs in the right positions? And/or the readme could be extended by a line explaining what I said above: "only spaces, no tabs, but a double-space before the amount"?

howeyc commented 8 years ago

You're right the parser should be extended to allow for tabs.

On February 20, 2016 6:19:28 PM CST, Dennis Schridde notifications@github.com wrote:

Thanks for this nice tool!

I had some trouble figuring out how to write ledger files. Initially I started with the following, which caused segfaults in lweb:

2016/02/20\tPayee
\tAccountA\t-100
\tAccountB

After a few tries, weird crashes and lweb sending application/x-gzip files my way, I figured out that it has to look like this (only spaces, no tabs, but a double-space before the amount):

2016/02/20 Payee
AccountA  -100
AccountB

Maybe the parser could be relaxed a bit, to also accept tabs in the right positions? And/or the readme could be extended by a line explaining what I said above: "only spaces, no tabs, but a double-space before the amount"?


Reply to this email directly or view it on GitHub: https://github.com/howeyc/ledger/issues/4

howeyc commented 8 years ago

I just made a change that should help with the issue you had.

However, when using only spaces, two are required between the account and the amount since accounts can have spaces and amounts are allowed to be blank.

With only one space there is ambiguity as to whether the last word should be considered part of the account or an amount. The parser treats it as part of the account name.

Thanks for bringing this to my attention.