-
Notifications
You must be signed in to change notification settings - Fork 51
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
Fix multiple issues with multi-strings #142
base: master
Are you sure you want to change the base?
Conversation
34fbf28
to
e9e803c
Compare
The convention in the git commit message is to use 'subject: msg'. Possible followed by an empty line and more text. |
|
OK, I will be more careful about this.
OK, I will conform to current usage.
For the tokenizer to handle string concatenation is not semantically correct and would require recursion to skip comments and handle preprocessing correctly. Regarding memory leaks, the operation allocates and frees the temporary block, which may cause a leak if Using a Limiting the length of combined multi-strings and using a VLA or a local array is even simpler. A more correct approach would be to create string concatenation nodes in the ast and delay the handling until the analysis phase or the generation phase. This would allow for multi-strings composed of different string types as is possible in C. I don't see a need for
OK, will do. I should probably make a separate PR for the escape sequence fixes. |
adfd6b1
to
0f9fafa
Compare
If you have an expression like "one" "two" "three", what the code does is to StringPool:
So this is not very good. There will be duplicate strings anyway with this solution, but then let's |
That's a good point, I updated the code to avoid creating the intermediary strings in the string pool. |
lexer: * simplify lexer: do not check for multi-strings * remove `Tokenizer.lex_string_literal_multi`, `Tokenizer.is_multi_string`, `Tokenizer.skip_to_next_string` parser: * concatenate multi-strings in `Parser.parseStringLiteral` * this allows multi-strings to be partially commented or preprocessed * fix incorrect parsing of `"\1" "23"` to produce 3 characters instead of 1 tests: * add tests in test/parser/multi_string.c2 for various issues
lexer:
Tokenizer.lex_string_literal_multi
,Tokenizer.is_multi_string
,Tokenizer.skip_to_next_string
parser:
Parser.parseStringLiteral
"\1" "23"
to produce 3 characters instead of 1tests: