Ad
  • Custom User Avatar

    According to the tokenize function of JS,

    const regex = /\s*(->|[-+*/\(\)\[\]\{\};,]|[A-Za-z]+|[0-9]+)\s*/g;
    

    it will generate something like {_, but it should be { and _.
    The correct regex should be

    const regex = /\s*(->|[-+*/\(\)\[\]\{\};,]|[A-Za-z_]+|[0-9]+)\s*/g;
    

    the key is [A-Za-z_].

  • Custom User Avatar

    According to the BNF (which is NOT a valid Kotlin BNF),

    function ::= expression "(" [parameters] ")" [lambda]
               | expression lambda
    
    expression ::= nameOrNumber
                 | lambda
    
    lambda ::= "{" [lambdaparam "->"] [lambdastmt] "}"
    

    the program {}{}{} is valid. Just pick lambda of expression and expression lambda of function, we can construct a infinite lambda list.

    Modify the BNF, or remove this test.