#!/usr/bin/perl

#Substitui todas as macros, e gera um novo dicionário (expande)
#expandeRef: Dic * P(Ref) -> Dic

#Rui Vilela, 2007

use warnings;
use strict;
use locale;
use Data::Dumper;

my $h = do "./".shift;

while(<>){
    next if /^\#/;
    next if /^\s+$/;
    s{\#([\d\w]{1,4})([\,\$\/])}{
      my ($a, $b) = ($1, $2);
      die "$a not found (file without ending newline?)" unless exists $h->{$a};
      "$h->{$a}$b"
    }ge;
    s/\#.+$//;
    print;
}
