DMS-Parser

 view release on metacpan or  search on metacpan

lib/DMS/Parser.pm  view on Meta::CPAN

        if ($$src_ref =~ /\G[ \t]*(?:#|\/\/)[^\n\r]*\r?\n/gc) { next LINE; }

        # Mega-match: kvpair with simple value OR nested-block header.
        # Group layout (capturing only — non-capturing alternations
        # don't shift indices):
        #   $1 = indent (spaces)
        #   $2 = bareword key
        #   $3 = positive integer
        #   $4 = negative integer
        #   $5 = bool ('true'/'false')
        #   $6 = basic-string content (escapes allowed; decoded after)
        #   $7 = empty list / empty table literal ('[]' or '{}')
        #   $8 = decimal float (no exponent)
        #   $9 = flow-list-of-simple-values content (between [ and ],
        #        no nested brackets, no embedded newlines)
        #   $10 = flow-table-of-simple-kvpairs content
        #   $11 = trailing '\r?\n' for the no-value (header) form
        if ($$src_ref =~ /\G([ ]*)([A-Za-z_][A-Za-z0-9_-]*):(?:[ ](?:(0|[1-9][0-9]{0,17})|(-[1-9][0-9]{0,17})|(true|false)|"((?:[\x20\x21\x23-\x5b\x5d-\x7e]|\\(?:["\\nrtbf]|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}))*)"|(\[\]|\{\})|(-?(?:0|[1-9][0-9]*)\.[0-9]+...
            my $ind = length($1);
            my $key = $2;
            # Pop closed levels (top's children no longer reachable).

lib/DMS/Parser.pm  view on Meta::CPAN

            flavor => 'basic_triple',
            label => (length($label) ? $label : undef),
            modifiers => [ map { { name => $_->{name}, args => $_->{args} } } @$mods ],
        },
    });
    # SPEC §Unicode normalization: re-NFC after escape decoding.
    return $out !~ /[^\x00-\x7F]/ ? $out : _NFC($out);
}

# SPEC §basic-string escapes: a `\uXXXX` / `\UXXXXXXXX` escape whose
# decoded value falls in the surrogate range U+D800..U+DFFF is not a
# Unicode scalar and is a parse error. Likewise U+0000 is forbidden.
# Basic-heredoc body lines are collected raw, so we validate the same
# rules by scanning the body for offending escape sequences.
sub _validate_heredoc_basic_escapes {
    my ($body) = @_;
    for my $ln (@{$body->{lines}}) {
        my $text = $ln->{text};
        my $len = length($text);
        my $i = 0;
        while ($i < $len) {

lib/DMS/Parser/Tier1.pm  view on Meta::CPAN

    return 1 if $cp == 0x20E3;                       # Combining Enclosing Keycap
    return _is_extended_pictographic($cp);
}

sub _is_regional_indicator { my ($cp) = @_; $cp >= 0x1F1E6 && $cp <= 0x1F1FF }
sub _is_emoji_modifier     { my ($cp) = @_; $cp >= 0x1F3FB && $cp <= 0x1F3FF }

# Read one Reserved-Emoji extended grapheme cluster from a *character* string
# starting at character offset $pos. Returns the new position (past the cluster)
# or undef if no emoji cluster starts at $pos.
# The input $str must be a Perl character string (decoded Unicode).
sub _read_reserved_emoji_atom_char {
    my ($str, $pos) = @_;
    my $len = length($str);
    return undef if $pos >= $len;

    my $c0 = substr($str, $pos, 1);
    my $cp0 = ord($c0);
    return undef unless _is_reserved_emoji_codepoint($cp0);

    my $end = $pos + 1;

lib/DMS/Parser/Tier1.pm  view on Meta::CPAN

hashref:

=over 4

=item * C<tier> — integer 0 or 1.

=item * C<imports> — arrayref of ImportSpec hashrefs (empty for tier-0 docs).
Each ImportSpec has keys C<dialect>, C<version>, C<ns>, C<bind>, C<allow>,
C<deny>, C<alias>.

=item * C<body> — the decoded value tree (same shape as C<DMS::Parser::decode>).

=item * C<decorators> — arrayref of decorator entry hashrefs, each with C<path>,
C<calls> (hashref of sigil → arrayref of call records), and C<comments>.

=item * C<_raw_doc> — the underlying tier-0 Document (for callers that need the
full Document including front matter and comments).

=back

Dies with a C<line:col: message> diagnostic on parse or validation error.



( run in 0.372 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )