diff --git a/kmath-ast/build.gradle.kts b/kmath-ast/build.gradle.kts index deb6a28ee..65a1ac12c 100644 --- a/kmath-ast/build.gradle.kts +++ b/kmath-ast/build.gradle.kts @@ -1,29 +1,27 @@ -plugins { id("scientifik.mpp") } -repositories { maven("https://dl.bintray.com/hotkeytlt/maven") } +plugins { + id("scientifik.mpp") +} + +repositories{ + maven("https://dl.bintray.com/hotkeytlt/maven") +} kotlin.sourceSets { commonMain { dependencies { api(project(":kmath-core")) implementation("com.github.h0tk3y.betterParse:better-parse-multiplatform:0.4.0-alpha-3") + implementation("com.github.h0tk3y.betterParse:better-parse-multiplatform-metadata:0.4.0-alpha-3") } } - - jvmMain { - dependencies { + jvmMain{ + dependencies{ implementation("com.github.h0tk3y.betterParse:better-parse-jvm:0.4.0-alpha-3") - implementation("org.ow2.asm:asm:8.0.1") - implementation("org.ow2.asm:asm-commons:8.0.1") - implementation(kotlin("reflect")) } } - - jvmTest { - dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-junit5")) + jsMain{ + dependencies{ + implementation("com.github.h0tk3y.betterParse:better-parse-js:0.4.0-alpha-3") } } -} - -tasks.withType { useJUnitPlatform() } +} \ No newline at end of file diff --git a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MST.kt b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MST.kt index eba2c3343..3375ecdf3 100644 --- a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MST.kt +++ b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MST.kt @@ -43,7 +43,7 @@ sealed class MST { fun NumericAlgebra.evaluate(node: MST): T { return when (node) { is MST.Numeric -> number(node.value) - is MST.Singular -> raw(node.value) + is MST.Singular -> symbol(node.value) is MST.Unary -> unaryOperation(node.operation, evaluate(node.value)) is MST.Binary -> when { node.left is MST.Numeric && node.right is MST.Numeric -> { diff --git a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MSTExpression.kt b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MSTExpression.kt index 3ee454b2a..dbd5238e3 100644 --- a/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MSTExpression.kt +++ b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/MSTExpression.kt @@ -12,7 +12,7 @@ class MSTExpression(val algebra: NumericAlgebra, val mst: MST) : Expressio * Substitute algebra raw value */ private inner class InnerAlgebra(val arguments: Map) : NumericAlgebra by algebra { - override fun raw(value: String): T = arguments[value] ?: super.raw(value) + override fun symbol(value: String): T = arguments[value] ?: super.symbol(value) } override fun invoke(arguments: Map): T = InnerAlgebra(arguments).evaluate(mst) diff --git a/kmath-ast/src/jvmMain/kotlin/scientifik/kmath/ast/Parser.kt b/kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt similarity index 100% rename from kmath-ast/src/jvmMain/kotlin/scientifik/kmath/ast/Parser.kt rename to kmath-ast/src/commonMain/kotlin/scientifik/kmath/ast/parser.kt diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt index 166287ec7..8ed3f329e 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Algebra.kt @@ -10,7 +10,10 @@ interface Algebra { /** * Wrap raw string or variable */ - fun raw(value: String): T = error("Wrapping of '$value' is not supported in $this") + fun symbol(value: String): T = error("Wrapping of '$value' is not supported in $this") + + @Deprecated("Symbol is more concise",replaceWith = ReplaceWith("symbol")) + fun raw(value: String): T = symbol(value) /** * Dynamic call of unary operation with name [operation] on [arg] diff --git a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt index 01aef824d..6ce1d929b 100644 --- a/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt +++ b/kmath-core/src/commonMain/kotlin/scientifik/kmath/operations/Complex.kt @@ -51,10 +51,10 @@ object ComplexField : ExtendedField { operator fun Double.times(c: Complex) = Complex(c.re * this, c.im * this) - override fun raw(value: String): Complex = if (value == "i") { + override fun symbol(value: String): Complex = if (value == "i") { i } else { - super.raw(value) + super.symbol(value) } }