focusaurus / gokdl

A parser implementation for the KDL document language in Go.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GoKDL

A parser implementation for the KDL document language in Go.

Example

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 ...
}

API

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.

Implementation Status

  • 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

About

A parser implementation for the KDL document language in Go.

License:MIT License


Languages

Language:Go 99.6%Language:Just 0.4%