<commit_before>package Parrot::H2inc;
# Copyright (C) 2010, Parrot Foundation.
# $Id$

use strict;
use warnings;
use Exporter;
our @ISA = qw( Exporter );
our @EXPORT_OK = qw(
    parse_file
    perform_directive
    generate_text
    print_generated_file
);

=head1 NAME

Parrot::H2inc - Subroutines used in F<tools/build/h2inc.pl>

=head1 DESCRIPTION

This package exports on demand only four subroutines used in
F<tools/build/h2inc.pl>.

=head1 SUBROUTINES

=head2 C<parse_file()>

=over 4

=item * Arguments

    $directive = parse_file($in_file, $out_file);

List of 2 elements: string holding name of incoming file; string holding name of outgoing file.

=item * Return Value

If successful, returns a hash reference.

=back

=cut

sub parse_file {
    my ( $in_file, $out_file) = @_;

    my ( @directives, %values, $last_val, $cur, $or_continues );
    open my $fh, '<', $in_file or die "Can't open $in_file: $!\n";
    while ( my $line = <$fh> ) {
        if (
            $line =~ m!
            &gen_from_(enum|def) \( ( [^)]* ) \)
            (?: \s+ prefix \( (\w+) \) )?
            (?: \s+ subst \( (s/.*?/.*?/[eig]?) \) )?
            !x
            )
        {
            $cur and die "Missing '&end_gen' in $in_file\n";
            my $file;<commit_msg>[H2inc] fix on Windows<commit_after>package Parrot::H2inc;
# Copyright (C) 2010, Parrot Foundation.
# $Id$

use strict;
use warnings;
use Exporter;
our @ISA = qw( Exporter );
our @EXPORT_OK = qw(
    parse_file
    perform_directive
    generate_text
    print_generated_file
);

=head1 NAME

Parrot::H2inc - Subroutines used in F<tools/build/h2inc.pl>

=head1 DESCRIPTION

This package exports on demand only four subroutines used in
F<tools/build/h2inc.pl>.

=head1 SUBROUTINES

=head2 C<parse_file()>

=over 4

=item * Arguments

    $directive = parse_file($in_file, $out_file);

List of 2 elements: string holding name of incoming file; string holding name of outgoing file.

=item * Return Value

If successful, returns a hash reference.

=back

=cut

sub parse_file {
    my ( $in_file, $out_file) = @_;
    $out_file =~ s/\\/\//g; # transform Windows backslash

    my ( @directives, %values, $last_val, $cur, $or_continues );
    open my $fh, '<', $in_file or die "Can't open $in_file: $!\n";
    while ( my $line = <$fh> ) {
        if (
            $line =~ m!
            &gen_from_(enum|def) \( ( [^)]* ) \)
            (?: \s+ prefix \( (\w+) \) )?
            (?: \s+ subst \( (s/.*?/.*?/[eig]?) \) )?
            !x
            )
        {
            $cur and die "Missing '&end_gen' in $in_file\n";
            my $file;
{'fraction_non_alphanumeric': 0.14948256036795707, 'fraction_numerical': 0.011115369873514757, 'mean_word_length': 2.546195652173913, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '467532', 'n_tokens_mistral': 992, 'n_tokens_neox': 943, 'n_words': 263}