3 kyu

Type Transpiler

54 of 206ice1000
Description
Loading description...
Algorithms
Strings
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    I had this test case: A < out > -> is this correct? According to the specification, I would doubt it. It seems to be a keyword, one that requires type behind it

    typeParam      ::= "*"
                     | "in " type
                     | "out " type
                     | type
    
  • dfhwze Avatar

    For both Kotlin and Java, since userType can be just a name, having just functionType and userType should suffice in the definition of type

    type           ::= functionType
                     | name
                     | userType
    
  • dfhwze Avatar

    In java section: params should be typeParams

    typeParams     ::= typeParam [ "," typeParams ]
    simpleUserType ::= name [ "<" params ">" ]
    
  • FArekkusu Avatar

    Python 3.8 should be enabled.

  • Voile Avatar

    Random tests are pathetically weak: https://www.codewars.com/kata/reviews/5aa936340a1ff7a89d002a14/groups/5eaeb8697e8d1e00015315b6

    Please write proper random tests with actual randomly-generated types of all forms ;-)

  • FArekkusu Avatar

    There're &lt; escape sequences in the EBNF.

  • Glyxerine Avatar

    Thanks for Ruby translator :)

  • Blind4Basics Avatar
  • Blind4Basics Avatar

    Hi,

    Seems to me there are some troubles in your BNF diagrams, aren't there?

    Kotlin

    name           ::= <valid java identifier>
    typeParam      ::= name                    <<<< "name" shouldn't be there since it's already in "type"?
                     | "*"
                     | "in " name
                     | "out " name
                     | type
    typeParams     ::= typeParam [ "," typeParams ]
    simpleUserType ::= name [ "<" typeParams ">" ]
    userType       ::= simpleUserType [ "." userType ]
    parameters     ::= type [ "," parameters ]
    functionType   ::= "(" [ parameters ] ")" "->" type
    type           ::= functionType
                     | name
                     | userType
    

    Java

    name           ::= <valid java identifier>
    typeParam      ::= name                                <<<< this time, "name" is there, but "type" isn't. => replace with "type"?
                     | "?"
                     | "? super " name
                     | "? extends " name
    typeParams     ::= typeParam [ "," typeParams ]
    simpleUserType ::= name [ "<" params ">" ]             <<<< should be "typeParams", right?
    userType       ::= simpleUserType [ "." userType ]
    parameters     ::= type [ "," parameters ]
    functionType   ::= "Function" ++ (number of parameters) "<" [ parameters "," ] type ">"
    type           ::= functionType
                     | name
                     | userT
    

    Subsquent questions:

    • could the name following in/out actually be type too?
    • wouldn't that be simpler (for the user) to merge userType and simpleUserType?

    Kotlin:

    userType ::= name [ "<" typeParams ">" ] [ "." userType ]
    

    Java:

    userType ::= name [ "<" typeParams ">" ] [ "." userType ]
    

    Cheers!

  • nomennescio Avatar

    "Hugh" is a given name, and is weird to report back to the user. If an exclamation is intended, this should be considered a typo, and "Huh?" should be returned.

  • nomennescio Avatar

    Haskell error: TypeTranspiler.hs:2:14: Unsupported extension: ApplicativeDo

  • ZED.CWT Avatar
  • ZebraLAN Avatar

    I guess the Kotlin bnf should actually be the following?

    name           ::= 
    typeParam      ::= name
                     | "*"
                     | "in " name
                     | "out " name
                     | simpleUserType
    typeParams     ::= typeParam [ "," typeParams ]
    simpleUserType ::= name [ "<" typeParams ">" ]
    userType       ::= simpleUserType [ "." userType ]
    parameters     ::= type [ "," parameters ]
    functionType   ::= "(" parameters ")" "->" type
    type           ::= functionType
                     | name
                     | userType
    

    If it is so, then the Java one will have to be modified as well.