[svn:parrot] r40051 - in branches/ops_pct/compilers/opsc: ops t
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Jul 13 12:15:04 UTC 2009
Author: bacek
Date: Mon Jul 13 12:15:04 2009
New Revision: 40051
URL: https://trac.parrot.org/parrot/changeset/40051
Log:
[opsc] Initial implementation of parse_ops_file
Modified:
branches/ops_pct/compilers/opsc/ops/oplib.pm
branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t
Modified: branches/ops_pct/compilers/opsc/ops/oplib.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/ops/oplib.pm Mon Jul 13 12:14:32 2009 (r40050)
+++ branches/ops_pct/compilers/opsc/ops/oplib.pm Mon Jul 13 12:15:04 2009 (r40051)
@@ -42,7 +42,7 @@
method BUILD(*%args) {
my @files := %args<files>;
- if !+ at files {
+ if + at files == 0 {
die("We need some files!")
}
self<files> := @files;
@@ -60,12 +60,25 @@
method parse_ops() {
for self.files() {
- self<ops>.push(self.parse_ops_file($_));
+ for @(self.parse_ops_file($_)) {
+ self<ops>.push($_);
+ }
}
}
method parse_ops_file($file) {
- <>;
+ my $parser := self._get_compiler();
+ my $buffer := slurp($file);
+ my $past := $parser.compile($buffer, :target('past'));
+ #_dumper($past);
+ #say($file ~ ' ' ~ +@($past<ops>));
+ $past<ops>;
+}
+
+method _get_compiler() {
+ PIR q<
+ %r = compreg 'Ops'
+ >;
}
method ops() {
Modified: branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t Mon Jul 13 12:14:32 2009 (r40050)
+++ branches/ops_pct/compilers/opsc/t/04-oplib_parse_ops.t Mon Jul 13 12:15:04 2009 (r40051)
@@ -6,15 +6,16 @@
my @files := qw{
- src/ops/core.ops
- src/ops/math.ops
+ ../../src/ops/core.ops
+ ../../src/ops/math.ops
};
my $lib := Ops::OpLib.new.BUILD(:files(@files));
$lib.parse_ops();
-# Not a real number. But I'll adjust it soon.
-ok(+($lib.ops) == 42, "ops file parsed");
+# 86 core
+# 116 math
+ok(+($lib.ops) == 86 + 116, "ops file parsed");
# vim: expandtab shiftwidth=4 ft=perl6:
More information about the parrot-commits
mailing list