Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - grammar - format() tweak
  • Loading branch information
fglock committed Sep 19, 2013
1 parent 9f2a707 commit 657299a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion html/perlito5.js
Expand Up @@ -2852,7 +2852,7 @@ var p5100 = p5pkg['main'];
var v_placeholder;
v_placeholder = (p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('code', 'list:<.>', 'namespace', '', 'arguments', (new p5ArrayRef(p5list_to_a(p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('code', 'list:<.>', 'namespace', '', 'arguments', (new p5ArrayRef([]))), 1))))), 0));
p5global_array("Perlito5::Grammar::String", "Here_doc").p5push(p5list_to_a((new p5ArrayRef(p5list_to_a('single_quote', (v_placeholder || (v_placeholder = new p5HashRef({})))._hash_.p5hget_array('arguments')._array_.p5aget_hash(0)._hash_.p5hget('arguments'), '.')))));
(v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('capture', (p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('code', 'infix:<=>', 'namespace', '', 'arguments', (new p5ArrayRef(p5list_to_a(p5call(p5pkg["Perlito5::AST::Decl"], "new", p5list_to_a('decl', 'FORMAT', 'type', null, 'var', p5call(p5pkg["Perlito5::AST::Var"], "new", p5list_to_a('name', p5pkg["Perlito5::Match"].flat(p5list_to_a((v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('Perlito5::Grammar.full_ident')), 1), 'namespace', '', 'sigil', 'FORMAT'), 1)), 1), v_placeholder)))), 0)));
(v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hset('capture', (p5call(p5pkg["Perlito5::AST::Apply"], "new", p5list_to_a('code', 'p5:format', 'namespace', '', 'arguments', (new p5ArrayRef(p5list_to_a(p5pkg["Perlito5::Match"].flat(p5list_to_a((v_MATCH || (v_MATCH = new p5HashRef({})))._hash_.p5hget('Perlito5::Grammar.full_ident')), 1), v_placeholder)))), 0)));
return (p5context([1], p5want));
})()], 0) }), function () { return p5context([(function () {
var v_m2;
Expand Down
2 changes: 1 addition & 1 deletion perlito5.pl
Expand Up @@ -999,7 +999,7 @@ sub Perlito5::Grammar::Statement::stmt_format {
$MATCH->{'str'} = $str;
my $placeholder = Perlito5::AST::Apply->new('code', 'list:<.>', 'namespace', '', 'arguments', [Perlito5::AST::Apply->new('code', 'list:<.>', 'namespace', '', 'arguments', [])]);
push(@Perlito5::Grammar::String::Here_doc, ['single_quote', $placeholder->{'arguments'}->[0]->{'arguments'}, '.']);
$MATCH->{'capture'} = Perlito5::AST::Apply->new('code', 'infix:<=>', 'namespace', '', 'arguments', [Perlito5::AST::Decl->new('decl', 'FORMAT', 'type', undef(), 'var', Perlito5::AST::Var->new('name', Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.full_ident'}), 'namespace', '', 'sigil', 'FORMAT')), $placeholder]);
$MATCH->{'capture'} = Perlito5::AST::Apply->new('code', 'p5:format', 'namespace', '', 'arguments', [Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.full_ident'}), $placeholder]);
1
}))) && ((do {
my $m2 = Perlito5::Grammar::Space->opt_ws($str, $MATCH->{'to'});
Expand Down
16 changes: 3 additions & 13 deletions src5/lib/Perlito5/Grammar/Statement.pm
Expand Up @@ -28,8 +28,7 @@ token stmt_format {
| { $MATCH->{'Perlito5::Grammar.full_ident'} = 'STDOUT' }
]
{
# inject a here-doc request
# see Perlito5::Grammar::String
# inject a here-doc request - see Perlito5::Grammar::String
my $placeholder = Perlito5::AST::Apply->new(
code => 'list:<.>',
namespace => '',
Expand All @@ -48,21 +47,12 @@ token stmt_format {
$placeholder->{arguments}[0]{arguments},
'.', # delimiter
];
# "FORMAT format_name = string"
$MATCH->{capture} =
Perlito5::AST::Apply->new(
code => 'infix:<=>',
code => 'p5:format',
namespace => '',
arguments => [
Perlito5::AST::Decl->new(
decl => 'FORMAT',
type => undef,
var => Perlito5::AST::Var->new(
name => Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.full_ident'}),
namespace => '', # TODO - split namespace/name
sigil => 'FORMAT', # ???
),
),
Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.full_ident'}),
$placeholder,
]
);
Expand Down

0 comments on commit 657299a

Please sign in to comment.