NAME
Parrot::PIR::Formatter - Given ugly PIR, format it nicely.
SYNOPSIS
use Parrot::PIR::Formatter;
DESCRIPTION
Primarily intended to be used by pirtidy.pl
. Given some ugly PIR, format it nicely.
SUBROUTINES/METHODS
- $obj =
new([code])
-
Returns
$obj
as a new instance. $obj-
add_pir($code, $code, ...)>-
Add more pir to be processed.
$code = $obj-
get_formatted()>-
Return the nicely formatted code for the raw PIR that's been provided.
Many things to muck with line could be done here:
o remove extraneous spaces. o add in "proper" spacing (after commas, etc.) o heredocs could be treated as blocks to set them off visually. o could remove/add explicit declarations of string type o could convert double to single quotes when possible. o could convert strings with embedded newlines to heredocs.
Things that might ease deprecation, but probably won't get done until after these items are already deprecated.
o could fixup Pmc vs. .Pmc o could undo usage of '<reg> = opcode' syntax where that syntax will eventually be prohibited.
Or not. =-)
BUGS AND LIMITATIONS
Does not play well with heredocs. Should arguably be part of IMCC, which already knows how to parse PIR.