Acme-Pythonic
view release on metacpan or search on metacpan
lib/Acme/Pythonic.pm view on Meta::CPAN
# Filter::Simple's identifiers.
normalize_newlines();
my @lines = split /\n/;
return unless @lines;
# If unsure about the ending indentation level, add an extra
# non-indented line to ensure the stack gets emptied.
push @lines, '1; # added by Acme::Pythonic' if $lines[-1] =~ /^(?:\s|\s*#)/;
my ($comment, # comment in the current line, if any
$indent, # indentation of the current logical line
$id_at_sob, # identifier at StartOfBlock, for instance "else", or "eval"
$prev_line_with_code, # previous line with code
$might_be_modifier, # flag: current logical line might be a modifier
$line_with_modifier, # physical line which started the current modifier
$joining, # flag: are we joining lines?
$unbalanced_paren, # flag: we opened a paren that remains to be closed
@stack, # keeps track of indentation stuff
);
@stack = ();
foreach my $line (@lines) {
# We remove any trailing comment so that we can assert stuff
# easily about the end of the code in this line. It is later
lib/Acme/Pythonic.pm view on Meta::CPAN
twice:
do_this_twice()
Nevertheless, the module is not smart enough to handle optional arguments as in
a subroutine with prototype C<&;$>.
=head2 Line joining
As in Python, you can break a logical line in several physical lines
using a backslash at the end:
my $total = total_products() + \
total_delivery() + \
total_taxes()
and in that case the indentation of those additional lines is irrelevant.
Unlike Python, backslashes in a line with a comment are allowed
( run in 0.524 second using v1.01-cache-2.11-cpan-b61123c0432 )