https://github.com/plokhotnyuk/expression-evaluator
Compile-time expression evaluation for Scala 2
https://github.com/plokhotnyuk/expression-evaluator
compile-time eval expression-evaluator macro scala
Last synced: 4 months ago
JSON representation
Compile-time expression evaluation for Scala 2
- Host: GitHub
- URL: https://github.com/plokhotnyuk/expression-evaluator
- Owner: plokhotnyuk
- License: apache-2.0
- Created: 2019-05-10T05:04:13.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T05:49:26.000Z (4 months ago)
- Last Synced: 2025-03-17T21:43:34.372Z (4 months ago)
- Topics: compile-time, eval, expression-evaluator, macro, scala
- Language: Scala
- Homepage:
- Size: 161 KB
- Stars: 15
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Expression Evaluator
[](https://github.com/plokhotnyuk/expression-evaluator/actions)
[](https://scala-steward.org)
[](https://search.maven.org/search?q=com.github.plokhotnyuk.expression-evaluator)Compile-time expression evaluation for Scala
## How to use
Add the library with a "provided" scope to your dependencies list:
```sbt
libraryDependencies ++= Seq(
"com.github.plokhotnyuk.expression-evaluator" %% "expression-evaluator" % "0.1.3" % Provided // required only in compile-time
)
```Generate expression results for primitives, strings, `BigInt`, `java.time.ZoneId`, `java.time.ZoneOffset`, and arrays of
them:
```scala
import com.github.plokhotnyuk.expression_evaluator._object Constants {
val x = eval(10 * 10 * 10)
val xs = eval((1 to 3).toArray)
}
```To see generated code for expression results
```sbt
scalacOptions ++= Seq("-Xmacro-settings:print-expr-results")
```## How to contribute
### Build and test
To compile, run tests, check coverage, and check binary compatibility for different Scala versions use a command:
```sh
sbt clean +coverage +test +coverageReport +mimaReportBinaryIssues
```BEWARE: expression-evaluator is included into [Scala Community Build](https://github.com/scala/community-builds)
for 2.11.x, 2.12.x, and 2.13.x versions of Scala.### Publish locally
Publish to the local Ivy repo:
```sh
sbt +publishLocal
```Publish to the local Maven repo:
```sh
sbt +publishM2
```### Release
For version numbering use [Recommended Versioning Scheme](http://docs.scala-lang.org/overviews/core/binary-compatibility-for-library-authors.html#recommended-versioning-scheme)
that is used in the Scala ecosystem.Double check binary and source compatibility (including behavior) and run `release` command (credentials required):
```sh
sbt release
```