Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 448 Bytes

README.md

File metadata and controls

23 lines (19 loc) · 448 Bytes

大学时候写得解释器,最近翻了出来。传上来防止以后找不到了。

val text = """
    String hello = "你好 ";
    String name = null;
    while(name == null) {
        print("请输入你的名字: ");
        name = readLine();
    }
    println(hello + name);
""".trimIndent()

val iterator = Lexer(text).parse()
Block(iterator).execute()

output:

请输入你的名字: 张三
你好 张三