From e13dde68b54ff815ff103ba22b2f01ebe7ef9df7 Mon Sep 17 00:00:00 2001 From: sergeych Date: Mon, 2 Jun 2025 11:38:17 +0400 Subject: [PATCH] Renamed to lyng --- README.md | 2 +- docs/List.md | 2 +- docs/OOP.md | 4 ++-- docs/Real.md | 2 +- docs/tutorial.md | 14 +++++++------- library/build.gradle.kts | 2 +- .../kotlin/net/sergeych/ling/Arguments.kt | 2 +- .../net/sergeych/ling/BuildDoubleFromParts.kt | 2 +- .../kotlin/net/sergeych/ling/Compiler.kt | 4 ++-- .../kotlin/net/sergeych/ling/CompilerContext.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/Context.kt | 7 ++++++- .../commonMain/kotlin/net/sergeych/ling/IfScope.kt | 9 --------- .../kotlin/net/sergeych/ling/ListEntry.kt | 2 +- .../sergeych/ling/LoopBreakContinueException.kt | 2 +- .../src/commonMain/kotlin/net/sergeych/ling/Obj.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/ObjBool.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/ObjChar.kt | 2 +- .../kotlin/net/sergeych/ling/ObjClass.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/ObjInt.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/ObjList.kt | 2 +- .../kotlin/net/sergeych/ling/ObjRange.kt | 2 +- .../kotlin/net/sergeych/ling/ObjRangeIterator.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/ObjReal.kt | 2 +- .../kotlin/net/sergeych/ling/ObjString.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/Parser.kt | 2 +- .../src/commonMain/kotlin/net/sergeych/ling/Pos.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/Script.kt | 2 +- .../kotlin/net/sergeych/ling/ScriptError.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/Source.kt | 2 +- .../kotlin/net/sergeych/ling/StoredObj.kt | 2 +- .../commonMain/kotlin/net/sergeych/ling/Token.kt | 2 +- .../kotlin/net/sergeych/ling/statements.kt | 2 +- library/src/commonTest/kotlin/ScriptTest.kt | 2 +- library/src/jvmTest/kotlin/BookTest.kt | 4 ++-- 34 files changed, 47 insertions(+), 51 deletions(-) delete mode 100644 library/src/commonMain/kotlin/net/sergeych/ling/IfScope.kt diff --git a/README.md b/README.md index 5237e0a..3794ae0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Ling: scripting lang for kotlin multiplatform +# Lying: scripting lang for kotlin multiplatform in the form of multiplatform library. diff --git a/docs/List.md b/docs/List.md index abf6576..de706f1 100644 --- a/docs/List.md +++ b/docs/List.md @@ -2,7 +2,7 @@ Mutable list of any objects. -It's class in Ling is `List`: +It's class in Lying is `List`: [1,2,3]::class >>> List diff --git a/docs/OOP.md b/docs/OOP.md index ae6026e..32720b4 100644 --- a/docs/OOP.md +++ b/docs/OOP.md @@ -1,4 +1,4 @@ -# OO implementation in Ling +# OO implementation in Lying Basic principles: @@ -15,7 +15,7 @@ Basic principles: ## Instances -Result of executing of any expression or statement in the Ling is the object that +Result of executing of any expression or statement in the Lying is the object that inherits `Obj`, but is not `Obj`. For example it could be Int, void, null, real, string, bool, etc. This means whatever expression returns or the variable holds, is the first-class diff --git a/docs/Real.md b/docs/Real.md index 8010701..251850f 100644 --- a/docs/Real.md +++ b/docs/Real.md @@ -3,7 +3,7 @@ Class that supports double-precision math. Woks much like double in other languages. We honor no floats, so it is ' Real'. -It's class in Ling is `Real`: +It's class in Lying is `Real`: (π/2)::class >>> Real diff --git a/docs/tutorial.md b/docs/tutorial.md index b72b37d..43b4cb1 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -1,6 +1,6 @@ -# Ling tutorial +# Lying tutorial -Ling is a very simple language, where we take only most important and popular features from +Lying is a very simple language, where we take only most important and popular features from other scripts and languages. In particular, we adopt _principle of minimal confusion_[^1]. In other word, the code usually works as expected when you see it. So, nothing unusual. @@ -8,12 +8,12 @@ __Other documents to read__ maybe after this one: - [Advanced topics](advanced_topics.md) - [OOP notes](OOP.md) -- [math in Ling](math.md) +- [math in Lying](math.md) - Some class references: [List](List.md), [Real](Real.md), [Range](Range.md) # Expressions -Everything is an expression in Ling. Even an empty block: +Everything is an expression in Lying. Even an empty block: // empty block >>> void @@ -221,7 +221,7 @@ Notice how function definition return a value, instance of `Callable`. You can use both `fn` and `fun`. Note that function declaration _is an expression returning callable_. -There are default parameters in Ling: +There are default parameters in Lying: fn check(amount, prefix = "answer: ") { prefix + if( amount > 100 ) @@ -273,7 +273,7 @@ If you need to create _unnamed_ function, use alternative syntax (TBD, like { -> # Lists (aka arrays) -Ling has built-in mutable array class `List` with simple literals: +Lying has built-in mutable array class `List` with simple literals: [1, "two", 3.33].size >>> 3 @@ -546,7 +546,7 @@ We can skip the rest of the loop and restart it, as usual, with `continue` opera >>> 0 Notice that `total` remains 0 as the end of the outerLoop@ is not reachable: `continue` is always called and always make -Ling to skip it. +Lying to skip it. ## else statement diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 6fdf536..a677b11 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -81,7 +81,7 @@ mavenPublishing { coordinates(group.toString(), "library", version.toString()) pom { - name = "Ling language" + name = "Lying language" description = "Kotlin-bound scripting loanguage" inceptionYear = "2025" // url = "https://sergeych.net" diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Arguments.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Arguments.kt index 2cc1431..dcd2989 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Arguments.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Arguments.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying data class ParsedArgument(val value: Statement, val pos: Pos, val isSplat: Boolean = false) diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/BuildDoubleFromParts.kt b/library/src/commonMain/kotlin/net/sergeych/ling/BuildDoubleFromParts.kt index edcc0cf..1db6157 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/BuildDoubleFromParts.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/BuildDoubleFromParts.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying //fun buildDoubleFromParts( // integerPart: Long, diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Compiler.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Compiler.kt index 4dbc654..b1a2d67 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Compiler.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Compiler.kt @@ -1,7 +1,7 @@ -package net.sergeych.ling +package net.sergeych.lying /** - * The LING compiler. + * The LYING compiler. */ class Compiler( @Suppress("UNUSED_PARAMETER") diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/CompilerContext.kt b/library/src/commonMain/kotlin/net/sergeych/ling/CompilerContext.kt index a6d71fb..b44f6ad 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/CompilerContext.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/CompilerContext.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying internal class CompilerContext(val tokens: List) : ListIterator by tokens.listIterator() { val labels = mutableSetOf() diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Context.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Context.kt index fe7953d..a3f3228 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Context.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Context.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class Context( val parent: Context?, @@ -16,10 +16,15 @@ class Context( @Suppress("unused") fun raiseNPE(): Nothing = raiseError(ObjNullPointerError(this)) + + @Suppress("unused") fun raiseIndexOutOfBounds(message: String = "Index out of bounds"): Nothing = raiseError(ObjIndexOutOfBoundsError(this, message)) + + @Suppress("unused") fun raiseArgumentError(message: String = "Illegal argument error"): Nothing = raiseError(ObjIllegalArgumentError(this, message)) + fun raiseClassCastError(msg: String): Nothing = raiseError(ObjClassCastError(this, msg)) fun raiseError(message: String): Nothing { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/IfScope.kt b/library/src/commonMain/kotlin/net/sergeych/ling/IfScope.kt deleted file mode 100644 index 4bbaaf2..0000000 --- a/library/src/commonMain/kotlin/net/sergeych/ling/IfScope.kt +++ /dev/null @@ -1,9 +0,0 @@ -package net.sergeych.ling - -class IfScope(val isTrue: Boolean) { - - fun otherwise(f: ()->Unit): Boolean { - if( !isTrue ) f() - return false - } -} \ No newline at end of file diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ListEntry.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ListEntry.kt index 82dbb58..3d1e35c 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ListEntry.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ListEntry.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying sealed class ListEntry { data class Element(val accessor: Accessor) : ListEntry() diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/LoopBreakContinueException.kt b/library/src/commonMain/kotlin/net/sergeych/ling/LoopBreakContinueException.kt index 39af279..560a93b 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/LoopBreakContinueException.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/LoopBreakContinueException.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class LoopBreakContinueException( val doContinue: Boolean, diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Obj.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Obj.kt index fe7cb97..42b66c8 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Obj.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Obj.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjBool.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjBool.kt index 1fac6ab..d948e2c 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjBool.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjBool.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying data class ObjBool(val value: Boolean) : Obj() { override val asStr by lazy { ObjString(value.toString()) } diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt index 733bce5..0b08a72 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class ObjChar(val value: Char): Obj() { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjClass.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjClass.kt index 61aca8c..37cbfc9 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjClass.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjClass.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying val ObjClassType by lazy { ObjClass("Class") } diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjInt.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjInt.kt index 659dbe7..a69f9b1 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjInt.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjInt.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying data class ObjInt(var value: Long) : Obj(), Numeric { override val asStr get() = ObjString(value.toString()) diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjList.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjList.kt index 1e82d62..a93bc2b 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjList.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjList.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class ObjList(val list: MutableList) : Obj() { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjRange.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjRange.kt index 2fb51d2..0a0b443 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjRange.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjRange.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class ObjRange(val start: Obj?, val end: Obj?, val isEndInclusive: Boolean) : Obj() { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjRangeIterator.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjRangeIterator.kt index 592545e..8e23ac7 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjRangeIterator.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjRangeIterator.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class ObjRangeIterator(val self: ObjRange) : Obj() { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjReal.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjReal.kt index 7e6fc73..6aafa14 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjReal.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjReal.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying import kotlin.math.floor import kotlin.math.roundToLong diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjString.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjString.kt index bc2949a..981d828 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ObjString.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjString.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Parser.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Parser.kt index 3cdf7c2..f10eaae 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Parser.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Parser.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying val digitsSet = ('0'..'9').toSet() val digits = { d: Char -> d in digitsSet } diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Pos.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Pos.kt index f826fe8..0c041b9 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Pos.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Pos.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying data class Pos(val source: Source, val line: Int, val column: Int) { override fun toString(): String { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Script.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Script.kt index 75234ed..60b7486 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Script.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Script.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying import kotlin.math.* diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ScriptError.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ScriptError.kt index d8f59e8..9860a8d 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/ScriptError.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ScriptError.kt @@ -1,6 +1,6 @@ @file:Suppress("CanBeParameter") -package net.sergeych.ling +package net.sergeych.lying open class ScriptError(val pos: Pos, val errorMessage: String,cause: Throwable?=null) : Exception( """ diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Source.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Source.kt index 0a92d04..3073970 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Source.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Source.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying class Source(val fileName: String, text: String) { diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/StoredObj.kt b/library/src/commonMain/kotlin/net/sergeych/ling/StoredObj.kt index 193828f..ea67688 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/StoredObj.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/StoredObj.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying /** * Whatever [Obj] stored somewhere diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/Token.kt b/library/src/commonMain/kotlin/net/sergeych/ling/Token.kt index 094f92a..a56c1a7 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/Token.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/Token.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying data class Token(val value: String, val pos: Pos, val type: Type) { val isComment: Boolean by lazy { type == Type.SINLGE_LINE_COMMENT || type == Type.MULTILINE_COMMENT } diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/statements.kt b/library/src/commonMain/kotlin/net/sergeych/ling/statements.kt index da4f64d..5ba2be2 100644 --- a/library/src/commonMain/kotlin/net/sergeych/ling/statements.kt +++ b/library/src/commonMain/kotlin/net/sergeych/ling/statements.kt @@ -1,4 +1,4 @@ -package net.sergeych.ling +package net.sergeych.lying fun String.toSource(name: String = "eval"): Source = Source(name, this) diff --git a/library/src/commonTest/kotlin/ScriptTest.kt b/library/src/commonTest/kotlin/ScriptTest.kt index a56b5b6..c3f47ae 100644 --- a/library/src/commonTest/kotlin/ScriptTest.kt +++ b/library/src/commonTest/kotlin/ScriptTest.kt @@ -1,7 +1,7 @@ package io.github.kotlin.fibonacci import kotlinx.coroutines.test.runTest -import net.sergeych.ling.* +import net.sergeych.lying.* import kotlin.test.* class ScriptTest { diff --git a/library/src/jvmTest/kotlin/BookTest.kt b/library/src/jvmTest/kotlin/BookTest.kt index 962bf2e..a7f261b 100644 --- a/library/src/jvmTest/kotlin/BookTest.kt +++ b/library/src/jvmTest/kotlin/BookTest.kt @@ -3,8 +3,8 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.test.runTest -import net.sergeych.ling.Context -import net.sergeych.ling.ObjVoid +import net.sergeych.lying.Context +import net.sergeych.lying.ObjVoid import java.nio.file.Files.readAllLines import java.nio.file.Paths import kotlin.test.Test