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

Add line numbers to parser error messages #574

Closed
Tracked by #547 ...
bobbinth opened this issue Dec 2, 2022 · 2 comments
Closed
Tracked by #547 ...

Add line numbers to parser error messages #574

bobbinth opened this issue Dec 2, 2022 · 2 comments
Assignees
Labels
assembly Related to Miden assembly enhancement New feature or request good first issue Good for newcomers

Comments

@bobbinth
Copy link
Contributor

bobbinth commented Dec 2, 2022

To improve debugging experience, it may be helpful to know which lines in the source file contain malformed instructions. This can be achieved by adding line numbers to the ParsingError messages.

To do this, we need to add line number to the Token struct. This may be in addition to, or instead of, the current pos field. This also means that we should collect line number info when we construct a token stream (i.e., here).

It would probably make sense to track line numbers is a separate map inside a TokenStream. This map would map a token position to a line number. This may result in a non-negligible performance overhead, and thus, we may want to introduce an option to instantiate token streams in debug mode. Then, line number info would be collected only in debug mode.

Note: this would help only with errors generated by the parsers. For better run-time debugging experience a more comprehensive solution is needed.

@bobbinth bobbinth added enhancement New feature or request good first issue Good for newcomers assembly Related to Miden assembly labels Dec 2, 2022
@vlopes11 vlopes11 assigned vlopes11 and unassigned vlopes11 Dec 7, 2022
@bobbinth bobbinth changed the title Add line numbers to parer error messages Add line numbers to parser error messages Jan 31, 2023
@MuhtasimTanmoy
Copy link
Contributor

I would like to work on this.

vlopes11 added a commit that referenced this issue Apr 14, 2023
Prior to this commit, [ParsingError] tracked the step of the source
instead of the line number.

This is not friendly to the user as he won't be able to find the
location of the error. A common standard is to display the line number,
so the user can easily spot the location of the error.

This commit introduces such track. It keeps a 1:1 map on [TokenStream]
from the token to the parsed line. As in common text editors, line
number starts at `1`.

It also removes the `pos` from [Token] as its only purpose was to
display the step to the user. The introduction of `line` completely
supersedes that.

closes #574
vlopes11 added a commit that referenced this issue Apr 16, 2023
Prior to this commit, [ParsingError] tracked the step of the source
instead of the line number.

This is not friendly to the user as he won't be able to find the
location of the error. A common standard is to display the line number,
so the user can easily spot the location of the error.

This commit introduces such track. It keeps a 1:1 map on [TokenStream]
from the token to the parsed line. As in common text editors, line
number starts at `1`.

It also removes the `pos` from [Token] as its only purpose was to
display the step to the user. The introduction of `line` completely
supersedes that.

closes #574
@bobbinth
Copy link
Contributor Author

Closed by #854.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assembly Related to Miden assembly enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants