class

UCL::Parser

Inherits Reference < Object

Low-level wrapper around a libucl parser handle. It turns a string into the raw UCL::LibUCL::UclObject* tree consumed by Decoder and Validator.

This is an internal building block that exposes raw C pointers: it is not part of the public, semver-covered API and may change. Use UCL.load / UCL.load_file instead.

Constants

DEFAULT_FLAGS = UCL::LibUCL::ParserFlags::UCL_PARSER_NO_TIME | UCL::LibUCL::ParserFlags::UCL_PARSER_NO_IMPLICIT_ARRAYS

Flags applied by default: parse time values as strings (UCL_PARSER_NO_TIME) and produce explicit rather than implicit arrays (UCL_PARSER_NO_IMPLICIT_ARRAYS). See UCL::LibUCL::ParserFlags.

Constructors

new(flags = DEFAULT_FLAGS)

Allocates a new libucl parser configured with flags.

Source

Class methods

parse(string : String, flags = DEFAULT_FLAGS)

Parses string with a fresh parser and returns the raw libucl object.

Source
parse_file(path : String, flags = DEFAULT_FLAGS)

Parses the file at path with a fresh parser and returns the raw object.

Source

Instance methods

parse(string : String)

Feeds string to the parser and returns the resulting UclObject*.

The returned object is a NEW owned reference (see LibUCL#get_object); the caller is responsible for object_unref-ing it. The parser itself is freed here — ensure runs even on a parse error, so no parser handle leaks.

Raises UCL::Error::DecoderError if libucl reports a parse error.

Source
parse_file(path : String)

Like #parse, but loads the UCL document from the file at path (libucl resolves file vars and relative includes). Same ownership/free contract.

Raises UCL::Error::DecoderError if the file cannot be read or parsed.

Source