https://github.com/epiqc/ScaffCC
Tip revision: 861c8b60980b0f4d36b101b45346a2e64b0fa390 authored by Pranav Gokhale on 05 February 2018, 05:29:11 UTC
update documentation and release notes
update documentation and release notes
Tip revision: 861c8b6
leaves.pl
#!/usr/bin/perl
open FIN, $ARGV[0] or die "Unable to open $ARGV[0]! $!\n";
my $in_func = 0;
my $leaf = 1;
my $buffer = [];
while (<FIN>) {
if (/#Function (\w+)/) {
$in_func = 1;
push @$buffer, $_;
} elsif (/#EndFunction/) {
push @$buffer, $_;
if ( $leaf ) {
print @$buffer;
print "\n";
}
$in_func = 0;
$leaf = 1;
$buffer = ();
} elsif ( $in_func and $leaf ) {
my ($ts, $op, @args) = split / /;
$leaf = 0 if ( $op !~ /^(?:GateName|PrepZ|MeasX|MeasZ|CNOT|H|S|Sdag|T|Tdag|X|Y|Z|Fredkin)$/ );
push @$buffer, $_ if ( $leaf );
}
}