-
Notifications
You must be signed in to change notification settings - Fork 114
Source parsing tests #170
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
Source parsing tests #170
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have one minor suggestion for the file_parse_error
. Since we have the line number already, it might be more verbose to print the line of the source file as well, maybe, in case we know, even highlight the offending part in some way.
I did something similar for the TOML parsing with a context from the tokenizer to provide some visual aid together with the error message:
https://github.com/toml-f/toml-f/blob/d7371fc8/src/tomlf/error.f90#L215-L243
Allows optional line number, line string value and line column output.
Thanks @awvwgk 👍
Great idea! That's a neat implementation too! I've now added more context output, though in most cases indicating the offending column may have to wait until a proper parsing library is used. |
end function parse_c_source | ||
|
||
|
||
function split_n(string,delims,n,stat) result(substring) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move these into an fpm_string.f90
module, and eventually get these into stdlib
.
But let's first merge this PR, then we can refactor later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I know writing tests is often a thankless chore, but it looks like you've really shored this part up with it, so thanks! :)
As discussed in #155, this uses the
error_t
type to return and propagate errors from the new source parsing routines.Adds a test suite for the parsing routines - any difficult parsing edge cases can be added in there as they are found.
There are other regions from #155 that still require test coverage.