<commit_before>package MarpaX::Demo::JSONParser::Actions;

use strict;
use warnings;

# Warning: Do not use Moo or anything similar.
# This class needs a sub new() due to the way
# Marpa calls the constructor.

our $VERSION = 1.00;

# ------------------------------------------------

sub do_array
{
	shift;

	return $_[1];

} # End of do_array.

# ------------------------------------------------

sub do_empty_array
{
	return [];

} # End of do_empty_array.

# ------------------------------------------------

sub do_empty_object
{
	return {};

} # End of do_empty_object.

# ------------------------------------------------

sub do_first_arg
{
	shift;

	return $_[0];

} # End of do_first_arg.

# ------------------------------------------------

sub do_join
{
	shift;

	return join '', @_;

} # End of do_join.

# ------------------------------------------------

sub do_list
{
	shift;

	return \@_;

} # End of do_list.

# ------------------------------------------------

sub do_null
{
	return undef;

} # End of do_null.

# ------------------------------------------------

sub do_object
{
	shift;

	return {map {@$_} @{$_[1]} };

} # End of do_object.

# ------------------------------------------------

sub do_pair
{
	shift;

	return [ $_[0], $_[2] ];

} # End of do_pair.

# ------------------------------------------------

sub do_string
{
	shift;

	my($s) = $_[0];

	$s =~ s/^"//;
	$s =~ s/"$//;

	$s =~ s/\\u([0-9A-Fa-f]{4})/chr(hex($1))/eg;

	$s =~ s/\\n/\n/g;
	$s =~ s/\\r/\r/g;
	$s =~ s/\\b/\b/g;
	$s =~ s/\\f/\f/g;
	$s =~ s/\\t/\t/g;
	$s =~ s/\\\\/\\/g;
	$s =~ s{\\/}{/}g;
	$s =~ s{\\"}{"}g;

	return $s;

} # End of do_string.

# ------------------------------------------------

sub do_true
{
	shift;

	return $_[0] eq 'true';

} # End of do_true.

# ------------------------------------------------

sub new
{
	my($class) = @_;

	return bless {}, $class;

} # End of new.

# ------------------------------------------------

1;

=pod

=head1 NAME

C<MarpaX::Demo::JSONParser::Actions> - A JSON parser with a choice of grammars

=head1 Synopsis

See L<MarpaX::Demo::JSONParser/Synopsis>.

The module is used automatically by L<MarpaX::Demo::JSONParser> as appropriate.

=head1 Description

See L<MarpaX::Demo::JSONParser/Description>.

=head1 Installation

See L<MarpaX::Demo::JSONParser/Installation>.

=head1 Constructor and Initialization

The constructor is called automatically by L<Marpa::R2> as appropriate.

=head1 Methods

=head2 new()

The constructor is called automatically by L<Marpa::R2> as appropriate.

=head1 Machine-Readable Change Log

The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.

=head1 Version Numbers

Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.

=head1 Support
<commit_msg>Clean up docs<commit_after>package MarpaX::Demo::JSONParser::Actions;

use strict;
use warnings;

# Warning: Do not use Moo or anything similar.
# This class needs a sub new() due to the way
# Marpa calls the constructor.

our $VERSION = 1.00;

# ------------------------------------------------

sub do_array
{
	shift;

	return $_[1];

} # End of do_array.

# ------------------------------------------------

sub do_empty_array
{
	return [];

} # End of do_empty_array.

# ------------------------------------------------

sub do_empty_object
{
	return {};

} # End of do_empty_object.

# ------------------------------------------------

sub do_first_arg
{
	shift;

	return $_[0];

} # End of do_first_arg.

# ------------------------------------------------

sub do_join
{
	shift;

	return join '', @_;

} # End of do_join.

# ------------------------------------------------

sub do_list
{
	shift;

	return \@_;

} # End of do_list.

# ------------------------------------------------

sub do_null
{
	return undef;

} # End of do_null.

# ------------------------------------------------

sub do_object
{
	shift;

	return {map {@$_} @{$_[1]} };

} # End of do_object.

# ------------------------------------------------

sub do_pair
{
	shift;

	return [ $_[0], $_[2] ];

} # End of do_pair.

# ------------------------------------------------

sub do_string
{
	shift;

	my($s) = $_[0];

	$s =~ s/^"//;
	$s =~ s/"$//;

	$s =~ s/\\u([0-9A-Fa-f]{4})/chr(hex($1))/eg;

	$s =~ s/\\n/\n/g;
	$s =~ s/\\r/\r/g;
	$s =~ s/\\b/\b/g;
	$s =~ s/\\f/\f/g;
	$s =~ s/\\t/\t/g;
	$s =~ s/\\\\/\\/g;
	$s =~ s{\\/}{/}g;
	$s =~ s{\\"}{"}g;

	return $s;

} # End of do_string.

# ------------------------------------------------

sub do_true
{
	shift;

	return $_[0] eq 'true';

} # End of do_true.

# ------------------------------------------------

sub new
{
	my($class) = @_;

	return bless {}, $class;

} # End of new.

# ------------------------------------------------

1;

=pod

=head1 NAME

C<MarpaX::Demo::JSONParser::Actions> - A JSON parser with a choice of grammars

=head1 Synopsis

See L<MarpaX::Demo::JSONParser/Synopsis>.

The module is used automatically by L<MarpaX::Demo::JSONParser> as appropriate.

=head1 Description

See L<MarpaX::Demo::JSONParser/Description>.

=head1 Installation

See L<MarpaX::Demo::JSONParser/Installation>.

=head1 Methods

The functions are called automatically by L<Marpa::R2> as appropriate.

=head2 new()

The constructor is called automatically by L<Marpa::R2> as appropriate.

=head1 Machine-Readable Change Log

The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>.

=head1 Version Numbers

Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions.

=head1 Support

{'fraction_non_alphanumeric': 0.3570404872805446, 'fraction_numerical': 0.011644571838050878, 'mean_word_length': 1.4168831168831169, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '958837', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1850, 'n_words': 480}