Skip to content

Commit

Permalink
Go through file and pick out all the high level structural entities i…
Browse files Browse the repository at this point in the history
…n the file.
  • Loading branch information
colomon committed Oct 29, 2012
1 parent f960bb5 commit d65de09
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions bin/structure.pl
Expand Up @@ -2,6 +2,11 @@
use ISO_10303_21::Grammar;
use ISO_10303_21::Actions;

sub print-sorted-keys(%look-for) {
say "Looking for " ~ %look-for.keys.sort(-> $a, $b { substr($a, 1) <=> substr($b, 1) }).join(" ");

}

for @*ARGS -> $file {
say "Reading $file";
my $file-data = slurp($file);
Expand All @@ -13,17 +18,43 @@
next;
}

my @look-for;
my %look-for;
for $step-data.entities.kv -> $index, $object {
if $object ~~ ISO_10303_21::Record {
if $object.keyword ~~ /SHAPE_REPRESENTATION$/ {
@look-for.push($index);
%look-for{$index} = 1;
}
} else {
if any($object.list.map({ $_.keyword ~~ /SHAPE_REPRESENTATION$/ })) {
@look-for.push($index);
%look-for{$index} = 1;
}
}
}

print-sorted-keys(%look-for);

my $previous-count = 0;

while $previous-count != +%look-for {
$previous-count = +%look-for;
for $step-data.entities.kv -> $index, $object {
if $object ~~ ISO_10303_21::Record {
for $object.entity_instances -> $reference {
if %look-for{$reference} {
%look-for{$index} = 1;
}
}
} else {
for @($object) -> $object {
for $object.entity_instances -> $reference {
if %look-for{$reference} {
%look-for{$index} = 1;
}
}
}
}
}
print-sorted-keys(%look-for);
}

}

0 comments on commit d65de09

Please sign in to comment.