Skip to content
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

Contemplate a way to trace each part of the parsed output back to the original SDP #125

Open
na-g opened this issue Jun 7, 2019 · 4 comments

Comments

@na-g
Copy link
Collaborator

na-g commented Jun 7, 2019

In order to facilitate debugging the output of the parser should be correlated somehow with the source.

@nils-ohlmeier
Copy link
Collaborator

Line numbers come to my mind as the obvious way to link. The parser has a knowledge of line numbers up to a certain point, after which it drops that information.

Adding line numbers to everything would probably require to put:

  • either puts lots of the structs into a shared struct holding the line information
  • adding line numbers into the structs them self

The first option appears to be more elegant, but breaks existing APIs quite a bit. The second option would not break the APIs quite as badly, but requires to make changes to a lot of code.

@na-g
Copy link
Collaborator Author

na-g commented Jun 11, 2019

I think all options will be fairly code change intensive.

I personally like the second option better for a few reasons. 1) I think it will result in a more usable API in which the data is directly available on the related object, 2) you can hold on to only the parts of the parse tree you need after parsing, 3) it would present a simpler FFI interface. A trait for the parsed objects could return a ParseContext struct containing the line number.

A third approach on the same order of invasivity, is to change the parser to a push parser, so that instead of getting a parsed structure back you get a series of parsing events which can contain their context.

Thoughts?

@na-g na-g added this to the 0.3 milestone Jun 12, 2019
@nils-ohlmeier
Copy link
Collaborator

How granular would the events be? Per m-section, or per line, or...?
I have a hard time to imagine how such a push based interface works when you want to use it not from Rust, but for example C++. Callbacks?

@na-g
Copy link
Collaborator Author

na-g commented Jul 18, 2019

The use of callbacks is the way I have seen push parsers done in the past. It may actually be a fairly simple FFI. As time has passed, I think I like option 2 more and more. Push parsing would require far more boiler plate code.

@na-g na-g removed this from the 0.3 milestone Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants