#!/usr/bin/env perl

use strict;
use warnings;
use 5.010;

use FindBin;
use lib $FindBin::Bin;
use Parser ();  # our Marpa-based parser

use Data::Dump 'dump';
use Data::TreeDumper;

my $data = Parser::EXAMPLE_INPUT;
my $ast = Parser->parse(\$data);

my ($command) = (@ARGV == 1) ? @ARGV : ();
$command //= q();

if ($command eq '--dump') {
    say dump($ast);
}
elsif ($command eq '--tree') {
    say DumpTree($ast, 'ast', DISPLAY_ADDRESS => 0, QUOTE_VALUES => 1);
}
else {
    say STDERR "Usage:";
    say STDERR "  $0 --dump";
    say STDERR "  $0 --tree";
    exit 1;
}
