NAME
Text::KDL::XS::Parser - Streaming KDL event parser
SYNOPSIS
use Text::KDL::XS::Parser;
my $p = Text::KDL::XS::Parser->new(\*STDIN, version => 'detect');
while (my $ev = $p->next_event) {
printf "%-12s %s\n", $ev->{event}, $ev->{name} // '';
}
DESCRIPTION
A thin wrapper over ckdl's kdl_parser exposing a SAX-like iterator.
Source types
String - parsed in-memory.
Filehandle / blessed IO object - read in chunks via
sysread.Code reference - invoked with a desired buffer size, returning bytes (or
undef/empty at EOF).
Event hash
Each event is a hash reference with these keys (most are optional and only present on relevant event kinds):
{
event => 'start_node' | 'end_node' | 'argument' | 'property' | 'comment',
commented => 0 | 1, # slashdash marker
name => $string, # for start_node and property
type => $string, # node type annotation, optional
value => Text::KDL::XS::Value, # for argument and property
}
comment events are only produced when the parser was constructed with emit_comments => 1. next_event returns undef at end of input and dies on a parse error.