correct end-block token processing (detect more errors)
This commit is contained in:
parent
c398496ee0
commit
e916d9805a
@ -65,9 +65,17 @@ class Compiler(
|
||||
}
|
||||
}
|
||||
}
|
||||
parseStatement(braceMeansLambda = true)?.also {
|
||||
val s = parseStatement(braceMeansLambda = true)?.also {
|
||||
statements += it
|
||||
} ?: break
|
||||
}
|
||||
if (s == null) {
|
||||
when( t.type ) {
|
||||
Token.Type.RBRACE, Token.Type.EOF, Token.Type.SEMICOLON -> {}
|
||||
else ->
|
||||
throw ScriptError(t.pos, "unexpeced `${t.value}` here")
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
} while (true)
|
||||
return Script(start, statements)//returnScope.needCatch)
|
||||
@ -833,8 +841,18 @@ class Compiler(
|
||||
val isExtern = cc.skipId("extern")
|
||||
when {
|
||||
cc.matchQualifiers("fun", "private") -> parseFunctionDeclaration(Visibility.Private, isExtern)
|
||||
cc.matchQualifiers("fun", "private", "static") -> parseFunctionDeclaration(Visibility.Private, isExtern, isStatic = true)
|
||||
cc.matchQualifiers("fun", "static") -> parseFunctionDeclaration(Visibility.Public, isExtern, isStatic = true)
|
||||
cc.matchQualifiers("fun", "private", "static") -> parseFunctionDeclaration(
|
||||
Visibility.Private,
|
||||
isExtern,
|
||||
isStatic = true
|
||||
)
|
||||
|
||||
cc.matchQualifiers("fun", "static") -> parseFunctionDeclaration(
|
||||
Visibility.Public,
|
||||
isExtern,
|
||||
isStatic = true
|
||||
)
|
||||
|
||||
cc.matchQualifiers("fn", "private") -> parseFunctionDeclaration(Visibility.Private, isExtern)
|
||||
cc.matchQualifiers("fun", "open") -> parseFunctionDeclaration(isOpen = true, isExtern = isExtern)
|
||||
cc.matchQualifiers("fn", "open") -> parseFunctionDeclaration(isOpen = true, isExtern = isExtern)
|
||||
|
@ -43,4 +43,21 @@ class OOTest {
|
||||
assertEquals( "foo!", Point.getData() )
|
||||
""".trimIndent())
|
||||
}
|
||||
|
||||
// @Test
|
||||
fun testDynamic() = runTest {
|
||||
eval("""
|
||||
println("0")
|
||||
class DynamicTest : Dynamic {
|
||||
|
||||
fun getDynamic(name) {
|
||||
if (name == "foo") "bar" else null
|
||||
}
|
||||
}
|
||||
println("1")
|
||||
val d = DynamicTest()
|
||||
println(d)
|
||||
println("2")
|
||||
""".trimIndent())
|
||||
}
|
||||
}
|
@ -2375,8 +2375,6 @@ class ScriptTest {
|
||||
x++; y++
|
||||
}
|
||||
assertEquals(p, Point(2,3))
|
||||
>>> void
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
@ -2393,8 +2391,6 @@ class ScriptTest {
|
||||
y++
|
||||
}
|
||||
assertEquals(p, Point(2,3))
|
||||
>>> void
|
||||
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user