class
UCL::Parser
- UCL::Parser
- Reference
- Object
Overview
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.
Defined in:
ucl/parser.crConstant Summary
-
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). SeeUCL::LibUCL::ParserFlags.
Constructors
-
.new(flags = DEFAULT_FLAGS)
Allocates a new libucl parser configured with flags.
Class Method Summary
-
.parse(string : String, flags = DEFAULT_FLAGS)
Parses string with a fresh parser and returns the raw libucl object.
-
.parse_file(path : String, flags = DEFAULT_FLAGS)
Parses the file at path with a fresh parser and returns the raw object.
Instance Method Summary
-
#parse(string : String)
Feeds string to the parser and returns the resulting
UclObject*. -
#parse_file(path : String)
Like
#parse, but loads the UCL document from the file at path (libucl resolves file vars and relative includes).
Constructor Detail
Class Method Detail
Parses string with a fresh parser and returns the raw libucl object.
Parses the file at path with a fresh parser and returns the raw object.
Instance Method Detail
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.
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.