serenity: LibJS: Lexer reports incorrect column for tokens
When lexing a piece of JS source for the console widget, I loop over the tokens to add styling information. However, it seems that the column numbers reported by these tokens are incorrect. I have to do some special math to make them usable, namely subtracting by 2, but I’m not sure why. Even after that subtraction, the output is sometimes still wrong, such as the case of let x = 10
. Perhaps this is an issue in the console output code, but I’m not sure what it is doing wrong.
@linusg I believe you are the person to tag for LibJS 😃
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (19 by maintainers)
Ultimately there are two issues.
After playing whack-a-mole for a while I think the above patch finally fixes both problems.
I believe this is because when reading the last token it gets the wrong length,
when m_position is m_source.length() it adds 1 for some reason so the length (m_position - value_start) becomes 2 which makes line_column 0.
Not true, last line has
line_column = 0
for theCurlyClose
token, that should be1
.don’t have to, but I appreciate it 😃
I’ll have a look.