Skip to content

Commit

Permalink
✨ Proper parser
Browse files Browse the repository at this point in the history
 - Implemented parser with ANTLR4
 - Added docs
  • Loading branch information
TOTHT0MI committed Dec 29, 2023
1 parent bd5c67c commit 59e85a2
Show file tree
Hide file tree
Showing 494 changed files with 50,988 additions and 1,910 deletions.
8 changes: 8 additions & 0 deletions .idea/artifacts/klarity_js_2_1_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/klarity_jvm_2_1_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ val translation = Klarity.translate("path.to.translation", "Default value")
// Or with parameters
Klarity.translate("path.to.translation2", "Value is: {param}", mapOf(Pair("param", "something")))
```
Please note, that parameters can only be lowercase, but can include numbers!

However Klarity provides much more configuration to fine tune it to your use case!

Expand All @@ -85,8 +86,8 @@ Klarity.configure {
withScriptingEnabled(false) // (default: true)
withGlobals {
globalParameters {
"appName" to "MyApp"
"appVersion" to "1.0.0"
"appname" to "MyApp"
"appversion" to "1.0.0"
}

// Note that prefix and suffix are not parsed for the script!
Expand Down
63 changes: 55 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import org.jetbrains.kotlin.ir.backend.js.compileIr
import com.strumenta.antlrkotlin.gradle.AntlrKotlinTask
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile

plugins {
kotlin("multiplatform") version "1.9.0"
id("org.jetbrains.dokka") version "1.8.20"
kotlin("multiplatform") version "1.9.22"
id("org.jetbrains.dokka") version "1.9.10"
java
antlr
id("com.strumenta.antlr-kotlin") version "0.1.0-RC14"
`maven-publish`
}

val klarityVersion = "2.1.0"

group = "net.iceyleagons"
version = "2.0.2"
version = klarityVersion

repositories {
mavenCentral()
Expand Down Expand Up @@ -43,12 +48,25 @@ kotlin {
binaries.library()
}
sourceSets {
val commonMain by getting
val commonTest by getting {
commonMain {
dependencies {
implementation("com.strumenta:antlr-kotlin-runtime:0.1.0-RC14")
}

kotlin {
srcDir(layout.buildDirectory.dir("generatedAntlr"))
}
}
commonTest {
dependencies {
implementation(kotlin("test"))
}
}

jsMain {

}

val jvmMain by getting {
dependencies {
implementation("org.json:json:20230618")
Expand All @@ -57,7 +75,7 @@ kotlin {
val jvmTest by getting
val jsMain by getting {
dependencies {
implementation(enforcedPlatform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.430"))
implementation(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.674"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-js:1.9.0")
implementation("org.jetbrains.kotlin-wrappers:kotlin-js")
}
Expand All @@ -66,15 +84,44 @@ kotlin {
}
}

dependencies {
antlr("org.antlr:antlr4:4.13.1")
}


val generateKotlinGrammarSource = tasks.register<AntlrKotlinTask>("generateKotlinGrammarSource") {
dependsOn("cleanGenerateKotlinGrammarSource")

// ANTLR .g4 files are under
setSource(layout.projectDirectory.dir("src/antlr"))

// We want the generated source files to have this package name
val pkgName = "net.iceyleagons.klarity.parsers.generated"
packageName = pkgName

// We want visitors alongside listeners.
// The Kotlin target language is implicit, as is the file encoding (UTF-8)
arguments = listOf("-visitor")

// Generated files are outputted inside build/generatedAntlr/{package-name}
val outDir = "generatedAntlr/${pkgName.replace(".", "/")}"
outputDirectory = layout.buildDirectory.dir(outDir).get().asFile
}

tasks.dokkaHtml {
outputDirectory.set(File("docs"))
}

tasks.withType<KotlinCompile<*>> {
dependsOn(generateKotlinGrammarSource)
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "net.iceyleagons"
artifactId = "klarity"
version = "2.0.2"
version = klarityVersion

from(components["java"])
}
Expand Down
8 changes: 8 additions & 0 deletions docs/images/anchor-copy-button.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/arrow_down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/images/burger.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/copy-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/copy-successful-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/footer-go-to-link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions docs/images/go-to-top-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/images/logo-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions docs/images/nav-icons/abstract-class-kotlin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions docs/images/nav-icons/abstract-class.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions docs/images/nav-icons/annotation-kotlin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/nav-icons/annotation.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions docs/images/nav-icons/class-kotlin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/nav-icons/class.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions docs/images/nav-icons/enum-kotlin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/nav-icons/enum.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/images/nav-icons/exception-class.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/images/nav-icons/field-value.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 59e85a2

Please sign in to comment.