For those of you interested… Here is the very beginning of a BASIC to Swift translator.
As of now it handles the more generic syntax.
IF/THEN/ELSE
FOR/NEXT
WHILE/WEND
SELECT/CASE
DIM/CONST
FUNCTION/SUB
handles a few functions where the syntax is different between BASIC and Swift (such as LEN)
handles non-decimal constant (&o, &b, &h)…
It also syntax highlights both the BASIC and Swift code…
Currently the BASIC code is not auto-formatted, the Swift code is.
Included in the zip file is the app (OSX only) and a test file, where I tried to use the examples in the SWIFT manual, and manually translated them back to BASIC to see how well the app retranslated them to Swift.
If this is something you might find of interest, I ask that you see if you can find things that it SHOULD be able to translate, but currently doesn’t, so I can modify appropriately. This is still a “proof of concept” level app, there is a LONG LONG ways to go…
my email address is in the package… so please communicate that way instead of using up bandwidth here
Note : this is based on a GENERIC BASIC Lexical and is not representative of any specific dialect of BASIC or any known existing commercial product.
[quote=98080:@Dave S]Yeah I know… CyberDuck is having hysterics Am trying to Upload via my ISP directly link text[/quote]
That link works, but the zip file contains nothing but 2 text files, no application or anything.
[quote=98189:@Kem Tekinay]This is an excellent learning tool, thanks!
How practical would it be to provide live updating of the translation so I can see it as I type?[/quote]
It could be done, as this is a context-less translator (ie. each line independent).
But that does create other issues… especially when what you type on the BASIC side creates multiple lines on the SWIFT side, and then the issue of removing BASIC code… trying to figure out what SWIFT code to take out and re-do.
Since this is the prototype for a much more extensive translation engine, I’m not inclined to add such fancies…
[quote=98194:@Dave S]It could be done, as this is a context-less translator (ie. each line independent).
But that does create other issues… especially when what you type on the BASIC side creates multiple lines on the SWIFT side, and then the issue of removing BASIC code… trying to figure out what SWIFT code to take out and re-do.
Since this is the prototype for a much more extensive translation engine, I’m not inclined to add such fancies… :)[/quote]
be sure to point out any faulty translations… everything this does is based on my current understanding of the Intro to Swift, and I can tell by reading that book that it glossed over ALOT, and left out even more.
FYI, using the example file in the package, the resulting code does not compile in Swift and flags numerous issues. Some are expected, like the translation of MsgBox, but others are not. For example, these three lines don’t compile:
var myarray:String=(count: 3, repeatedValue:")
var xarray:String=["A","B","C"]
var xint:Int=5