published to our maven
This commit is contained in:
		
							parent
							
								
									185aa4e0cf
								
							
						
					
					
						commit
						8c6a1979ed
					
				
							
								
								
									
										37
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								README.md
									
									
									
									
									
								
							@ -9,6 +9,10 @@ class Point(x,y) {
 | 
			
		||||
   fun dist() { sqrt(x*x + y*y) } 
 | 
			
		||||
}
 | 
			
		||||
Point(3,4).dist() //< 5
 | 
			
		||||
 | 
			
		||||
fun swapEnds(first, args..., last, f) {
 | 
			
		||||
    f( last, ...args, first)
 | 
			
		||||
} 
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
- extremely simple Kotlin integration on any platform
 | 
			
		||||
@ -31,16 +35,37 @@ and it is multithreaded on platforms supporting it (automatically, no code chang
 | 
			
		||||
 | 
			
		||||
## Integration in Kotlin multiplatform
 | 
			
		||||
 | 
			
		||||
### Add library
 | 
			
		||||
### Add dependency to your project
 | 
			
		||||
 | 
			
		||||
TBD
 | 
			
		||||
```kotlin
 | 
			
		||||
// update to current please:
 | 
			
		||||
val lyngVersion = "0.6.1-SNAPSHOT"
 | 
			
		||||
 | 
			
		||||
repositories {
 | 
			
		||||
    // ...
 | 
			
		||||
    maven("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
And add dependency to the proper place in your project, it could look like:
 | 
			
		||||
 | 
			
		||||
```kotlin
 | 
			
		||||
comminMain by getting {
 | 
			
		||||
    dependencies {
 | 
			
		||||
        // ...
 | 
			
		||||
        implementation("net.sergeych:lynglib:$lyngVersion")
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Now you can import lyng and use it:
 | 
			
		||||
 | 
			
		||||
### Execute script:
 | 
			
		||||
 | 
			
		||||
```kotlin
 | 
			
		||||
assertEquals("hello, world", eval(""" 
 | 
			
		||||
    "hello, " + "world" 
 | 
			
		||||
    """).toString())
 | 
			
		||||
import net.sergeyh.lyng.*
 | 
			
		||||
 | 
			
		||||
println(eval(""" "hello, " + "Lyng" """))
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Exchanging information
 | 
			
		||||
@ -49,6 +74,8 @@ Script is executed over some `Context`. Create instance of the context,
 | 
			
		||||
add your specific vars and functions to it, an call over it:
 | 
			
		||||
 | 
			
		||||
```kotlin
 | 
			
		||||
import new.sergeych.lyng.* 
 | 
			
		||||
 | 
			
		||||
// simple function
 | 
			
		||||
val context = Context().apply {
 | 
			
		||||
    addFn("addArgs") {
 | 
			
		||||
 | 
			
		||||
@ -1,13 +0,0 @@
 | 
			
		||||
package net.sergeych.lyng
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Symbols(
 | 
			
		||||
    unitType: UnitType,
 | 
			
		||||
    val name: String,
 | 
			
		||||
    val x: TypeDecl
 | 
			
		||||
) {
 | 
			
		||||
    enum class UnitType {
 | 
			
		||||
        Module, Function, Lambda
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -1,21 +0,0 @@
 | 
			
		||||
package net.sergeych.lyng
 | 
			
		||||
 | 
			
		||||
sealed class TypeDecl {
 | 
			
		||||
    // ??
 | 
			
		||||
    data class Fn(val argTypes: List<ArgsDeclaration.Item>, val retType: TypeDecl) : TypeDecl()
 | 
			
		||||
    object Obj : TypeDecl()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
To use in the compiler, we need symbol information when:
 | 
			
		||||
 | 
			
		||||
- declaring a class: the only way to export its public/protected symbols is to know it in compiler time
 | 
			
		||||
- importing a module: actually,  we cam try to do it in a more efficient way.
 | 
			
		||||
 | 
			
		||||
Importing module:
 | 
			
		||||
 | 
			
		||||
The moudule is efficiently a statement, that initializes it with all its symbols modifying some context.
 | 
			
		||||
 | 
			
		||||
The thing is, we need only
 | 
			
		||||
 | 
			
		||||
 */
 | 
			
		||||
@ -29,7 +29,7 @@ kotlin {
 | 
			
		||||
    sourceSets {
 | 
			
		||||
        val commonMain by getting {
 | 
			
		||||
            dependencies {
 | 
			
		||||
                implementation(project(":library"))
 | 
			
		||||
                implementation(project(":lynglib"))
 | 
			
		||||
                implementation(libs.okio)
 | 
			
		||||
 | 
			
		||||
                implementation(libs.clikt)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
 | 
			
		||||
import com.vanniktech.maven.publish.SonatypeHost
 | 
			
		||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
 | 
			
		||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
 | 
			
		||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
 | 
			
		||||
@ -20,9 +19,10 @@ buildscript {
 | 
			
		||||
plugins {
 | 
			
		||||
    alias(libs.plugins.kotlinMultiplatform)
 | 
			
		||||
    alias(libs.plugins.androidLibrary)
 | 
			
		||||
    alias(libs.plugins.vanniktech.mavenPublish)
 | 
			
		||||
//    alias(libs.plugins.vanniktech.mavenPublish)
 | 
			
		||||
    kotlin("plugin.serialization") version "2.1.20"
 | 
			
		||||
    id("com.codingfeline.buildkonfig") version "0.17.1"
 | 
			
		||||
    `maven-publish`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
buildkonfig {
 | 
			
		||||
@ -62,7 +62,7 @@ kotlin {
 | 
			
		||||
    sourceSets {
 | 
			
		||||
        all {
 | 
			
		||||
            languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
 | 
			
		||||
            languageSettings.optIn("kotlin.contracts.ExperimentalContracts::class")
 | 
			
		||||
            languageSettings.optIn("kotlin.contracts.ExperimentalContracts")
 | 
			
		||||
            languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
 | 
			
		||||
            languageSettings.optIn("kotlin.coroutines.DelicateCoroutinesApi")
 | 
			
		||||
        }
 | 
			
		||||
@ -101,73 +101,54 @@ dependencies {
 | 
			
		||||
    implementation(libs.firebase.crashlytics.buildtools)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mavenPublishing {
 | 
			
		||||
    publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
 | 
			
		||||
 | 
			
		||||
    signAllPublications()
 | 
			
		||||
 | 
			
		||||
    coordinates(group.toString(), "library", version.toString())
 | 
			
		||||
 | 
			
		||||
    pom {
 | 
			
		||||
        name = "Lyng language"
 | 
			
		||||
        description = "Kotlin-bound scripting loanguage"
 | 
			
		||||
        inceptionYear = "2025"
 | 
			
		||||
//        url = "https://sergeych.net"
 | 
			
		||||
        licenses {
 | 
			
		||||
            license {
 | 
			
		||||
                name = "XXX"
 | 
			
		||||
                url = "YYY"
 | 
			
		||||
                distribution = "ZZZ"
 | 
			
		||||
publishing {
 | 
			
		||||
    val mavenToken by lazy {
 | 
			
		||||
        File("${System.getProperty("user.home")}/.gitea_token").readText()
 | 
			
		||||
    }
 | 
			
		||||
    repositories {
 | 
			
		||||
        maven {
 | 
			
		||||
            credentials(HttpHeaderCredentials::class) {
 | 
			
		||||
                name = "Authorization"
 | 
			
		||||
                value = mavenToken
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        developers {
 | 
			
		||||
            developer {
 | 
			
		||||
                id = "XXX"
 | 
			
		||||
                name = "YYY"
 | 
			
		||||
                url = "ZZZ"
 | 
			
		||||
            url = uri("https://gitea.sergeych.net/api/packages/SergeychWorks/maven")
 | 
			
		||||
            authentication {
 | 
			
		||||
                create("Authorization", HttpHeaderAuthentication::class)
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        scm {
 | 
			
		||||
            url = "XXX"
 | 
			
		||||
            connection = "YYY"
 | 
			
		||||
            developerConnection = "ZZZ"
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//mavenPublishing {
 | 
			
		||||
//    publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
 | 
			
		||||
//
 | 
			
		||||
//val projectVersion  by project.extra(provider {
 | 
			
		||||
//    // Compute value lazily
 | 
			
		||||
//    (version as String)
 | 
			
		||||
//})
 | 
			
		||||
//    signAllPublications()
 | 
			
		||||
//
 | 
			
		||||
//val generateBuildConfig by tasks.registering {
 | 
			
		||||
//    // Declare outputs safely
 | 
			
		||||
//    val outputDir = layout.buildDirectory.dir("generated/buildConfig/commonMain/kotlin")
 | 
			
		||||
//    outputs.dir(outputDir)
 | 
			
		||||
//    coordinates(group.toString(), "library", version.toString())
 | 
			
		||||
//
 | 
			
		||||
//    val version = projectVersion.get()
 | 
			
		||||
//
 | 
			
		||||
//    // Inputs: Version is tracked as an input
 | 
			
		||||
//    inputs.property("version", version)
 | 
			
		||||
//
 | 
			
		||||
//    doLast {
 | 
			
		||||
//        val packageName = "net.sergeych.lyng.buildconfig"
 | 
			
		||||
//        val packagePath = packageName.replace('.', '/')
 | 
			
		||||
//        val buildConfigFile = outputDir.get().file("$packagePath/BuildConfig.kt").asFile
 | 
			
		||||
//
 | 
			
		||||
//        buildConfigFile.parentFile?.mkdirs()
 | 
			
		||||
//        buildConfigFile.writeText(
 | 
			
		||||
//            """
 | 
			
		||||
//            |package $packageName
 | 
			
		||||
//            |
 | 
			
		||||
//            |object BuildConfig {
 | 
			
		||||
//            |    const val VERSION = "$version"
 | 
			
		||||
//            |}
 | 
			
		||||
//            """.trimMargin()
 | 
			
		||||
//        )
 | 
			
		||||
//    pom {
 | 
			
		||||
//        name = "Lyng language"
 | 
			
		||||
//        description = "Kotlin-bound scripting loanguage"
 | 
			
		||||
//        inceptionYear = "2025"
 | 
			
		||||
////        url = "https://sergeych.net"
 | 
			
		||||
//        licenses {
 | 
			
		||||
//            license {
 | 
			
		||||
//                name = "XXX"
 | 
			
		||||
//                url = "YYY"
 | 
			
		||||
//                distribution = "ZZZ"
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//        developers {
 | 
			
		||||
//            developer {
 | 
			
		||||
//                id = "XXX"
 | 
			
		||||
//                name = "YYY"
 | 
			
		||||
//                url = "ZZZ"
 | 
			
		||||
//            }
 | 
			
		||||
//        }
 | 
			
		||||
//        scm {
 | 
			
		||||
//            url = "XXX"
 | 
			
		||||
//            connection = "YYY"
 | 
			
		||||
//            developerConnection = "ZZZ"
 | 
			
		||||
//        }
 | 
			
		||||
//    }
 | 
			
		||||
//}
 | 
			
		||||
//
 | 
			
		||||
//tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
 | 
			
		||||
//    dependsOn(generateBuildConfig)
 | 
			
		||||
//}
 | 
			
		||||
@ -96,6 +96,7 @@ internal class CompilerContext(val tokens: List<Token>) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Suppress("NOTHING_TO_INLINE")
 | 
			
		||||
    inline fun addBreak() {
 | 
			
		||||
        breakFound = true
 | 
			
		||||
    }
 | 
			
		||||
@ -5,6 +5,7 @@ data class Pos(val source: Source, val line: Int, val column: Int) {
 | 
			
		||||
        return "${source.fileName}:${line+1}:${column}"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Suppress("unused")
 | 
			
		||||
    fun back(): Pos =
 | 
			
		||||
        if( column > 0) Pos(source, line, column-1)
 | 
			
		||||
        else if( line > 0) Pos(source, line-1, source.lines[line-1].length - 1)
 | 
			
		||||
@ -0,0 +1,9 @@
 | 
			
		||||
package net.sergeych.lyng
 | 
			
		||||
 | 
			
		||||
// this is highly experimental and subject to complete redesign
 | 
			
		||||
// very soon
 | 
			
		||||
sealed class TypeDecl {
 | 
			
		||||
    // ??
 | 
			
		||||
//    data class Fn(val argTypes: List<ArgsDeclaration.Item>, val retType: TypeDecl) : TypeDecl()
 | 
			
		||||
    object Obj : TypeDecl()
 | 
			
		||||
}
 | 
			
		||||
@ -18,5 +18,5 @@ dependencyResolutionManagement {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
rootProject.name = "lyng"
 | 
			
		||||
include(":library")
 | 
			
		||||
include(":lynglib")
 | 
			
		||||
include(":lyng")
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user