Skip to content

Commit

Permalink
Bump CI Rakudo to 2023.04
Browse files Browse the repository at this point in the history
For a working RakuAST implementation.
  • Loading branch information
dwarring committed Sep 20, 2023
1 parent d6f7c21 commit 1a47592
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- windows-latest
raku-version:
- 'latest'
- '2021.12'
- '2023.04'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
24 changes: 7 additions & 17 deletions lib/CSS/Specification/Build.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ my subset Path where Str|IO::Path;
use experimental :rakuast;

#= generate parsing grammar
our proto sub generate(Str $type, Str $name, Path :$input-path?) { * };
our proto sub generate(|) { * };
multi sub generate('grammar', Str $grammar-name, Path :$input-path?) {

my CSS::Specification::Actions $actions .= new;
Expand Down Expand Up @@ -42,31 +42,23 @@ multi sub generate('actions', Str $class-name, Path :$input-path?) {
}

#= generate interface roles.
multi sub generate('interface', Str $role-name, Path :$input-path?) {
multi sub generate('interface', @role-id, Path :$input-path? --> RakuAST::Package:D) {

my CSS::Specification::Actions $actions .= new;
my @defs = load-defs($input-path, $actions);

say qq:to<END-HDR>;
use v6;
# -- DO NOT EDIT --
# generated by: {($*PROGRAM-NAME, @*ARGS.Slip).join: ' '}
unit role {$role-name};
END-HDR

my %prop-refs = $actions.prop-refs;
my %props = $actions.props;
my %rules = $actions.rules;
my RakuAST::Method @methods = generate-raku-interface-methods(%prop-refs, %props, %rules);
my @expression = @methods.map(-> $expression { RakuAST::Statement::Expression.new: :$expression });
my RakuAST::Blockoid $body .= new: RakuAST::StatementList.new(|@expression);
my RakuAST::Name $name .= from-identifier-parts(|$role-name.split('::'));
my RakuAST::Package $package .= new(
my RakuAST::Name $name .= from-identifier-parts(|@role-id);
RakuAST::Package.new(
:declarator<role>,
:$name,
:body(RakuAST::Block.new: :$body),
);
$package.DEPARSE;
}

sub find-edges(%properties, %child-props) {
Expand Down Expand Up @@ -248,12 +240,10 @@ sub generate-raku-interface-methods(%references, %prop-names, %rule-names) {
%unresolved{$_}:delete
for %rule-names.keys;

for %unresolved.keys.sort -> $sym {
say "method {$sym}(\$/) \{ ... \}";
}
%unresolved.keys.sort.map: {
my Str @stubs = %unresolved.keys.sort;
@stubs.map: -> $id {
my RakuAST::Method $method .= new(
name => RakuAST::Name.from-identifier("valign"),
name => RakuAST::Name.from-identifier($id),
signature => RakuAST::Signature.new(
parameters => (
RakuAST::Parameter.new(
Expand Down
16 changes: 8 additions & 8 deletions t/build.t
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env perl6

use Test;
use CSS::Grammar::Test;
use CSS::Grammar::CSS21;
use CSS::Specification::Build;
use lib 't';
use experimental :rakuast;

sub capture($code, $output-path) {
my $*OUT = open $output-path, :w;
Expand All @@ -13,10 +12,11 @@ sub capture($code, $output-path) {
$output-path;
}

my $base-name = 'Test::CSS::Aural::Spec';
my @base-id = qw<Test CSS Aural Spec>;
my $base-name = @base-id.join: '::';
my $grammar-name = $base-name ~ '::Grammar';
my $actions-name = $base-name ~ '::Actions';
my $interface-name = $base-name ~ '::Interface';
my @role-id = @base-id.Slip, 'Interface';

my $input-path = $*SPEC.catfile('examples', 'css21-aural.txt');
my @summary = CSS::Specification::Build::summary( :$input-path );
Expand All @@ -33,10 +33,10 @@ capture({
}, 't/lib/Test/CSS/Aural/Spec/Actions.rakumod');
lives-ok {require ::($actions-name)}, "$actions-name compilation";

capture({
CSS::Specification::Build::generate( 'interface', $interface-name, :$input-path );
}, 't/lib/Test/CSS/Aural/Spec/Interface.rakumod');
lives-ok {require ::($interface-name)}, "$interface-name compilation";
my RakuAST::Package $interface-package = CSS::Specification::Build::generate( 'interface', @role-id, :$input-path );
't/lib/Test/CSS/Aural/Spec/Interface.rakumod'.IO.spurt: $interface-package.DEPARSE;
my $role-name = @role-id.join: '::';
lives-ok {require ::($role-name)}, "$role-name compilation";

dies-ok {require ::("Test::CSS::Aural::BadGrammar")}, 'grammar composition, unimplemented interface - dies';

Expand Down
29 changes: 13 additions & 16 deletions t/lib/Test/CSS/Aural/Spec/Interface.rakumod
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
use v6;
# -- DO NOT EDIT --
# generated by: t/build.t
unit role Test::CSS::Aural::Spec::Interface;

method angle($/) { ... }
method color($/) { ... }
method frequency($/) { ... }
method generic-voice($/) { ... }
method identifier($/) { ... }
method number($/) { ... }
method percentage($/) { ... }
method specific-voice($/) { ... }
method string($/) { ... }
method time($/) { ... }
method uri($/) { ... }
role Test::CSS::Aural::Spec::Interface {
method angle ($/) { ... }
method color ($/) { ... }
method frequency ($/) { ... }
method generic-voice ($/) { ... }
method identifier ($/) { ... }
method number ($/) { ... }
method percentage ($/) { ... }
method specific-voice ($/) { ... }
method string ($/) { ... }
method time ($/) { ... }
method uri ($/) { ... }
}

0 comments on commit 1a47592

Please sign in to comment.