goccmack / gocc

Parser / Scanner Generator
Other
618 stars 48 forks source link

Feature/human error #115

Closed kfsone closed 3 years ago

kfsone commented 3 years ago

Note: Because this changes errors.go, a lot of the generated files changed, so I split this into two commits -- one with just my changes and a second with the generated outputs.

This change turns the generated Error.Error() function to produce more human-friendly outputs, designed to be prefixed with the traditional "FLC" (file.go:line:col:) that makes parsers interact well with IDEs and editors.

2:5: error: expected one of ",", "}", int, float, or string; got: error

If the user prefixes this with the name of the file being parsed:

C:\users\oliver\sample.txt:2:5: error: expected one of ",", "}", int, float, or string; got: error

See https://github.com/goccmack/gocc/issues/109

awalterschulze commented 3 years ago

This looks really great.

I don't know if the Severity and EOFRepresentation variables are necessary. The global nature of it irks me and it seems like we could choose sensible defaults, such that it is not necessary to edit.

awalterschulze commented 3 years ago

I am close to accepting and merging this diff if any other maintainers what to take a look

awalterschulze commented 3 years ago

@kfsone please resolve conflicts in this diff. I am ready to merge :)

kfsone commented 3 years ago

@awalterschulze rebased, resolved & squashed. I also removed the "part 1 just the changes" from the description.

awalterschulze commented 3 years ago

Thanks again, this is a really great upgrade. Great job.