mirror of https://github.com/tbklang/tlang.git
⚡ Feature: Better error reporting, messaging #169
Labels
No Label
dependency
emit
hashmapper
lebanonmapper
lexer
meta
needsfix
parser
qol
question
resolution
typing
No Milestone
No project
1 Participants
Notifications
Total Time Spent: 2 days 22 hours
Due Date
deavmi
2 days 22 hours
Dependencies
No dependencies set.
Reference: tlang/tlang#169
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose ✍️
I want to have better error reporting, which entails:
Example
If for example we have source code
int i = 3;
then the tokens should be as follows:int
i
=
3
;
And the
getOrigin()
's of each of theseToken
(s) should be as follows:int
int i
int i =
int i = 3
int i = 3;
How
I think we should implement something in every
Statement
to have aLineInfo
struct associated with it which is a string of associatedToken
(s) which can be restrung together on the fly. This means we get proper line information.Coords
Token
to havegetCoords()
LineInfo
definedStatement
to have methods to get and setLineInfo
Parser to attachLineInfo
to allStatement
sBasicLexer
to dosetOrigin(string)
when needed @gusmeyerBasicLexer
to have better(x,y)
saving @gusmeyerStatement
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)Parser
'sexpect()
method should be correctly updatedStatement
so errors that are not only in theParser
can be reported onStatement
inparsing/core.d
Most of the requirements are done ✅
We are calling
track(Token)
on each and then saving afterwards:Then this gives us this:
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 thewhile(<expression>)
also have its own line info. Therefore we can maintain this maybe usingenter()
andleave()
semantics.openTracking()
should push to a stack a newLineInfo
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.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 feel as though the
Token
should have anoriginString
which holds the line the token belongs to and then from there all we do our side is, becauseToken
s have agetCoord()
we can place that along said string for error messages.Going to need @gusmeyer 's help for this
The idea is right though:
Reporting mechanism is basically done
Better error reporting, messagingto ⚡ Feature: Better error reporting, messagingWorking on making the reporting system more generic from first prinmciples and then building it out on a per-usae case scenario.
Added in ✅
Finalizing some cleanup, but moet gaan stort eerstens 🚿
Finalized now ✅
This has been completed by updating
SyntaxError
to usereport(string, Token)
✅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?
Forgot to stop the timer 🤡