Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow Semicolons in Swift Code #45

Closed
petermichaux opened this issue Nov 21, 2017 · 11 comments
Closed

Allow Semicolons in Swift Code #45

petermichaux opened this issue Nov 21, 2017 · 11 comments

Comments

@petermichaux
Copy link
Contributor

I'm brand new to Kotlin. I'm actually hoping to learn quite a lot about Kotlin by looking at translations created by SwiftKotlin. I put the following very basic swift class definition into SwiftKotlin 0.1.0 and nothing happened. No output. No error messages. It seems like this swift code cannot be translated.

class Person {

    private let name: String;

    init(name: String) {
        self.name = name;
    }

    func getName() -> String {
        return self.name;
    }

}

What to do?

@petermichaux
Copy link
Contributor Author

Whoa! The semicolons in Swift are the problem?!

Can SwiftKotlin be modified to understand semicolons in Swift code?

@angelolloqui
Copy link
Owner

Semicolons are indeed the problem. I am working on a version that will indicate the issue when parsing wrong swift.

By the way, SwiftKotlin is not always producing correct kotlin, it is still not complete, so if you use it as a learning tool have that in mind.

@petermichaux
Copy link
Contributor Author

petermichaux commented Nov 21, 2017

That will be a great help if the SwiftKotlin app indicates to the user any issues it encounters when parsing Swift.

Why are semicolons a problem? They are legal swift code. I have tens of thousands of lines of Swift with semicolons. Surely some other people who want to use SwiftKotlin will have some semicolons also. Must we remove all the semicolons? I hope not!

@angelolloqui
Copy link
Owner

SwiftKotlin uses a third party library for parsing and AST processing of the Swift files. That tool is not accepting it. I am not sure of the reason but semicolons are never used in Swift (albeit legal as you pointed out)

I will handle this with the author.

@petermichaux petermichaux changed the title Translating a simple class fails Allow Semicolons in Swift Code Nov 21, 2017
@petermichaux
Copy link
Contributor Author

I changed the title of this issue to reflect the actual problem.

I hope that the Swift parsing library author is open to the idea of allowing semicolons. I will keep my fingers crossed.

Is there a Github issue you can link where you are asking the Swift parsing library author so I can follow along?

Thanks.

@petermichaux
Copy link
Contributor Author

I see this issue...

yanagiba/swift-ast#61

@petermichaux
Copy link
Contributor Author

It seems that only one of the semicolons in my example is causing trouble.

The following can be translated by SwiftKotlin app.

class Person {

    private let name: String

    init(name: String) {
        self.name = name;
    }

    func getName() -> String {
        return self.name;
    }

}

@ryuichis
Copy link

I hope the latest upstream changes on swift-ast will have this fixed. @petermichaux @angelolloqui if you can verify, please let me know if it works.

@angelolloqui
Copy link
Owner

Hi @ryuichis ! thanks for the quick support. I have tried the latest version and I can confirm that the code posted above works OK with the new version.

Thanks!

@angelolloqui
Copy link
Owner

I have just added a small feedback label with a description of the compilation issue in the Mac app (fb8798b)

@angelolloqui
Copy link
Owner

#49

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants