Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Storing column numbers for every token just in case there might be an error likely weighs out the string allocation reduction. But for error messages it might suffice to output just the line number together with a snippet of the line at the error location. Most people probably don't care about the exact column number, though it might be bad for other tools.


> Storing column numbers for every token just in case there might be an error likely weighs out the string allocation reduction.

Only if you store all of the tokens before starting the parsing, which would arguably be the bigger fish to fry in terms of conserving memory.

But it actually slows down the lexer: by an insignificant amount if the lexer is the traditionally written one, or by quite a lot if it's one of those new-fangled ones that use SIMD-instructions speed up finding the token boundaries... but such lexers also benefit wrom the ability to re-use unneeded parts of the source input (like quotes or spaces) for storing auxillary data.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: