Skip to content
cppfwPublic

About

🌿 tree markup language parser in C++

Resources

Stars

10 stars

Watchers

2 watching

Forks

Repository files navigation

tml

releases ci status

Tree Markup Language. A lightweight markup language C++ library.

The idea is that the document is just a tree of strings. Each string can have a number of children strings or no children at all, and so on.

document example:

"quoted string"
unquoted_string
"string with children"{
	"child 1"
	Child2
	"child three"{
		SubChild1
		"Subchild two"

		# properties can be expressed as a string with just one child
		Property1 {Value1}
		"Property two" {"Value 2"}

		# a # opens a line comment, it runs to the end of the line

		# / is an ordinary character, so URLs can be written without quotes:
		http://website.com/some/url/*

		# escape sequences inside a quoted string
		"Escape sequences: \" \n \t \\"

		# a raw string is delimited by a run of 3 or more double quotes
		# followed by '(', and closed by ')' followed by a matching run
		# of quotes; its content is byte-exact and no escape is processed
		"""(raw string content " "" { } \ /)"""

		# a longer opening run is needed when the content has a quote run
		# immediately after a ')' that could look like a closing delimiter
		"""(it has """" quotes)"""
	}
}

The full language specification is in doc/spec.md, the formal BNF grammar in doc/bnf.md.

Usage

#include <tml/tree.hpp>

auto doc = tml::read(
R"(
root{
	name{value}
	"quoted child"
}
)"
);

for (const auto& node : doc)
{
	const auto& value = node.value.string;  // the node's string
	for (const auto& child : node.children)
		// ... visit children ...
	{};
};

std::string text = tml::to_string(doc);  // serialize back to tml

Installation and Documentation

See Wiki.

About

🌿 tree markup language parser in C++

Resources

Stars

10 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages