#!/usr/bin/env perl

use STD;
use DumpMatch;
use utf8;
use YAML::XS;
use Encode;
use strict;
use warnings;
use Getopt::Long;
my $nocolor = 0;
my $horizontal = 0;
my $yaml = 0;
my $mark_arrays;
GetOptions("nocolor"=>\$nocolor,"horizontal"=>\$horizontal,"yaml"=>\$yaml,"mark-arrays"=>\$mark_arrays);
unless ($#ARGV <= 0) {
    die "USAGE: [--nocolor --horizontal --mark-arrays] filename [rule]\n";
}
if ($nocolor) {
    $DumpMatch::NOCOLOR = 1;
}
my $file = shift;
my $what = shift // 'comp_unit';

my $r = STD->parsefile($file,$what);
if ($yaml) {
    print Dump($r);
    exit;
} else {
    print dump_match($what=>$r,{vertical=>!$horizontal,mark_arrays=>$mark_arrays,visit_twice=>1}),"\n";
}

