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

Get assertion improvement #512

Closed
wants to merge 2 commits into from

Conversation

littlewhitecloud
Copy link
Contributor

No description provided.

@littlewhitecloud
Copy link
Contributor Author

Now the biggest headache is figuring out where to add spaces...

@Akuli
Copy link
Owner

Akuli commented Jul 21, 2024

You could maybe read the file from first token's location to last token's location. When you read text from file, it already comes with spaces in the right places.

@Akuli
Copy link
Owner

Akuli commented Jul 21, 2024

maybe read the file from first token's location to last token's location

Now I remember why this is not possible. Jou's tokens do not contain column numbers, only line numbers. So you don't know where exactly the assert keyword ends and the assertion itself starts.

That's why the old code just reads the whole line and removes the assert word:

    if(!strncmp(str.ptr, "assert",6))
        memmove(str.ptr, &str.ptr[6], strlen(&str.ptr[6]) + 1);

So if the first 6 characters in the string are "assert", it moves the remaining characters (including the special \0 terminator) to start of the string. Not very nice.

Maybe some day Jou's tokens will contain a better location than just line number. Until then, I don't think this can be improved much.

@littlewhitecloud
Copy link
Contributor Author

OK, closing.

@littlewhitecloud littlewhitecloud deleted the rassertimprove branch January 12, 2025 03:41
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.

2 participants