Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't need [] args in AST for dot calls
  • Loading branch information
ingydotnet committed Mar 15, 2013
1 parent 82e8c19 commit b8cc491
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 47 deletions.
5 changes: 0 additions & 5 deletions lib/TestML/Compiler/Lite.pm
Expand Up @@ -108,7 +108,6 @@ sub parse_assertion {
sub parse_expression {
my ($self) = @_;
my $calls = [];
my $dot = 0;

while (not $self->done and $self->peek !~ /^($ENDING|$COMP)$/) {
my $token = $self->pop;
Expand All @@ -124,9 +123,6 @@ sub parse_expression {
if (not $self->done and $self->peek eq '(') {
$call->{args} = $self->parse_args;
}
elsif ($dot) {
$call->{args} = [];
}
push @$calls, $call;
}
elsif ($token =~ /^$POINT/) {
Expand All @@ -139,7 +135,6 @@ sub parse_expression {
}
if (not $self->done and $self->peek eq '.') {
$self->pop;
$dot = 1;
}
}
return @$calls == 1
Expand Down
10 changes: 0 additions & 10 deletions lib/TestML/Compiler/Pegex/AST.pm
Expand Up @@ -6,7 +6,6 @@ use TestML::Runtime;

has points => [];
has function => sub { TestML::Function->new };
has dot => 0;

# sub final {
# my ($self, $match, $top) = @_;
Expand Down Expand Up @@ -58,7 +57,6 @@ sub got_code_expression {
my $call = $_->[0]; #->{call_call}[0][0];
push @$calls, $call;
}
$self->{dot} = 0;
return $calls->[0] if @$calls == 1;
return TestML::Expression->new(
calls => $calls,
Expand Down Expand Up @@ -139,16 +137,12 @@ sub got_function_object {
sub got_call_name {
my ($self, $name) = @_;
my $call = TestML::Call->new(name => $name);
$call->{dot} = $self->dot;
$self->{dot} = 0;
return $call;
}

sub got_call_object {
my ($self, $object) = @_;
my $call = $object->[0];
my $dot = delete $call->{dot};
$self->{dot} = 0;
my $args = $object->[1][-1];
if ($args) {
$args = [
Expand All @@ -162,9 +156,6 @@ sub got_call_object {
];
$call->args($args)
}
elsif ($dot) {
$call->args([]);
}
return $call;
}

Expand All @@ -175,7 +166,6 @@ sub got_call_argument_list {

sub got_call_indicator {
my ($self) = @_;
$self->{dot} = 1;
return;
}

Expand Down
5 changes: 3 additions & 2 deletions lib/TestML/Runtime.pm
Expand Up @@ -154,7 +154,8 @@ sub run_call {
if ($callable->isa('TestML::Object')) {
return $callable;
}
return $callable unless defined $call->args;
return $callable unless $call->args or defined $context;
$call->{args} ||= [];
my $args = [map $self->run_expression($_), @{$call->args}];
unshift @$args, $context if $context;
if ($callable->isa('TestML::Native')) {
Expand Down Expand Up @@ -198,7 +199,7 @@ sub run_native {
};
if ($@) {
$self->{error} = $@;
return;
return TestML::None->new;
}
elsif ($value->isa('TestML::Object')) {
return $value;
Expand Down
1 change: 0 additions & 1 deletion t/ast/arguments.tml
Expand Up @@ -62,7 +62,6 @@ statements:
name: else
- !!perl/hash:TestML::Call
name: uppercase
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Point
Expand Down
5 changes: 0 additions & 5 deletions t/ast/basic.tml
Expand Up @@ -22,7 +22,6 @@ statements:
name: text
- !!perl/hash:TestML::Call
name: uppercase
args: []
points:
- text
- upper
Expand All @@ -37,7 +36,6 @@ statements:
name: text
- !!perl/hash:TestML::Call
name: lowercase
args: []
points:
- text
- lower
Expand All @@ -49,18 +47,15 @@ statements:
name: upper
- !!perl/hash:TestML::Call
name: lowercase
args: []
- !!perl/hash:TestML::Call
name: uppercase
args: []
name: EQ
expr: !!perl/hash:TestML::Expression
calls:
- !!perl/hash:TestML::Point
name: lower
- !!perl/hash:TestML::Call
name: uppercase
args: []
points:
- lower
- upper
Expand Down
1 change: 0 additions & 1 deletion t/ast/dataless.tml
Expand Up @@ -30,7 +30,6 @@ statements:
value: bar
- !!perl/hash:TestML::Call
name: Str
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand Down
3 changes: 0 additions & 3 deletions t/ast/exceptions.tml
Expand Up @@ -18,10 +18,8 @@ statements:
name: error
- !!perl/hash:TestML::Call
name: NonExistingMethod
args: []
- !!perl/hash:TestML::Call
name: Catch
args: []
assert: !!perl/hash:TestML::Assertion
name: HAS
expr: !!perl/hash:TestML::Point
Expand All @@ -43,7 +41,6 @@ statements:
name: message
- !!perl/hash:TestML::Call
name: Catch
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Call
Expand Down
4 changes: 0 additions & 4 deletions t/ast/function.tml
Expand Up @@ -48,7 +48,6 @@ statements:
name: c
- !!perl/hash:TestML::Call
name: Join
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Call
Expand Down Expand Up @@ -95,15 +94,13 @@ statements:
name: List
- !!perl/hash:TestML::Call
name: Join
args: []
- !!perl/hash:TestML::Statement
expr: !!perl/hash:TestML::Expression
calls:
- !!perl/hash:TestML::Call
name: test1
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand Down Expand Up @@ -208,7 +205,6 @@ statements:
name: func
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand Down
5 changes: 0 additions & 5 deletions t/ast/truth.tml
Expand Up @@ -26,7 +26,6 @@ statements:
name: False
- !!perl/hash:TestML::Call
name: Not
args: []
- !!perl/hash:TestML::Statement
assert: !!perl/hash:TestML::Assertion
name: OK
Expand All @@ -36,10 +35,8 @@ statements:
name: True
- !!perl/hash:TestML::Call
name: Not
args: []
- !!perl/hash:TestML::Call
name: Not
args: []
- !!perl/hash:TestML::Assignment
name: Label
expr: !!perl/hash:TestML::Str
Expand All @@ -58,7 +55,6 @@ statements:
value: ''
- !!perl/hash:TestML::Call
name: Not
args: []
- !!perl/hash:TestML::Statement
assert: !!perl/hash:TestML::Assertion
name: OK
Expand All @@ -77,7 +73,6 @@ statements:
value: '0'
- !!perl/hash:TestML::Call
name: Not
args: []
- !!perl/hash:TestML::Statement
assert: !!perl/hash:TestML::Assertion
name: OK
Expand Down
11 changes: 0 additions & 11 deletions t/ast/types.tml
Expand Up @@ -19,7 +19,6 @@ statements:
value: Foo
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -31,7 +30,6 @@ statements:
value: '42'
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -43,7 +41,6 @@ statements:
name: True
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -62,7 +59,6 @@ statements:
name: List
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -74,7 +70,6 @@ statements:
statements: []
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -86,7 +81,6 @@ statements:
statements: []
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -102,7 +96,6 @@ statements:
name: s
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -118,7 +111,6 @@ statements:
name: n
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -134,7 +126,6 @@ statements:
name: b
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -151,7 +142,6 @@ statements:
name: l
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand All @@ -167,7 +157,6 @@ statements:
name: f
- !!perl/hash:TestML::Call
name: Type
args: []
assert: !!perl/hash:TestML::Assertion
name: EQ
expr: !!perl/hash:TestML::Str
Expand Down

0 comments on commit b8cc491

Please sign in to comment.