Enable support for C multi-strings

This commit is contained in:
Jeremiah Orians 2020-11-15 18:58:25 -05:00
parent 57264eb157
commit 67dbbbdcfc
No known key found for this signature in database
GPG Key ID: 5410E91C14959E87
3 changed files with 42 additions and 8 deletions

View File

@ -426,8 +426,42 @@ void primary_expr_string()
strings_list = uniqueID(function->s, strings_list, number_string);
/* Parse the string */
strings_list = emit(parse_string(global_token->s), strings_list);
global_token = global_token->next;
if('"' != global_token->next->s[0])
{
strings_list = emit(parse_string(global_token->s), strings_list);
global_token = global_token->next;
}
else
{
char* s = calloc(MAX_STRING, sizeof(char));
/* prefix leading string */
s[0] = '"';
int i = 1;
int j;
while('"' == global_token->s[0])
{
/* Step past the leading '"' */
j = 1;
/* Copy the rest of the string as is */
while(0 != global_token->s[j])
{
require(i < MAX_STRING, "concat string exceeded max string length\n");
s[i] = global_token->s[j];
i = i + 1;
j = j + 1;
}
/* Move on to the next token */
global_token = global_token->next;
require(NULL != global_token, "multi-string null is not valid C\n");
}
/* Now use it */
strings_list = emit(parse_string(s), strings_list);
}
}
void primary_expr_char()

View File

@ -169,8 +169,8 @@ a2a83f42119e646b389b98647cf6cf2aa9597185997c9453db746178c8c4c0bf test/results/t
6c10f796fdb986a3a52a4ed8ad1a4eb4c1023c5dd99101a2aeadd9bad4d064ef test/results/test0106-knight-native-binary
6852a8f33ec49d43bcfb3ffff1e04900ad146806aeb67ed1749d15baed50bcb5 test/results/test0106-knight-posix-binary
3e026925ec537c817f815b4748e19e4edc0487643b66d8df00a831c73229059e test/results/test0106-x86-binary
faccfa595a90874aaf7a28f3000f6869bcc85ace8a5622f3e6d853814e76687c test/results/test1000-aarch64-binary
258068d01c1cd86d8edf7a30d62be32c463f35aed8db79e48230a82df706846a test/results/test1000-amd64-binary
a541e31ba118cdc8dc8e21b0209a2452e8bab2031cc0296b3e11eaee0201a1a5 test/results/test1000-armv7l-binary
eee2d17b91000fdbb7d978c449044c7943d660ddeded3cbc0b85fa317d43ae72 test/results/test1000-knight-posix-binary
cde5373a30c8cc2be97f82a186ddc2f01ab65b47943d7b2068d540199988c62d test/results/test1000-x86-binary
b8c05b3c57e2c469c9d5db3c225f66dfde3d00e10be95c6cd582865e878f707b test/results/test1000-aarch64-binary
dab703f295f2074bbf10927fa6e5811cdbe4a5801f5c99d84167f31180c63609 test/results/test1000-amd64-binary
c4e6ce14fd9171504c7ff2490da8147f51e62359f73f0ef6e63b67dca1bf793d test/results/test1000-armv7l-binary
2ca38a7da9c4f707ea2940a08cf5314401e0a5b96d7a467ed49c04890dd54622 test/results/test1000-knight-posix-binary
4f3ee7a46a31edfc502c436c561c0a281d9c5b6ef2c578215d0e3777f88e0045 test/results/test1000-x86-binary

View File

@ -1 +1 @@
793a85cf64a6895751cd45388c4899f3f3c83fb0f06af7e455d034771ddcb5da test/test1000/proof
5a26f6d1d3fd9da464ba7e2f5ab2c51f97fabc0366c5c7cba5af238753343264 test/test1000/proof