Skip to content

Commit

Permalink
Make work with latest Pegex refactorings.
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Aug 27, 2012
1 parent 1f000c3 commit 1daa58d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions lib/TestML/Compiler.pm
Expand Up @@ -3,6 +3,7 @@ package TestML::Compiler;
use TestML::Mo;
use TestML::Grammar;
use TestML::AST;
use Pegex::Parser;

has base => ();

Expand All @@ -21,24 +22,26 @@ sub compile {

my ($code, $data) = @$result{qw(code data)};

my $grammar = TestML::Grammar->new(
my $parser = Pegex::Parser->new(
grammar => TestML::Grammar->new,
receiver => TestML::AST->new,
);
$grammar->parse($code, 'code_section')

$parser->parse($code, 'code_section')
or die "Parse TestML code section failed";

$self->fixup_grammar($grammar, $result);
$parser = $self->fixup_grammar($parser, $result);

if (length $data) {
$grammar->parse($data, 'data_section')
$parser->parse($data, 'data_section')
or die "Parse TestML data section failed";
}

if ($result->{DumpAST}) {
XXX($grammar->receiver->function);
XXX($parser->receiver->function);
}

my $function = $grammar->receiver->function;
my $function = $parser->receiver->function;
$function->outer(TestML::Function->new());

return $function;
Expand Down Expand Up @@ -133,14 +136,12 @@ sub preprocess {
}

sub fixup_grammar {
my $self = shift;
my $grammar = shift;
my $hash = shift;
my ($self, $parser, $hash) = @_;

my $namespace = $grammar->receiver->function->namespace;
my $namespace = $parser->receiver->function->namespace;
$namespace->{TestML} = $hash->{TestML};

my $tree = $grammar->tree;
my $tree = $parser->grammar->tree;

my $point_lines = $tree->{point_lines}{'.rgx'};

Expand All @@ -159,6 +160,12 @@ sub fixup_grammar {
}

$tree->{point_lines}{'.rgx'} = qr/$point_lines/;

Pegex::Parser->new(
grammar => $parser->grammar,
receiver => $parser->receiver,
);

}

sub slurp {
Expand Down
2 changes: 1 addition & 1 deletion lib/TestML/Grammar.pm
Expand Up @@ -2,7 +2,7 @@ package TestML::Grammar;
use TestML::Mo;
extends 'Pegex::Grammar';

use constant text => '../testml-pgx/testml.pgx';
use constant file => '../testml-pgx/testml.pgx';

sub make_tree {
{
Expand Down

0 comments on commit 1daa58d

Please sign in to comment.