Skip to content

toolcreator/simpleyaml.lua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simpleyaml.lua

Very simple YAML parser written in Lua.

Features:

  • understands a "useful" subset of YAML
  • parses correct files
    • line-based parser, each line needs to contain a key
    • almost no error handling
  • no dependencies
  • single-file

Example

Input:

---

# Example

someExample:
  someKey: Here is some string
  anotherKey: 42
  subExample1:
    foo: bar
  subExample2:
    hello: world

anotherExample:
  thats: it

Output:

{
  anotherExample = {
    thats = "it"
  },
  someExample = {
    anotherKey = "42",
    someKey = "Here is some string",
    subExample1 = {
      foo = "bar"
    },
    subExample2 = {
      hello = "world"
    }
  }
}

Documentation

Example usage:

simpleyaml = require("simpleyaml.lua")
local parsed = simpleyaml.parse_file("path/to/file.yaml")

Functions:

  • parse_file(path) Takes a path to a YAML file and returns a table representing the key-value pairs in the file. No type conversions are performed, there are only strings. May return nil in case of error.

About

Very simple, dependency-free (subset of) YAML parser

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages