Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - grammar - tweak Apply node
  • Loading branch information
fglock committed Aug 10, 2013
1 parent 8370a18 commit a147cf5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions TODO-perlito5
Expand Up @@ -32,6 +32,10 @@ TODO list for Perlito5

* Parser

-- AST - move the block parameter in sort() to Perlito5::AST::Apply->special_arg, to disambiguate this case:
sort $x 1,2,3 # $x is subroutine reference
sort $x,1,2,3 # $x is list element

-- sort SUBNAME LIST
see Grammar/Map.pm

Expand Down
3 changes: 3 additions & 0 deletions html/perlito5.js
Expand Up @@ -11690,6 +11690,9 @@ return r;
p5make_sub("Perlito5::AST::Apply", "code", function (List__, p5want) {
return (List__.p5aget_hash(0)._hash_.p5hget('code'));
});
p5make_sub("Perlito5::AST::Apply", "special_arg", function (List__, p5want) {
return (List__.p5aget_hash(0)._hash_.p5hget('special_arg'));
});
p5make_sub("Perlito5::AST::Apply", "arguments", function (List__, p5want) {
return (List__.p5aget_hash(0)._hash_.p5hget('arguments'));
});
Expand Down
3 changes: 3 additions & 0 deletions perlito5.pl
Expand Up @@ -8724,6 +8724,9 @@ sub Perlito5::AST::Apply::new {
sub Perlito5::AST::Apply::code {
$_[0]->{ 'code'}
};
sub Perlito5::AST::Apply::special_arg {
$_[0]->{ 'special_arg'}
};
sub Perlito5::AST::Apply::arguments {
$_[0]->{ 'arguments'}
};
Expand Down
7 changes: 4 additions & 3 deletions src5/lib/Perlito5/AST.pm
Expand Up @@ -102,9 +102,10 @@ sub arguments { $_[0]->{arguments} }

package Perlito5::AST::Apply;
sub new { my $class = shift; bless {@_}, $class }
sub code { $_[0]->{code} }
sub arguments { $_[0]->{arguments} }
sub namespace { $_[0]->{namespace} }
sub code { $_[0]->{code} } # print
sub special_arg { $_[0]->{special_arg} } # STDOUT
sub arguments { $_[0]->{arguments} } # 1,2,3
sub namespace { $_[0]->{namespace} } # CORE



Expand Down
5 changes: 3 additions & 2 deletions src5/lib/Perlito5/Grammar/Map.pm
Expand Up @@ -9,6 +9,9 @@ Perlito5::Precedence::add_term( 'sort' => sub { Perlito5::Grammar::Map->term_so

token map_or_grep { 'map' | 'grep' };


# TODO: map ( BLOCK LIST )

token term_map_or_grep {
# Note: this is map-block; map-expr is parsed as a normal subroutine
<map_or_grep> <.Perlito5::Grammar::Space.opt_ws>
Expand All @@ -28,8 +31,6 @@ token term_map_or_grep {
}
};

# TODO: sort SUBNAME
#
# Warning: syntactical care is required when sorting the list
# returned from a function. If you want to sort the list returned
# by the function call "find_records(@key)", you can use:
Expand Down

0 comments on commit a147cf5

Please sign in to comment.