Skip to content

Replace stb_c_lexer.h with a custom Lexer written from scratch in Crust #70

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

Merged
merged 13 commits into from
Jun 2, 2025

Conversation

rexim
Copy link
Member

@rexim rexim commented Jun 1, 2025

@yui-915 @deniska @mikmart @nullnominal let me know if you see any problems

Closes #64

@deniska
Copy link
Contributor

deniska commented Jun 1, 2025

Tried it, seems to work fine.

How "historically accurate" are we aiming for a language to be? Hex literals are nice to have for example, even if the original didn't have them.

@rexim
Copy link
Member Author

rexim commented Jun 1, 2025

How "historically accurate" are we aiming for a language to be? Hex literals are nice to have for example, even if the original didn't have them.

I actually don't know yet... My plan was to implement full set of described B features, but with the C lexer (since stb_c_lexer.h was a C lexer) and then go over the entire codebase and make it historically accurate as much as possible given the targets and the code we already have. Something like that.

@nullnominal
Copy link
Contributor

nullnominal commented Jun 1, 2025

build/b -run -o build/tests/inc_dec tests/inc_dec.b ./std/test.b
Generated build/tests/inc_dec.asm
flat assembler version 1.73.32 (16384 kilobytes memory, x64)
3 passes, 1624 bytes.
x: 3
++x: 4
x++: 4
x: 5
x--: 5
--x: 3

seems off

@nullnominal
Copy link
Contributor

that might be in the previous thing but we're paying more attention to the tests for this

@rexim
Copy link
Member Author

rexim commented Jun 1, 2025

build/b -run -o build/tests/inc_dec tests/inc_dec.b ./std/test.b Generated build/tests/inc_dec.asm flat assembler version 1.73.32 (16384 kilobytes memory, x64) 3 passes, 1624 bytes. x: 3 ++x: 4 x++: 4 x: 5 x--: 5 --x: 3

seems off

Hm... Don't see any problems. That's literally how Post/Pre-increments work.

@nullnominal
Copy link
Contributor

nullnominal commented Jun 1, 2025

Hm... Don't see any problems. That's literally how Post/Pre-increments work.

looked off to us because x is set to 3 then incremented twice

@nullnominal
Copy link
Contributor

im prolly just being dumb tho

@nullnominal nullnominal mentioned this pull request Jun 1, 2025
@nullnominal
Copy link
Contributor

(blocking #69)

@rexim
Copy link
Member Author

rexim commented Jun 2, 2025

Alright, I see no objections. Merging.

@rexim rexim merged commit 4ecedac into main Jun 2, 2025
@rexim rexim deleted the 64-lexer branch June 2, 2025 08:47
@mikmart
Copy link
Contributor

mikmart commented Jun 2, 2025

@rexim looks great! Storing the input path and the Token enum make it a lot more ergonomic. I have some tweaks I noticed which I'll submit a PR for.

This was referenced Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

B lexer from scratch in Crust
5 participants