Skip to content

Commit 940e9ea

Browse files
committed
Skeletal grammar, runner tweaks
1 parent a1263e1 commit 940e9ea

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Diff for: 2021/template.raku

+16-6
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,27 @@
66
# https://opensource.org/licenses/MIT.
77
#
88
# https://adventofcode.com/2021/day/__DAY_NUM__
9+
use v6.d;
10+
11+
grammar InputFormat {
12+
rule TOP { .* }
13+
}
14+
15+
class FormatActions {
16+
method TOP($/) { }
17+
}
918

1019
class __CLASS_NAME__ {
1120
has $.input is required;
12-
has $.input-lines = $!input.lines;
21+
has @.input-lines = $!input.lines;
22+
has @.parsed-lines = $!input.lines.map:
23+
{ InputFormat.parse($_, :actions(FormatActions.new)) };
1324

14-
method solve-part1() of Str(Cool) {
25+
method solve-part1( --> Str(Cool)) {
1526
"TODO";
1627
}
1728

18-
method solve-part2() of Str(Cool) {
29+
method solve-part2( --> Str(Cool)) {
1930
"TODO";
2031
}
2132
}
@@ -29,11 +40,10 @@ class RunContext {
2940
my $expected = $.expected«$part» // '';
3041
say "Running __CLASS_NAME__ part $part on $!input-file expecting '$expected'";
3142
my $solver = __CLASS_NAME__.new(:$!input);
32-
my $method = $solver.^find_method("solve-part$part").assuming: $solver;
3343
my $start = now;
34-
my $result = $method();
44+
my $result = $solver."solve-part$part"();
3545
my $end = now;
36-
say $result;
46+
put $result;
3747
"Part $part took %.3fms\n".printf(($end - $start) * 1000);
3848
if $expected {
3949
if $expected eq $result {

0 commit comments

Comments
 (0)