Skip to content

Instantly share code, notes, and snippets.

@leedo
Created August 5, 2009 21:09
Show Gist options
  • Save leedo/162957 to your computer and use it in GitHub Desktop.
Save leedo/162957 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use Regexp::Grammars;
use File::Slurp;
use Data::Dump qw/dump/;
my $config = read_file $ARGV[0];
my $parser = qr{
<[Item]>+
<token: Item>
<Directive> | <[Comment]>+ | <KeyValue>
<token: Comment>
\s*\#\s*<MATCH=([^\n]*)>\n
<rule: Directive>
\< <Key=(\w+)> \>
<[Value=Item]>+
\</ (??{$MATCH{Key}}) \>
<rule: KeyValue>
<Key=(\w+)>\s+<Value=(\w+)>
}x;
dump %/ if $config =~ $parser;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment