Here’s a thing I feel conflicted about. I’m going to be migrating ~ several hundred thousands of lines of code in coming months (years??) from Swift to JavaScript. The code represents years of my previous work creating synthesizer patch editors. I’ve done a small portion of it already, and in the process, I’ve created scripts that use lots of regular expressions to help automate a lot of the grunt work, to varying degrees of success. But… (1/4)
=> More informations about this toot | More toots from chorist@merveilles.town
@chorist Have you tried transforming an AST dump instead of working on the textual representation? Swift's compiler should have such a feature, if not, find a Swift grammar for Tree-Sitter and have it dump an AST.
=> More informations about this toot | More toots from csepp@merveilles.town
@csepp I haven’t. I’ve thought about something like that but didn’t have the vocabulary to really formulate the thought well!
The “translation” I’m doing is a combination of syntax (obviously, Swift to Javascript) but also structural changes (e.g. what was in Swift a custom type is now in Javascript an array or vanilla object with a specific structure).
Does an AST approach seem to fit within that?
=> More informations about this toot | More toots from chorist@merveilles.town
@chorist Yup. Source code has a tree structure, so a tree representation is the minimum that you need. For variable renaming and such you might need something more.
=> More informations about this toot | More toots from csepp@merveilles.town
@csepp Thanks, I’ll look into that. I would certainly prefer an approach without the fuzziness and mistakes of an LLM, or the fuzziness and mistakes of my 68 regular expressions as well!
=> More informations about this toot | More toots from chorist@merveilles.town This content has been proxied by September (3851b).Proxy Information
text/gemini