Skip to content
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

stb_c_lexer: invalid char literal #1652

Open
Wonshtrum opened this issue Jun 19, 2024 · 0 comments
Open

stb_c_lexer: invalid char literal #1652

Wonshtrum opened this issue Jun 19, 2024 · 0 comments

Comments

@Wonshtrum
Copy link

The stb C lexer consumes one extra character when parsing a char literal.

This can be demonstrated with this code:

stb_lexer l = {0};
char source[] = "char lit = 'A';";
char store[1024];
stb_c_lexer_init(&l, source, source+sizeof(source)-1, store, sizeof(store));

while (stb_c_lexer_get_token(&l)) {
	printf("%d: %.*s\n", l.token, l.where_lastchar-l.where_firstchar+1, l.where_firstchar);
}

which outputs:

260: char
260: lit
61: =
263: 'A';

when we expected:

260: char
260: lit
61: =
263: 'A'
59: ;
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

No branches or pull requests

1 participant