Ancestors

Written by Chorist on 2024-09-16 at 17:27

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

Written by Csepp 🌢 on 2024-09-17 at 10:11

@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

Written by Chorist on 2024-09-17 at 13:58

@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

Written by Csepp 🌢 on 2024-09-17 at 14:05

@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

Toot

Written by Chorist on 2024-09-17 at 14:09

@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

Descendants

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113153289640215389
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
321.72666 milliseconds
Gemini-to-HTML Time
0.537857 milliseconds

This content has been proxied by September (3851b).