As Rick mentions, you have to parse the quoted literal string: Determine the beginning and ending positions of the string, then replace any double quotes within those positions with the Swift equivalent. You may be able to accomplish this on a global basis using RegEx.
In the code I have that does properly tokenize Xojo code that would come out as a StringLiteral
And in there with that I know I can rip of the first & last quote
Then replace all the other “” with " and I’m done
I dont know if you have anything that splits the code into tokens like that which would let you take that same kind of approach
Yes,… My tokenizer returns a quoted string (with embedded " ) as a single token.
For some reason I didn’t think that simply removing the enclosing " (1st and last) and then replacing any remaining “” with " would be the answer… I thought there was all kinds of situations with triple, quadruple and other numbers of sequential quote.
That did in fact seem to work… . I did have an issue with the fact that the “text” might go thru the tokenizer more than once… so it had to handle BOTH cases multiple double quotes AND escaped double quotes…
rewriting Xojo? No…
writing another development system that has some similarities? and hopefully improvements? Yes.
I have already written a proof-of-concept IDE the generates GUI code in Swift, and a partially working one the creates macOS code.
Right now I am working on translator (which is in another thread here)… .That takes BASIC code and attempts to translate it directly to Swift… Its not perfect (yet)… but at this moment only creates about 100 errors when attempting to translate 6000 lines of BASIC.
100 errors (but only 50 are “unique”) may sound like a lot, but considering the 4 days ago it was 900 errors, I think I’m making good progress