-
Notifications
You must be signed in to change notification settings - Fork 111
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
Codegen Lua 5.1 friendly string literals #762
Conversation
Teal Playground URL: https://762--teal-playground-preview.netlify.app |
Ha, funnily enough that 5.1 test failure is what this is trying to solve. |
Nice!
I've added a check here: https://github.com/teal-language/tl/tree/euclidianAce-string-codegen-check
I've also tried my hand implementing your suggestion, based on your code: https://github.com/teal-language/tl/tree/euclidianAce-string-codegen-escapes I did some light benchmarking with What do think about these variations? |
If there isn't a blatant performance degradation then this is probably fine to merge (barring any |
Co-authored-by: Hisham Muhammad <[email protected]>
bba9aad
to
3b96892
Compare
Merged! |
This gets the job done, but is arguably inelegant.
gsub
ing a large string literal a few times will probably have some performance implications and feels hackish. And they get run for every string literal whether it has escapes or not. I think a better solution might be to handle escapes at lex time and stash a list of byte offsets in theToken
for easier translation at codegen time. So consider this a functional first draft/mvp.