New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem : Parser errors are not informative. #402

Closed
crocket opened this Issue Sep 14, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@crocket

crocket commented Sep 14, 2016

commodity BTC
  note Bitcoin

When I parse the above journal with hledger, it should report that note is not a supported subdirective of commodity directive.

Instead, the parser reports the following error.

hledger: ledger.journal:1:1:
unexpected 'c'
expecting end of input or transaction or directive

The same happens when account directive contains unsupported subdirectives and when the end of a journal file is not a new line. When the end of a journal file is not a newline, the parser reports an error at the beginning of the last transaction or any last directive.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Sep 14, 2016

Owner

Agreed, thanks.

Owner

simonmichael commented Sep 14, 2016

Agreed, thanks.

@simonmichael simonmichael modified the milestone: 1.1 Dec 29, 2016

@karan-ta

This comment has been minimized.

Show comment
Hide comment
@karan-ta

karan-ta May 1, 2017

I started using timedot format and created a new file with contents :
2016/2/2
client1 .... ....
research .

but i got error -
using conversion rules file /karanahuja.timedot.rules
hledger: "/karanahuja.timedot" (line 2, column 1):
unexpected 'i'
expecting journal transaction or directive or end of input

karan-ta commented May 1, 2017

I started using timedot format and created a new file with contents :
2016/2/2
client1 .... ....
research .

but i got error -
using conversion rules file /karanahuja.timedot.rules
hledger: "/karanahuja.timedot" (line 2, column 1):
unexpected 'i'
expecting journal transaction or directive or end of input

@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael May 1, 2017

Owner

That looks strange. I can't reproduce here with hledger 1.2..

Owner

simonmichael commented May 1, 2017

That looks strange. I can't reproduce here with hledger 1.2..

@simonmichael simonmichael added the timedot label May 1, 2017

ony added a commit to ony/hledger that referenced this issue Nov 3, 2017

journal: limit scope of directives backtracking
Effectively improves error reporting for directives.

Resolves simonmichael#402

@ony ony added the in progress label Nov 3, 2017

@ony ony self-assigned this Nov 3, 2017

@ony

This comment has been minimized.

Show comment
Hide comment
@ony

ony Nov 3, 2017

Collaborator

@crocket I agree that errors sometimes quiet hard to understand because of excessive backtracking in journal parser.

Note that it is hard to identify "not supported" because it means that we should already partially support that sub-directive in parser. On the other hand most of the parser able to generate meaningful error message with their expectations. Example:

hledger: -:2:3:
unexpected 'n'
expecting "format"
Collaborator

ony commented Nov 3, 2017

@crocket I agree that errors sometimes quiet hard to understand because of excessive backtracking in journal parser.

Note that it is hard to identify "not supported" because it means that we should already partially support that sub-directive in parser. On the other hand most of the parser able to generate meaningful error message with their expectations. Example:

hledger: -:2:3:
unexpected 'n'
expecting "format"

ony added a commit to ony/hledger that referenced this issue Nov 27, 2017

journal: limit scope of directives backtracking
Effectively improves error reporting for directives.

Resolves simonmichael#402

ony added a commit to ony/hledger that referenced this issue Nov 27, 2017

journal: limit scope of directives backtracking
Effectively improves error reporting for directives.

Resolves simonmichael#402
@ony

This comment has been minimized.

Show comment
Hide comment
@ony

ony Nov 27, 2017

Collaborator

With newer MegaParsec you can get even better error report:

hledger: -:2:3:
unexpected "note B"
expecting "format"
Collaborator

ony commented Nov 27, 2017

With newer MegaParsec you can get even better error report:

hledger: -:2:3:
unexpected "note B"
expecting "format"

ony added a commit to ony/hledger that referenced this issue Nov 27, 2017

journal: limit scope of directives backtracking
Effectively improves error reporting for directives.

Resolves simonmichael#402

simonmichael added a commit that referenced this issue Nov 27, 2017

journal: limit scope of directives backtracking
Effectively improves error reporting for directives.

Resolves #402
@simonmichael

This comment has been minimized.

Show comment
Hide comment
@simonmichael

simonmichael Nov 27, 2017

Owner

The specific error reported by this issue has been improved: #640 (comment)

Owner

simonmichael commented Nov 27, 2017

The specific error reported by this issue has been improved: #640 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment