├── parsers └── lua-parser │ ├── samples │ ├── s4.koy │ ├── s3.koy │ ├── s2.koy │ └── s1.koy │ ├── test.lua │ ├── src │ ├── utils.lua │ └── lib.lua │ ├── README.md │ └── deps │ └── inspect.lua ├── .prettierrc.json ├── docs ├── style-guide.md ├── conventions.md ├── README.md └── specs.md ├── example.koy ├── .editorconfig ├── LICENSE └── README.md /parsers/lua-parser/samples/s4.koy: -------------------------------------------------------------------------------- 1 | // this is s4 2 | is_foss: true 3 | -------------------------------------------------------------------------------- /parsers/lua-parser/samples/s3.koy: -------------------------------------------------------------------------------- 1 | // this is s3.koy 2 | creation_date: 1892 3 | -------------------------------------------------------------------------------- /parsers/lua-parser/samples/s2.koy: -------------------------------------------------------------------------------- 1 | env: { 2 | user: "pocco81", 3 | editor: "neovim" 4 | } 5 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "es5", 3 | "tabWidth": 4, 4 | "semi": false, 5 | "singleQuote": true 6 | } 7 | -------------------------------------------------------------------------------- /docs/style-guide.md: -------------------------------------------------------------------------------- 1 |
2 |
7 | A guide on how to properly style and implement the language 8 |
9 | 10 | 11 | -------------------------------------------------------------------------------- /example.koy: -------------------------------------------------------------------------------- 1 | /* 2 | Hello world! this is a simple Koy document 3 | and you are reading a multi-line comment :^) 4 | */ 5 | 6 | // let's import some settings, shall we? 7 | import "./settings/screen.koy" 8 | 9 | title: "Koy Example" 10 | 11 | user: { 12 | name: "Michael Theodor Mouse", 13 | age: 23, 14 | married: true 15 | } 16 | 17 | ports: [ 8001, 8002, 8003 ] 18 | -------------------------------------------------------------------------------- /parsers/lua-parser/samples/s1.koy: -------------------------------------------------------------------------------- 1 | /* 2 | Hello world! this is a simple Koy document 3 | and you are reading a multi-line comment :^) 4 | */ 5 | 6 | // let's import some settings, shall we? 7 | import "./samples/s2.koy" 8 | 9 | title: "Koy Example" 10 | 11 | user: { 12 | name: "Michael Theodor Mouse", 13 | age: 23, 14 | married: true 15 | } 16 | 17 | ports: [ 8001, 8002, 8003 ] 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # EditorConfig is awesome: https://EditorConfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | charset = utf-8 10 | indent_size = 4 11 | indent_style = tab 12 | end_of_line = lf 13 | insert_final_newline = true 14 | trim_trailing_whitespace = true 15 | 16 | [*.{diff,md}] 17 | trim_trailing_whitespace = false 18 | 19 | -------------------------------------------------------------------------------- /docs/conventions.md: -------------------------------------------------------------------------------- 1 |2 |
6 | Standard utilization of the language 7 |
8 | 9 | 10 | 11 | ### Filename 12 | 13 | + **Extension:** Koy files must use the `.koy` extension. 14 | + **Naming Convention:** try to stick with the _snake_case_ naming convention. 15 | 16 | ### MIME Type 17 | 18 | The appropriate MIME type is `application/koy` 19 | 20 | 21 | -------------------------------------------------------------------------------- /parsers/lua-parser/test.lua: -------------------------------------------------------------------------------- 1 | local koy_parser = require("src.lib") 2 | local inspect = require("deps.inspect") 3 | 4 | local koy_sample = require("src.utils").dump_file("./samples/s1.koy") 5 | local parsed_koy = koy_parser.decode(koy_sample) 6 | 7 | -- NOTE: when using inspector, tables that have the same content will be represented by pointers: 8 | --[[ for example: 9 | { 10 | person1 = <1>{ 11 | age = 121, 12 | name = "Michael" 13 | }, 14 | person2 =| Symbols | Function | Example | 38 | 39 |
// |
42 | Single-line comment | 43 |44 | 45 | ``` 46 | // hello world! 47 | ``` 48 | 49 | | 50 |
/**/ |
54 | Multi-line comment | 55 |56 | 57 | ``` 58 | /* 59 | This is a multi-line comment and 60 | you are watcing Disney channel! 61 | */ 62 | ``` 63 | 64 | | 65 |
: |
70 | Set a key, followed by its data type (optional) and then the value. To define a literal key put it between single quotes ('') |
71 | 72 | 73 | ``` 74 | hello: "world!" 75 | 76 | // specifying data type 77 | temperature:int 12.23 78 | ``` 79 | 80 | | 81 |
${} |
86 | Call a variable | 87 |88 | 89 | ``` 90 | // simple usage 91 | name: "Michael Theodor Mouse" 92 | hello: "Good evening ${name}" 93 | 94 | // with arrays (using the `.` notation) 95 | user: { 96 | name: "Michael", 97 | surnames: "Theodor Mouse" 98 | } 99 | hi: "Good morning ${user.name}" 100 | ``` 101 | 102 | | 103 |
"" |
108 | Define a normal string | 109 |110 | 111 | ``` 112 | hello: "world" 113 | ``` 114 | 115 | | 116 |
""" """ |
121 | Define a multi-line string | 122 |123 | 124 | ``` 125 | hello: """My name is 126 | Michael Theodor Mouse, but 127 | you can call me Peter. 128 | """ 129 | ``` 130 | 131 | | 132 |
'' |
137 | Define a literal value | 138 |139 | 140 | ``` 141 | weird_path: 'pc/\fds!fd/\&24324%!@' 142 | ``` 143 | 144 | | 145 |
[] |
150 | Define an array | 151 |152 | 153 | ``` 154 | hosts: [ "omega", "alpha", "gama" ] 155 | ``` 156 | 157 | | 158 |
{} |
163 | Define an object | 164 |165 | 166 | ``` 167 | user: { 168 | name: "Michael Theodor Mouse", 169 | age: 92 170 | } 171 | ``` 172 | 173 | | 174 |
import |
179 | Import other .koy files |
180 | 181 | 182 | ``` 183 | // single import 184 | import "./directory/settings.koy" 185 | 186 | // multiple imports 187 | import { 188 | "./directory/user0.koy", 189 | "./directory/user1.koy", 190 | "./directory/user2.koy" 191 | } 192 | ``` 193 | 194 | | 195 |
<< |
200 | Overwrite values from objects | 201 |202 | 203 | ``` 204 | user: { 205 | name: "Michael Theodor Mouse", 206 | age: 93 207 | } 208 | 209 | laptop: { 210 | name: "Lenovo Thinkpad", 211 | owner: ${user} << { 212 | name: "Dominic Toretto" 213 | } 214 | } 215 | ``` 216 | 217 | | 218 |
.koy file using every feature2 |
6 | Experimental human-friendly data serialization language 7 |
8 | 9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 | Koy is a new flexible and feature-rich data serialization language; easy for you, your dog and your average 5 year-old. Its design focuses on being visually unobtrusive while keeping an overall sense of verbosity, allowing easy-to-write parsers (in multiple languages) to effortlessly map the data to hash tables. 22 |
23 | 24 | 25 | 26 | ### 🐣 Example 27 | 28 | ```koy 29 | /* 30 | Hello world! this is a simple Koy document 31 | and you are reading a multi-line comment :^) 32 | */ 33 | 34 | // let's import some settings, shall we? 35 | import "./settings/screen.koy" 36 | 37 | title: "Koy Example" 38 | 39 | person: { 40 | name: "Michael Theodor Mouse", 41 | age: 34 42 | } 43 | 44 | laptop: { 45 | owner: ${person} << { 46 | username: "mickey1234" 47 | }, 48 | temp:int 203.04, 49 | married: true, 50 | document: ${title} 51 | } 52 | 53 | ports: [ 8001, 8002, 8003 ] 54 | ``` 55 | 56 | > As shown here, Koy isn't only good for deeply nested data, but also for avoiding an unambiguous use of it, managing their data-types and modularizing them. 57 | 58 | 59 | 60 | ### 📋 Characteristics 61 | 62 | - **Friendly Syntax with Obvious Semantics**: everything in a Koy file works on a `key` -> `value` basis, therefore you can nest data as much as you want and no matter what, it's easy to comprehend at a glance. 63 | - **Standard Errors**: Koy defines a list of semantic errors throwable for when the parser screams _"oh crap! what is this?"_. This way developers get an implementation-agnostic definition that helps them debug their program's config faster. 64 | - **Unambiguous**: Koy has one, and only _ONE_ way to define each thing, because doing the opposite would increase the overall complexity of the language. 65 | - **Feature Rich:** Koy supports: 66 | - comments 67 | - variables 68 | - type casting & coercion 69 | - data overwritting 70 | - importing other koy files 71 | - native data-types: 72 | - Integer (`int`) 73 | - String (`str`) 74 | - Null (`null`) 75 | - Array (`arr`) 76 | - Boolean (`bool`) 77 | - Float (`flt`) 78 | - Object (`obj`) 79 | 80 | 81 | 82 | ### 🪴 Index 83 | 84 | + [Library Implementations](#-library-implementations) 85 | + [IDE/DE Support](#%EF%B8%8F-idede-support) 86 | + [Documentation](#-documentation) 87 | + [ToDo List](#-todo-list) 88 | + [FAQ](#-faq) 89 | + [License](#-license) 90 | 91 | 92 | 93 | 94 | 95 | ### 📚 Library Implementations 96 | 97 | The following is a list of library implementations for Koy: 98 | 99 | - 🌙 Lua: [`parser`](https://github.com/Pocco81/koy-lang/tree/main/parsers/lua-parser) 100 | 101 | 102 | 103 | ### 🖼️ IDE/DE Support 104 | 105 | The following is a list of IDE/DE plugins available for Koy: 106 | 107 | > 👷🛑 Under dev 108 | 109 | 110 | 111 | ### 🎁 Documentation 112 | 113 | You can read Koy's docs [here](https://github.com/Pocco81/koy-lang/tree/main/docs) 114 | 115 | 116 | 117 | ### 🧻 ToDo List 118 | 119 | Check out the list [here](https://github.com/Pocco81/koy-lang/projects/1). 120 | 121 | 122 | 123 | ### 🙋 FAQ 124 | 125 | - _**Why?**_ 126 | 127 | **Disclaimers**: 128 | 129 | - these are just my thoughts on config/data serialization languages. Feel free to disagree (and to open an issue, I'm open to discussions.) 130 | - all this is for the sake of creating a _bettter_ language, however I still haven't decided if I'll end up making this. Initially this repo was just meant to be a rant, but I don't know, maybe something good will come out of here! 131 | 132 | With that said, let's continue... 133 | 134 | I like how XML is useful for porting data across platforms, however I dislike the fact that it "repeats itself" too much (opening and closing tags), so often times it feels visually jammed. JSON, however, is vastly nicer on the eyes due to its notable hierarchical structure. But now, looking more at its syntax I can't help but feel like it's _too strict_(?) (numbers and longstrings are a nightmare); apart from that, given that JSON is a data-only-type-of-config-language, nice stuff such as comments are not baked into it. On the other end of the spectrum, TOML, which focuses on being easy to read due to obvious sematic sucks for deeply nested _data_. The `.` convention simply doesn't cut it for me. Furthermore, something that I wish any of these included by default is native support for variable placeholders. I know, YAML has aliases and anchors which sorta do the job? however these simply don't work as such because they can't be inserted arbitrarily throughout a YAML file, which sucks too. Speaking about YAML, it is unnecessarily complex. Like, c'mon? 4 ways to define a simple boolean? 135 | 136 | **Koy**, in a sense, is just a proof of concept for what I ambition my _ideal_ data serialization language to look like. 137 | 138 | 139 | 140 | ### 📜 License 141 | 142 | Koy is released under the MIT license, which grants the following permissions: 143 | 144 | - Commercial use 145 | - Distribution 146 | - Modification 147 | - Private use 148 | 149 | For more convoluted language, see the [LICENSE](https://github.com/koy-lang/koy-lang/blob/main/LICENSE). 150 | 151 | 152 | -------------------------------------------------------------------------------- /docs/specs.md: -------------------------------------------------------------------------------- 1 |2 |
6 | Syntactic rules 7 |
8 | 9 | 10 | 11 | - [TL;DR](#tldr) 12 | - [General Structure](#general-structure) 13 | - [Comments](#comments) 14 | - [Data Types](#data-types) 15 | - [Specifying/Converting Data Types](#specifyingconverting-data-types) 16 | - [Integer](#integer-int) 17 | - [String](#string-str) 18 | - [Null](#null-null) 19 | - [Array](#array-arr) 20 | - [Boolean](#boolean-bool) 21 | - [Float](#float-float) 22 | - [Object](#object-bool) 23 | - [Imports](#imports) 24 | - [Variables](#variables) 25 | 26 | 27 | 28 | ### 😴 TL;DR 29 | 30 | Everything in a Koy file is a variable specified on a `key -> value` basis, for example: `hello: "world"`. If it makes sense to your data model, you may group them on objects (`{}`), which you can later put inside of arrays, because these operate on a `index -> value` basis. Furthermore, the data type of these values can be specified using `!!type` to enhance verbosity. These variables can be accessed using `${variable}`; on objects and arrays, however, you can use either the `${dot.convention}` or the `${brackets['convention']}`. 31 | 32 | 33 | 34 | ### General Structure 35 | 36 | Like JSON, `key -> values` are the foundation of everything. The general structure is the following one: 37 | 38 | ``` 39 | key: value 40 | ``` 41 | 42 | > notice the space between the `:` and the `value`. 43 | 44 | #### Keys 45 | 46 |(A-Za-z0-9_)