Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alllex/ink-lang
Configuration language with Kotlin syntax
https://github.com/alllex/ink-lang
configuration kotlin language multiplatform
Last synced: about 2 months ago
JSON representation
Configuration language with Kotlin syntax
- Host: GitHub
- URL: https://github.com/alllex/ink-lang
- Owner: alllex
- Created: 2023-11-05T09:39:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-12T13:34:42.000Z (about 1 year ago)
- Last Synced: 2024-10-28T19:56:32.671Z (4 months ago)
- Topics: configuration, kotlin, language, multiplatform
- Language: Kotlin
- Homepage:
- Size: 111 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ink
Ink is a configuration language that is a subset of Kotlin
```kotlin
// Flat properties style
server.port = 80// Nested scoping style
server {
// Overrides the value above!
port = 8080// Mixed style
auth {
token.refresh = ""
}
}// Human readable list syntax
testerIds = listOf(1001, 1002)// Builder style
users = listOf({
name = "Alex"
age = 42
}, {
name = "Bob"
age = 6033
})
```## Configuration
The primary use-case of Ink is configuration files.
The above example document can be interpreted as the following config:
```kotlin
fun main() {
val text = readFile("config.ink")
val config = readDocument(text)
println(config)
}@Serializable
data class Config(
val server: Server,
val testerIds: List,
val users: List,
)@Serializable
data class Server(val port: Int, val auth: ServerAuth)@Serializable
data class ServerAuth(val token: Token)@Serializable
data class Token(val refresh: String)@Serializable
data class User(val name: String, val age: Int)
```The Ink document is evaluated into JSON value, taking nesting and overrides into account.
Then `kotlinx.serialization` is used to convert the resulting JSON into a Kotlin object of a given type.## Roadmap
There are a few things that are missing from the language:
- Multi-line comments
- Multi-line strings
- Escaped string characters
- Semicolon as a statement separator
- Scientific notation for numbers
- Hexadecimal numbers
- Binary numbers
- MapsSome of the things that may or may not be included in the future:
- Local variables
- String interpolation
- Import of other files## License
Distributed under the MIT License. See `LICENSE` for more information.