Feature: Better error reporting, messaging #169

Open
opened 2024-04-02 07:36:23 +01:00 by deavmi · 16 comments
Owner

Purpose ✍️

I want to have better error reporting, which entails:

  • Showing where the error happened. Think about line information
  • Better print outs for errors

Example

If for example we have source code int i = 3; then the tokens should be as follows:

  1. int
  2. i
  3. =
  4. 3
  5. ;

And the getOrigin()'s of each of these Token(s) should be as follows:

  1. int
  2. int i
  3. int i =
  4. int i = 3
  5. int i = 3;

How

I think we should implement something in every Statement to have a LineInfo struct associated with it which is a string of associated Token(s) which can be restrung together on the fly. This means we get proper line information.

  • Coords
  • Token to have getCoords()
  • LineInfo defined
  • Statement to have methods to get and set LineInfo
  • Parser to attach LineInfo to all Statements
  • BasicLexer to do setOrigin(string) when needed @gusmeyer
  • BasicLexer to have better (x,y) saving @gusmeyer
  • Common error reporting mechansim. Something whereby we give it the Statement and it automagically prints out the problem, we could even optionally position the cursor (this would imply knowing where which at that stage is probably not possible)
    • The Parser's expect() method should be correctly updated
    • In future we should maybe keep the origin transferred over to the Statement so errors that are not only in the Parser can be reported on
      • Transfer over to each Statement in parsing/core.d
## Purpose ✍️ I want to have better error reporting, which entails: - [x] Showing _where_ the error happened. Think about line information - [x] Better print outs for errors ### Example If for example we have source code `int i = 3;` then the tokens should be as follows: 1. `int` 2. `i` 3. `=` 4. `3` 5. `;` And the `getOrigin()`'s of each of these `Token`(s) should be as follows: 1. `int` 2. `int i` 3. `int i =` 4. `int i = 3` 5. `int i = 3;` ## How I think we should implement something in every `Statement` to have a `LineInfo` struct associated with it which is a string of associated `Token`(s) which can be restrung together on the fly. This means we get proper line information. - [x] `Coords` - [x] `Token` to have `getCoords()` - [x] `LineInfo` defined - [x] `Statement` to have methods to get and set `LineInfo` - [ ] ~~Parser to attach `LineInfo` to all `Statement`s~~ - [ ] `BasicLexer` to do `setOrigin(string)` when needed @gusmeyer - [ ] `BasicLexer` to have better `(x,y)` saving @gusmeyer - [ ] Common error reporting mechansim. Something whereby we give it the `Statement` and it automagically prints out the problem, we could even optionally position the cursor (this would imply knowing where which at that stage is probably not possible) - [x] The `Parser`'s `expect()` method should be correctly updated - [ ] In future we should maybe keep the origin transferred over to the `Statement` so errors that are not only in the `Parser` can be reported on - [ ] Transfer over to each `Statement` in `parsing/core.d`
deavmi added this to the Clean ups milestone 2024-04-02 07:36:23 +01:00
deavmi added spent time 2024-04-02 07:47:16 +01:00
10 minutes
deavmi started working 2024-04-02 07:47:18 +01:00
deavmi added the
parser
lexer
labels 2024-04-02 07:47:27 +01:00
deavmi self-assigned this 2024-04-02 07:47:30 +01:00
deavmi added this to the Parser project 2024-04-02 07:47:35 +01:00
deavmi added reference feature/reporting 2024-04-02 07:51:44 +01:00
Author
Owner

Most of the requirements are done

Most of the requirements are done ✅
deavmi stopped working 2024-04-02 08:16:07 +01:00
28 minutes 49 seconds
deavmi started working 2024-04-02 08:53:41 +01:00
Author
Owner

We are calling track(Token) on each and then saving afterwards:

image

Then this gives us this:

image

We are calling `track(Token)` on each and then saving afterwards: ![image](/attachments/0b8627fa-c9e8-4399-bca9-d356aa49c951) Then this gives us this: ![image](/attachments/22ab6231-5f36-4952-bcc4-e80e104a4fc3)
Author
Owner

The current tracking mechanism may not be the best. It may need nesting. It really depends on what we want but yes, definately it would need to be a little smarter.

We would like to have the expression in the while(<expression>) also have its own line info. Therefore we can maintain this maybe using enter() and leave() semantics.

The current tracking mechanism may not be the best. It may need nesting. It really depends on what we want but yes, definately it would need to be a little smarter. We would like to have the `expression` in the `while(<expression>)` also have its own line info. Therefore we can maintain this maybe using `enter()` and `leave()` semantics.
Author
Owner

openTracking() should push to a stack a new LineInfo which is used as the current one.

Mmmh, however we need like actually a trail where every open'd LineInfo gets tacked onto, that makes the most sense.

`openTracking()` should push to a stack a new `LineInfo` which is used as the current one. Mmmh, however we need like actually a trail where every open'd `LineInfo` gets tacked onto, that makes the most sense.
Author
Owner

I wonder f this is even the best way to do this? It feels bloated reconsttucting it from Token(s) when perhaps the lexer should be storing the line of each token. Whenever a newline is found you then restart that line.

I wonder f this is even the best way to do this? It feels bloated reconsttucting it _from_ `Token`(s) when perhaps the lexer should be storing the line of each token. Whenever a newline is found you then restart that line.
Author
Owner

I feel as though the Token should have an originString which holds the line the token belongs to and then from there all we do our side is, because Tokens have a getCoord() we can place that along said string for error messages.

I feel as though the `Token` should have an `originString` which holds the line the token belongs to and then from there all we do our side is, because `Token`s have a `getCoord()` we can place that along said string for error messages.
Author
Owner

Going to need @gusmeyer 's help for this

Going to need @gusmeyer 's help for this
Author
Owner

I feel as though the Token should have an originString which holds the line the token belongs to and then from there all we do our side is, because Tokens have a getCoord() we can place that along said string for error messages.

The idea is right though:

image

> I feel as though the `Token` should have an `originString` which holds the line the token belongs to and then from there all we do our side is, because `Token`s have a `getCoord()` we can place that along said string for error messages. The idea is right though: ![image](/attachments/c5ed917f-fed3-4574-87d6-103fbb92c7cb)
Author
Owner

Reporting mechanism is basically done

I feel as though the Token should have an originString which holds the line the token belongs to and then from there all we do our side is, because Tokens have a getCoord() we can place that along said string for error messages.

The idea is right though:

image

Reporting mechanism is basically done > > I feel as though the `Token` should have an `originString` which holds the line the token belongs to and then from there all we do our side is, because `Token`s have a `getCoord()` we can place that along said string for error messages. > > The idea is right though: > > ![image](/attachments/c5ed917f-fed3-4574-87d6-103fbb92c7cb)
gusmeyer was assigned by deavmi 2024-04-02 09:43:58 +01:00
deavmi stopped working 2024-04-02 09:44:07 +01:00
50 minutes 26 seconds
deavmi changed title from Better error reporting, messaging to Feature: Better error reporting, messaging 2024-04-02 17:33:24 +01:00
deavmi started working 2024-04-02 17:36:13 +01:00
deavmi stopped working 2024-04-02 17:38:49 +01:00
2 minutes 36 seconds
deavmi started working 2024-04-02 17:39:32 +01:00
Author
Owner

Working on making the reporting system more generic from first prinmciples and then building it out on a per-usae case scenario.

Working on making the reporting system more generic from first prinmciples and then building it out on a per-usae case scenario.
Author
Owner

Working on making the reporting system more generic from first prinmciples and then building it out on a per-usae case scenario.

Added in

> Working on making the reporting system more generic from first prinmciples and then building it out on a per-usae case scenario. Added in ✅
deavmi stopped working 2024-04-02 18:11:33 +01:00
32 minutes
deavmi added the due date 2024-04-05 2024-04-02 18:11:39 +01:00
deavmi added spent time 2024-04-02 18:13:14 +01:00
2 minutes
deavmi started working 2024-04-02 18:13:20 +01:00
Author
Owner

Finalizing some cleanup, but moet gaan stort eerstens 🚿

Finalizing some cleanup, but moet gaan stort eerstens 🚿
Author
Owner

Finalizing some cleanup, but moet gaan stort eerstens 🚿

Finalized now

> Finalizing some cleanup, but moet gaan stort eerstens 🚿 Finalized now ✅
deavmi stopped working 2024-04-02 18:32:19 +01:00
18 minutes 58 seconds
deavmi started working 2024-04-02 20:19:51 +01:00
Author
Owner

Purpose ✍️

I want to have better error reporting, which entails:

  • Showing where the error happened. Think about line information
  • Better print outs for errors

Example

If for example we have source code int i = 3; then the tokens should be as follows:

  1. int
  2. i
  3. =
  4. 3
  5. ;

And the getOrigin()'s of each of these Token(s) should be as follows:

  1. int
  2. int i
  3. int i =
  4. int i = 3
  5. int i = 3;

How

I think we should implement something in every Statement to have a LineInfo struct associated with it which is a string of associated Token(s) which can be restrung together on the fly. This means we get proper line information.

  • Coords

  • Token to have getCoords()

  • LineInfo defined

  • Statement to have methods to get and set LineInfo

  • Parser to attach LineInfo to all Statements

  • Common error reporting mechansim. Something whereby we give it the Statement and it automagically prints out the problem, we could even optionally position the cursor (this would imply knowing where which at that stage is probably not possible)

    • The Parser's expect() method should be correctly updated
    • In future we should maybe keep the origin transferred over to the Statement so errors that are not only in the Parser can be reported on

The Parser's expect() method should be correctly updated

This has been completed by updating SyntaxError to use report(string, Token)

> ## Purpose ✍️ > > I want to have better error reporting, which entails: > > - [ ] Showing _where_ the error happened. Think about line information > - [ ] Better print outs for errors > > > ### Example > > If for example we have source code `int i = 3;` then the tokens should be as follows: > > 1. `int` > 2. `i` > 3. `=` > 4. `3` > 5. `;` > > And the `getOrigin()`'s of each of these `Token`(s) should be as follows: > > 1. `int` > 2. `int i` > 3. `int i =` > 4. `int i = 3` > 5. `int i = 3;` > > ## How > > I think we should implement something in every `Statement` to have a `LineInfo` struct associated with it which is a string of associated `Token`(s) which can be restrung together on the fly. This means we get proper line information. > > - [x] `Coords` > - [x] `Token` to have `getCoords()` > - [x] `LineInfo` defined > - [x] `Statement` to have methods to get and set `LineInfo` > - [ ] ~~Parser to attach `LineInfo` to all `Statement`s~~ > > - [ ] Common error reporting mechansim. Something whereby we give it the `Statement` and it automagically prints out the problem, we could even optionally position the cursor (this would imply knowing where which at that stage is probably not possible) > - [ ] The `Parser`'s `expect()` method should be correctly updated > - [ ] In future we should maybe keep the origin transferred over to the `Statement` so errors that are not only in the `Parser` can be reported on >The Parser's expect() method should be correctly updated This has been completed by updating `SyntaxError` to use `report(string, Token)` ✅
deavmi stopped working 2024-04-02 20:33:16 +01:00
13 minutes 25 seconds
deavmi started working 2024-04-02 20:55:42 +01:00
Author
Owner

Purpose ✍️

I want to have better error reporting, which entails:

  • Showing where the error happened. Think about line information
  • Better print outs for errors

Example

If for example we have source code int i = 3; then the tokens should be as follows:

  1. int
  2. i
  3. =
  4. 3
  5. ;

And the getOrigin()'s of each of these Token(s) should be as follows:

  1. int
  2. int i
  3. int i =
  4. int i = 3
  5. int i = 3;

How

I think we should implement something in every Statement to have a LineInfo struct associated with it which is a string of associated Token(s) which can be restrung together on the fly. This means we get proper line information.

  • Coords
  • Token to have getCoords()
  • LineInfo defined
  • Statement to have methods to get and set LineInfo
  • Parser to attach LineInfo to all Statements
  • BasicLexer to do setOrigin(string) when needed @gusmeyer
  • BasicLexer to have better (x,y) saving @gusmeyer
  • Common error reporting mechansim. Something whereby we give it the Statement and it automagically prints out the problem, we could even optionally position the cursor (this would imply knowing where which at that stage is probably not possible)
    • The Parser's expect() method should be correctly updated
    • In future we should maybe keep the origin transferred over to the Statement so errors that are not only in the Parser can be reported on

Trying to think of the best way to do this because, look, it could span multiple lines then and then you're in for trouble with a relatively complicated system. Maybe we should just assume best effort?

In future we should maybe keep the origin transferred over to the Statement so errors that are not only in the Parser can be reported on

> ## Purpose ✍️ > > I want to have better error reporting, which entails: > > - [x] Showing _where_ the error happened. Think about line information > - [x] Better print outs for errors > > > ### Example > > If for example we have source code `int i = 3;` then the tokens should be as follows: > > 1. `int` > 2. `i` > 3. `=` > 4. `3` > 5. `;` > > And the `getOrigin()`'s of each of these `Token`(s) should be as follows: > > 1. `int` > 2. `int i` > 3. `int i =` > 4. `int i = 3` > 5. `int i = 3;` > > ## How > > I think we should implement something in every `Statement` to have a `LineInfo` struct associated with it which is a string of associated `Token`(s) which can be restrung together on the fly. This means we get proper line information. > > - [x] `Coords` > - [x] `Token` to have `getCoords()` > - [x] `LineInfo` defined > - [x] `Statement` to have methods to get and set `LineInfo` > - [ ] ~~Parser to attach `LineInfo` to all `Statement`s~~ > - [ ] `BasicLexer` to do `setOrigin(string)` when needed @gusmeyer > - [ ] `BasicLexer` to have better `(x,y)` saving @gusmeyer > - [ ] Common error reporting mechansim. Something whereby we give it the `Statement` and it automagically prints out the problem, we could even optionally position the cursor (this would imply knowing where which at that stage is probably not possible) > - [x] The `Parser`'s `expect()` method should be correctly updated > - [ ] In future we should maybe keep the origin transferred over to the `Statement` so errors that are not only in the `Parser` can be reported on Trying to think of the best way to do this because, look, it could span multiple lines then and then you're in for trouble with a relatively complicated system. Maybe we should just assume best effort? >In future we should maybe keep the origin transferred over to the Statement so errors that are not only in the Parser can be reported on
deavmi stopped working 2024-04-02 21:24:37 +01:00
28 minutes 55 seconds
deavmi started working 2024-04-02 21:26:10 +01:00
deavmi stopped working 2024-04-05 16:45:19 +01:00
2 days 19 hours
Author
Owner

Forgot to stop the timer 🤡

Forgot to stop the timer 🤡
deavmi modified the due date from 2024-04-05 to 2024-04-09 2024-04-05 17:09:35 +01:00
deavmi pinned this 2024-04-08 16:00:57 +01:00
deavmi started working 2024-04-14 10:01:32 +01:00
deavmi modified the due date from 2024-04-09 to 2024-04-30 2024-04-14 10:04:50 +01:00
deavmi stopped working 2024-04-14 10:12:42 +01:00
11 minutes 10 seconds
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Total Time Spent: 2 days 22 hours
deavmi
2 days 22 hours
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2024-04-30

Dependencies

No dependencies set.

Reference: tlang/tlang#169
No description provided.