A parser implementation for the KDL document language in Go.
The following code shows a minimal example of parsing a KDL document:
package main
import (
"log"
"github.com/lunjon/gokdl"
)
func main() {
bs := []byte(`
MyNode "string arg" myint=1234 awesome=true {
child-node
}
// A node with arbitrary name (in quotes)
"Other node with much cooler name!" { Okay; }
`)
doc, err := gokdl.Parse(bs)
if err != nil {
log.Fatal(err)
}
// Do something with doc ...
}
The general API for module (including the types Doc, Node, Arg and Prop) is yet to be done.
Although it can be used, it is very rough.
- Comments
- Line
- Multiline
- Slash-dash
- Node with children
- Support arbitrary identifiers
- Multiline nodes
- Number literals
- Integers
- Float
- Scientific notation
- Strings
- Regular strings (double quotes)
- Raw string literals
- Type annotations