view src/parallel_execution/tmp_tool/parse_cerate_each_context.pl @ 569:077158ea026c

tweak
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 23 Nov 2019 19:39:11 +0900
parents 840597c5d242
children 1233236c244d
line wrap: on
line source

#!/usr/bin/env perl
use strict;
use warnings;
use DDP {deparse => 1};

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

open my $fh, '<', $context;
while (my $line = <$fh>) {
  if ($line =~ /^union Data \{/) {
    last;
  }
}

my @context_cg_str = <$fh>;
close($fh);
chomp @context_cg_str;
my $res = {};

while (my $line = shift @context_cg_str) {
  if ($line =~ /\s*struct\s*(\w+)\s*\{/) {
    my $struct = $1;
    $line = shift @context_cg_str;
    while ($line !~  /\}\s*$struct/) {
        $line =~ s/\s+([\*\w ]+);/$1/;
        push (@{$res->{$struct}},$line);
        $line = shift @context_cg_str ;
    }
  }
}
use Data::Dumper;

print Dumper  $res;