Skip to content

Commit

Permalink
Use new Pegex
Browse files Browse the repository at this point in the history
  • Loading branch information
ingydotnet committed Aug 25, 2011
1 parent 0160878 commit 799bcae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions lib/TestML/Compiler.pm
Expand Up @@ -141,24 +141,25 @@ sub fixup_grammar {
my $namespace = $grammar->receiver->function->namespace;
$namespace->{TestML} = $hash->{TestML};

$grammar = $grammar->grammar;
my $point_lines = $grammar->{point_lines}{'+re'};
my $tree = $grammar->tree;

my $point_lines = $tree->{point_lines}{'+re'};

my $block_marker = $hash->{BlockMarker};
if ($block_marker) {
$block_marker =~ s/([\$\%\^\*\+\?\|])/\\$1/g;
$grammar->{block_marker}{'+re'} = qr/\G$block_marker/;
$tree->{block_marker}{'+re'} = qr/\G$block_marker/;
$point_lines =~ s/===/$block_marker/;
}

my $point_marker = $hash->{PointMarker};
if ($point_marker) {
$point_marker =~ s/([\$\%\^\*\+\?\|])/\\$1/g;
$grammar->{point_marker}{'+re'} = qr/\G$point_marker/;
$tree->{point_marker}{'+re'} = qr/\G$point_marker/;
$point_lines =~ s/---/$point_marker/;
}

$grammar->{point_lines}{'+re'} = qr/$point_lines/;
$tree->{point_lines}{'+re'} = qr/$point_lines/;
}

sub slurp {
Expand Down
6 changes: 4 additions & 2 deletions lib/TestML/Grammar.pm
@@ -1,7 +1,8 @@
package TestML::Grammar;
use base 'Pegex::Grammar';
# use base 'Pegex::Grammar::Bootstrap';

sub grammar_tree {
sub build_tree {
return +{
'NEVER' => {
'+re' => qr/(?-xism:\G(?!))/
Expand Down Expand Up @@ -473,7 +474,8 @@ sub grammar_tree {
'unit_call' => {
'+all' => [
{
'+not' => 'assertion_call_test'
'+rule' => 'assertion_call_test',
'<' => '!'
},
{
'+rule' => 'call_indicator'
Expand Down
5 changes: 4 additions & 1 deletion src/grammar.pl
@@ -1,3 +1,5 @@
# XXX This code currently depends on too much bootstrapping stuffs.

use lib "../../pegex-pm/lib";
# use Pegex::Compiler;
use Pegex::Compiler::Bootstrap;
Expand All @@ -13,8 +15,9 @@
print <<"...";
package TestML::Grammar;
use base 'Pegex::Grammar';
# use base 'Pegex::Grammar::Bootstrap';
sub grammar_tree {
sub build_tree {
return +$perl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/testml.pgx
Expand Up @@ -42,7 +42,7 @@ code_expression:
<unit_call>*

unit_call:
<!assertion_call_test>
!<assertion_call_test>
<call_indicator>
<code_object>

Expand Down

0 comments on commit 799bcae

Please sign in to comment.