DMS-XS-Parser

 view release on metacpan or  search on metacpan

Parser.xs  view on Meta::CPAN

    HV *h = newHV();
    SV *content_sv = newSVpv(ac->content ? ac->content : "", 0);
    sv_utf8_decode(content_sv);
    hv_store(h, "content", 7, content_sv, 0);
    const char *kind = (ac->kind == DMS_COMMENT_BLOCK) ? "block" : "line";
    hv_store(h, "kind", 4, newSVpv(kind, 0), 0);
    return newRV_noinc((SV *)h);
}

/* Build a path arrayref from a dms_breadcrumb_seg array. String segments
 * are plain Perl scalars (UTF-8 decoded); index segments are blessed
 * DMS::Index scalar refs (matching the pure-Perl parser's wrapper).
 * Used by both attached-comment paths and original-form-entry paths. */
static SV *path_segs_to_sv(pTHX_ const dms_breadcrumb_seg *segs, size_t n) {
    AV *av = newAV();
    if (n > 0) av_extend(av, (SSize_t)n - 1);
    for (size_t i = 0; i < n; i++) {
        const dms_breadcrumb_seg *seg = &segs[i];
        if (seg->is_index) {
            HV *st = get_stash_cached(aTHX_ &stash_Index, "DMS::Index");
            av_push(av, bless_sentinel(aTHX_ st, newSViv((IV)seg->idx)));

vendor/dms-c/dms.c  view on Meta::CPAN

                for (size_t j = 0; j < mods->mods[i].nargs; j++) {
                    sf->modifiers[i].args[j] = dms_value_clone(mods->mods[i].args[j]);
                }
            }
        }
    }
    return sf;
}

/* 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. The basic-string lexer
   (parse_basic_string_str) already enforces this; basic-heredoc body
   lines are collected raw, so we validate the same rule by scanning
   the body for surrogate escape sequences. Returns 1 on OK, sets the
   parser error and returns 0 on a surrogate escape. */
static int validate_heredoc_basic_surrogates(const h_body *body, parser *p) {
    for (size_t li = 0; li < body->len; li++) {
        const h_line *ln = &body->lines[li];
        const char *text = ln->text;
        size_t tl = strlen(text);



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