Skip to content

Commit

Permalink
Merge branch 'master' of github.com:colomon/perl6-ISO_10303-21
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Jun 15, 2013
2 parents 45d02a9 + 4c136d4 commit e07e736
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions bin/step-scan-for-trimmed-circles.pl
@@ -0,0 +1,44 @@
#!/usr/bin/env perl6

use v6;
use ISO_10303_21::Grammar;

class ScanActions {
has %.entities-to-check;
has %.circles;

method simple_entity_instance($/) {
given $<simple_record><keyword> {
when "CIRCLE" { %.circles{~$<entity_instance_name>} = 1; }
when "TRIMMED_CURVE" {
my @parameters = $<simple_record><parameter_list>[0]<parameter>;
@parameters.shift if ~@parameters[0].substr(0, 1) eq "'";
my $link = ~@parameters[0];
my $trim1 = ~@parameters[1];
my $trim2 = ~@parameters[2];
my $bool = ~@parameters[3];
say "TRIMMED_CURVE: $link, $trim1, $trim2, $bool";
if $bool eq ".F." {
%.entities-to-check{$link} = 1;
}
}
}
}
}

for @*ARGS -> $file {
say "Reading $file";
my $actions = ScanActions.new;
my $file-data = slurp($file);
$file-data .= subst(/"/*" .*? "*/"/, " ", :global);
my $match = ISO_10303_21::LooseGrammar.parse($file-data, :rule<exchange_file>, :$actions);
if $match ~~ Match && $match {
say " read correctly!";
} else {
say " failed!!!!";
}

# say set $actions.entities-to-check;
# say set $actions.circles;
say $actions.entities-to-check (&) $actions.circles;
}

0 comments on commit e07e736

Please sign in to comment.