Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Perlito5 - grammar - the "format" statement - use proper assignment
  • Loading branch information
fglock committed Sep 16, 2013
1 parent 4b438fb commit 9f36ffc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 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::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', 'value', v_placeholder), 1)), 0)));
(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)));
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::Decl->new('decl', 'FORMAT', 'type', undef(), 'var', Perlito5::AST::Var->new('name', Perlito5::Match::flat($MATCH->{'Perlito5::Grammar.full_ident'}), 'namespace', '', 'sigil', 'FORMAT', 'value', $placeholder));
$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]);
1
}))) && ((do {
my $m2 = Perlito5::Grammar::Space->opt_ws($str, $MATCH->{'to'});
Expand Down
26 changes: 17 additions & 9 deletions src5/lib/Perlito5/Grammar/Statement.pm
Expand Up @@ -48,20 +48,28 @@ token stmt_format {
$placeholder->{arguments}[0]{arguments},
'.', # delimiter
];
# "FORMAT format_name = string"
$MATCH->{capture} =
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', # ???
value => $placeholder # TODO - use proper assignment with infix:<=>
),
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 => '', # TODO - split namespace/name
sigil => 'FORMAT', # ???
),
),
$placeholder,
]
);
}
<.Perlito5::Grammar::Space.opt_ws>
'='
# TODO - make sure there are only spaces or comments until the end of the line
<.Perlito5::Grammar::Space.ws> # this will read the 'here-doc' we are expecting
};

Expand Down

0 comments on commit 9f36ffc

Please sign in to comment.