vickenty / lang-c

Lightweight C parser for Rust
Apache License 2.0
202 stars 30 forks source link

More precise parser error #10

Open sertel opened 5 years ago

sertel commented 5 years ago

When the parser encounters a type that is unknown, it fails with the following error:

expected: {"<typedef_name>"}

It would be extremely helpful if the parser would at the following point in the parser code:

__state.mark_failure(__pos, "<typedef_name>");

make an effort to print the actual type that it can not parse.

vickenty commented 5 years ago

Indeed, error reporting is one of the weak places currently.

Our current parser generator lacks the facility to report exact text that failed to parse. We do return expanded source code and position, so the type name can be recovered from that. We could provide some helper functions to do that.