Sélectionner une révision Git
oud2_parser.pl 5,46 Kio
#!/usr/bin/perl
use Module::Load;
use utf8;
use autodie 'open';
use strict;
use warnings;
use feature 'unicode_strings';
use open qw( :std :encoding(UTF-8) );
binmode(STDOUT, ":encoding(UTF-8)");
BEGIN
{
unshift @INC, './lib';
}
use FindBin;
use File::Spec;
use lib File::Spec -> catdir ($FindBin::Bin, '..', 'lib');
use Perl::Critic;
use Nice::Try;
use Marpa::R2;
use Data::Dumper;
use File::BOM;
use App::Ts;
use App::Ressya;
use App::Frame;
use App::FrameUtils;
use App::Dia;
my $dia_path = $ARGV[0];
my $default_path = 'tests/dia/kyogoku.oud2';
my $dia_file;
if (defined $dia_path)
{
open $dia_file, '<:encoding(UTF-8):via(File::BOM)', $dia_path;
}
else
{
print "No file has been supplied.\n";
print "Using default file $default_path.\n";
open $dia_file, '<:encoding(UTF-8):via(File::BOM)', $default_path;
}
read $dia_file, my $diah, -s $dia_file;
# TODO refactor
my $contents = $diah;
my $diar = << 'endrule'
lexeme default = latm => 1
:start ::= ALL
ALL ::= HEADER_SECTION
ROSEN_SECTION
EKI_SECTION
SYUBETSU_SECTION
DIA_SECTION
action => Dia::frame
HEADER_SECTION ::= HEADER_BEGIN
VERSIONING
ROSEN_SECTION ::= ROSEN_BEGIN
ROSEN_NAME
GARBAGE_LINES
action => Dia::second