C library for parsing eno notation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Simon Repp 0d11845c5d
Allocate and attach a globally re-usable ICU context to the document
2 days ago
include Allocate and attach a globally re-usable ICU context to the document 2 days ago
lib Allocate and attach a globally re-usable ICU context to the document 2 days ago
test Draft public interface for checking what types an element yields 2 days ago
.gitignore Initialize 1 month ago
CMakeLists.txt Draft public interface for checking what types an element yields 2 days ago
README.md Implement experimental public API, use opaque types, drop lib prefix 3 days ago

README.md

libeno

C library for parsing eno notation.

Development status

libeno already parses most of any given eno document according to specification, with the exception of multiline fields, which are only partially implemented. There is already some solid functionality for printing back the AST that libeno constructs during parsing, annotated with line numbers and both in plain text and with terminal coloring. An experimental public interface for traversing the AST and obtaining some things from the document exists, it is however very incomplete and entirely undocumented at this point. Resolution of template references for element copies is currently skipped entirely.

C standard

libeno is written using C99, divergence from C89 mainly being usage of:

  • // style comments
  • Variable declarations anywhere in a block

Build

You need to install icu4c (the ICU library for C), including its headers. On linux this can be done through the package manager (e.g. libicu-dev on Ubuntu).

When the icu4c dependency is satisfied you can build libeno like this:

mkdir build
cd build
cmake ..
make

Test

Parsing a document, printing the AST

Inside build/ create a test document and run:

./test_parse your_document_path.eno

This debug-prints the document's abstract syntax tree and reports errors in the document if it encounters one.

Parsing a document, obtaining a value by key

Inside build/ create a test document and run:

./test_get your_document_path.eno "some key"

This parses the document and prints the value of a field at the root level of the document that matches the supplied key. It also prints considerable noise if there are other element types than fields, because the public API used for this is still completely experimental.