Permalink
Browse files

Initial commit

  • Loading branch information...
tadzik committed Feb 21, 2011
0 parents commit fc088f43fda0d22921c862a8dcf4c76febbb9fe9
Showing with 551 additions and 0 deletions.
  1. +47 −0 Deprecations.pm
  2. +9 −0 Makefile
  3. +5 −0 README
  4. +465 −0 api.yaml
  5. +25 −0 test.pir
@@ -0,0 +1,47 @@
+class Deprecations;
+
+INIT {
+ pir::load_bytecode("YAML/Tiny.pbc");
+}
+
+=begin method
+
+method check($file_to_check, $deprecations_file)
+
+Scans $file_to_check for deprecations listen in $deprecations_file,
+probably Parrot's C<api.yaml>. Returns a list of warnings (strings).
+
+=end method
+
+method check_file($file, $yaml) {
+ my $parser := YAML::Tiny.new;
+ my $api := $parser.read_string(slurp($yaml));
+ my @regexes;
+ my @deprecations;
+
+ if $file ~~ / '.pir' $ / {
+ for $api[0] {
+ if $_<detection> && $_<detection><regex>
+ && $_<detection><regex><pir> {
+ @regexes.push($_<detection><regex><pir>);
+ }
+ }
+ }
+
+ my $fh := FileHandle.new;
+ $fh.open($file);
+ my $line := 1;
+ while $fh.readline -> $line {
+ for @regexes -> $regex {
+ if $line ~~ $regex {
+ @deprecations.push("$line: $regex");
+ }
+ }
+ $line++;
+ }
+ $fh.close;
+
+ return @deprecations;
+}
+
+# vim: ft=perl6
@@ -0,0 +1,9 @@
+Deprecations.pbc: Deprecations.pm
+ parrot-nqp --target=pir Deprecations.pm > Deprecations.pir
+ parrot -o Deprecations.pbc Deprecations.pir
+
+run: Deprecations.pbc
+ parrot test.pir test.pir
+
+clean:
+ rm -f Deprecations.pbc Deprecations.pir
5 README
@@ -0,0 +1,5 @@
+A deprecations detector for Parrot, using api.yaml
+It consist of Deprecations.pm, written in nqp, and test.pir, needed for nqp can't handle command-line arguments (afaik)
+Doesn't work due to some weird YAML::Tiny errors, assistance needed
+
+Run 'make run' to try it out
Oops, something went wrong.

0 comments on commit fc088f4

Please sign in to comment.