This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val i = 1 | |
println(i) // 1 | |
i = i + 1 // コンパイルエラー | |
var j = 1 | |
println(j) // 1 | |
j = j + 1 // OK | |
println(j) // 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+"<language> programming" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.kmizu.scala_kotlin_java | |
open class KotlinClass(open val name: String) | |
fun main(args: Array<String>) { | |
println(KotlinClass("Kotlin").name) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parser<A> p = ...; | |
String input = ...; | |
Optional<A> values = ...; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package parser; | |
public class Main { | |
public static void main(String[] args) { | |
Parser<List<String>> hellos = Parser.string("Hello").many(); | |
System.out.println(hellos.invoke("Hello, World!")); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parser<A> p = ...; | |
String input = ...; | |
List<A> values = new ArrayList<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parser<A> pa = ...; | |
Parser<B> pb = ...; | |
String input; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package parser; | |
public interface Parser<T> { | |
ParseResult<T> invoke(String input); | |
static Parser<String> string(String literal) { | |
return new StringParser(literal); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.github.kmizu.scomb.SCombinator | |
object IntegerParser extends SCombinator[Int] { | |
override def root: P[Int] = (digit.+).map{ case digits => digits.mkString.toInt } | |
lazy val digit: P[String] = set('0'to'9') | |
def main(args: Array[String]): Unit = { | |
assert(parse("100") == Success(100)) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Expression: | |
def __add__(self, that): | |
return BinaryOp('+', self, that) | |
def __sub__(self, that): | |
return BinaryOp('-', self, that) | |
def __mul__(self, that): | |
return BinaryOp('*', self, that) | |