Translate BASIC to Swift

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 :slight_smile:

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.

BASIC2Swift

That link doesn’t work.

Try now.

Yeah I know… CyberDuck is having hysterics :slight_smile: Am trying to Upload via my ISP directly
link text

Hang on… the zip file wasn’t even built properly :frowning:

[quote=98080:@Dave S]Yeah I know… CyberDuck is having hysterics :slight_smile: 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.

It works now… same link

I only am able to see:

func basic2swift(xyz:String) ->Int {

MacOS X 10.8.5
MacBoop Pro 15" 2011-11

When I can run swift apps in the Windows (real world) environment I’ll be impressed.

Oh & by the way HATE .net but love the fact that I can build Mac apps from my Windows environment using Xojo.

[quote=98140:@Emile Schwarz]I only am able to see:

func basic2swift(xyz:String) ->Int {

MacOS X 10.8.5
MacBoop Pro 15" 2011-11[/quote]
Try typing in your own code… or pasting the test program…

Pasting ?

I tryed drag and drop ;-:slight_smile:

Will do.

Drag/n/Drop should have worked… but then this is prelim code :slight_smile:

Am surprised as to how little interest it has garnered…

Well, you did post this in the evening. :slight_smile:

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?

I looked, but your first post said to email you rather than discuss here so I didn’t really do 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… :slight_smile:

[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.

Well, let me tell you how I’ve read your announce and how it affected my initial interest:

This is a basic BASIC → SWIFT translator.
It’s a “proof of concept”.

:slight_smile:

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

Indeed the book seems to leave out a lot. Only actual testing of the generated code can perform.

*DING !

Kem just posted an example :wink: