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

Dig into line/row numbers in the parser #732

Open
purpleidea opened this issue Jan 28, 2024 · 3 comments
Open

Dig into line/row numbers in the parser #732

purpleidea opened this issue Jan 28, 2024 · 3 comments

Comments

@purpleidea
Copy link
Owner

Description:

We currently don't have good position (line/row) information about errors from the parser. We'd like to have that information both from parser errors (an error that occurs during the parsing stage) but we'd also like to have that positional information when it occurs in a later stage, such as type unification, and so on.

To get that information, we need to embed it in each AST node. Figure out how this works in goyacc, and propose an early proof-of-concept. We'll help you morph that from rough code to production polish if needed.

Some information is here:

// FIXME: get these values, by tracking pos in parser...

More here:

// pos is a helper function used to track the position in the lexer.

Design:

You probably want to eventually add a new interface that sets the position of row/col for each AST node, either that, or am embedded struct with the data, or both. Don't worry about how this works right away, but I expect that's where we'll end up.

Minimally-viable:

At a bare minimum, try and get mgmt running with a simple mcl file that shows an obvious type unification error (4 == "foo") type of thing. Then we'll see if we can print the line numbers of those expressions and statements.

Longer term:

We should want to pass the line information into the type unification, so that we can include that information when we error.

Questions?

Ask early and often. Post an early version of the code, even if it doesn't compile or work perfectly. Don't spend tool long without checking-in if you feel lost.

Cheers!

@ffrank
Copy link
Contributor

ffrank commented Mar 18, 2024

@Juneezee have you been working on this? I would be up for cooperating.

@Juneezee
Copy link
Contributor

@Juneezee have you been working on this? I would be up for cooperating.

Hi @ffrank, thanks for offering to help! I have been occupied with work lately I haven't had a chance to dive into this yet.

@ffrank
Copy link
Contributor

ffrank commented Mar 23, 2024

So far I have come up with #750 but it's fraught.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants