.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "B::Concise 3"
.TH B::Concise 3 "2002-11-24" "perl v5.8.0" "Perl Programmers Reference Guide"
.SH "NAME"
B::Concise \- Walk Perl syntax tree, printing concise info about ops
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& perl -MO=Concise[,OPTIONS] foo.pl
.Ve
.PP
.Vb 1
\& use B::Concise qw(set_style add_callback);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This compiler backend prints the internal OPs of a Perl program's syntax
tree in one of several space-efficient text formats suitable for debugging
the inner workings of perl or other compiler backends. It can print OPs in
the order they appear in the \s-1OP\s0 tree, in the order they will execute, or
in a text approximation to their tree structure, and the format of the
information displyed is customizable. Its function is similar to that of
perl's \fB\-Dx\fR debugging flag or the \fBB::Terse\fR module, but it is more
sophisticated and flexible.
.SH "EXAMPLE"
.IX Header "EXAMPLE"
Here's is a short example of output, using the default formatting
conventions :
.PP
.Vb 11
\& % perl -MO=Concise -e '$a = $b + 42'
\& 8 <@> leave[t1] vKP/REFC ->(end)
\& 1 <0> enter ->2
\& 2 <;> nextstate(main 1 -e:1) v ->3
\& 7 <2> sassign vKS/2 ->8
\& 5 <2> add[t1] sK/2 ->6
\& - <1> ex-rv2sv sK/1 ->4
\& 3 <$> gvsv(*b) s ->4
\& 4 <$> const(IV 42) s ->5
\& - <1> ex-rv2sv sKRM*/1 ->7
\& 6 <$> gvsv(*a) s ->7
.Ve
.PP
Each line corresponds to an operator. Null ops appear as \f(CW\*(C`ex\-opname\*(C'\fR,
where \fIopname\fR is the op that has been optimized away by perl.
.PP
The number on the first row indicates the op's sequence number. It's
given in base 36 by default.
.PP
The symbol between angle brackets indicates the op's type : for example,
<2> is a \s-1BINOP\s0, <@> a \s-1LISTOP\s0, etc. (see \*(L"\s-1OP\s0 class abbreviations\*(R").
.PP
The opname may be followed by op-specific information in parentheses
(e.g. \f(CW\*(C`gvsv(*b)\*(C'\fR), and by targ information in brackets (e.g.
\&\f(CW\*(C`leave[t1]\*(C'\fR).
.PP
Next come the op flags. The common flags are listed below
(\*(L"\s-1OP\s0 flags abbreviations\*(R"). The private flags follow, separated
by a slash. For example, \f(CW\*(C`vKP/REFC\*(C'\fR means that the leave op has
public flags OPf_WANT_VOID, OPf_KIDS, and OPf_PARENS, and the private
flag OPpREFCOUNTED.
.PP
Finally an arrow points to the sequence number of the next op.
.SH "OPTIONS"
.IX Header "OPTIONS"
Arguments that don't start with a hyphen are taken to be the names of
subroutines to print the OPs of; if no such functions are specified, the
main body of the program (outside any subroutines, and not including use'd
or require'd files) is printed.
.IP "\fB\-basic\fR" 4
.IX Item "-basic"
Print OPs in the order they appear in the \s-1OP\s0 tree (a preorder
traversal, starting at the root). The indentation of each \s-1OP\s0 shows its
level in the tree. This mode is the default, so the flag is included
simply for completeness.
.IP "\fB\-exec\fR" 4
.IX Item "-exec"
Print OPs in the order they would normally execute (for the majority
of constructs this is a postorder traversal of the tree, ending at the
root). In most cases the \s-1OP\s0 that usually follows a given \s-1OP\s0 will
appear directly below it; alternate paths are shown by indentation. In
cases like loops when control jumps out of a linear path, a 'goto'
line is generated.
.IP "\fB\-tree\fR" 4
.IX Item "-tree"
Print OPs in a text approximation of a tree, with the root of the tree
at the left and 'left\-to\-right' order of children transformed into
\&'top\-to\-bottom'. Because this mode grows both to the right and down,
it isn't suitable for large programs (unless you have a very wide
terminal).
.IP "\fB\-compact\fR" 4
.IX Item "-compact"
Use a tree format in which the minimum amount of space is used for the
lines connecting nodes (one character in most cases). This squeezes out
a few precious columns of screen real estate.
.IP "\fB\-loose\fR" 4
.IX Item "-loose"
Use a tree format that uses longer edges to separate \s-1OP\s0 nodes. This format
tends to look better than the compact one, especially in \s-1ASCII\s0, and is
the default.
.IP "\fB\-vt\fR" 4
.IX Item "-vt"
Use tree connecting characters drawn from the \s-1VT100\s0 line-drawing set.
This looks better if your terminal supports it.
.IP "\fB\-ascii\fR" 4
.IX Item "-ascii"
Draw the tree with standard \s-1ASCII\s0 characters like \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`|\*(C'\fR. These don't
look as clean as the \s-1VT100\s0 characters, but they'll work with almost any
terminal (or the horizontal scrolling mode of \fIless\fR\|(1)) and are suitable
for text documentation or email. This is the default.
.IP "\fB\-main\fR" 4
.IX Item "-main"
Include the main program in the output, even if subroutines were also
specified.
.IP "\fB\-base\fR\fIn\fR" 4
.IX Item "-basen"
Print \s-1OP\s0 sequence numbers in base \fIn\fR. If \fIn\fR is greater than 10, the
digit for 11 will be 'a', and so on. If \fIn\fR is greater than 36, the digit
for 37 will be 'A', and so on until 62. Values greater than 62 are not
currently supported. The default is 36.
.IP "\fB\-bigendian\fR" 4
.IX Item "-bigendian"
Print sequence numbers with the most significant digit first. This is the
usual convention for Arabic numerals, and the default.
.IP "\fB\-littleendian\fR" 4
.IX Item "-littleendian"
Print seqence numbers with the least significant digit first.
.IP "\fB\-concise\fR" 4
.IX Item "-concise"
Use the author's favorite set of formatting conventions. This is the
default, of course.
.IP "\fB\-terse\fR" 4
.IX Item "-terse"
Use formatting conventions that emulate the ouput of \fBB::Terse\fR. The
basic mode is almost indistinguishable from the real \fBB::Terse\fR, and the
exec mode looks very similar, but is in a more logical order and lacks
curly brackets. \fBB::Terse\fR doesn't have a tree mode, so the tree mode
is only vaguely reminiscient of \fBB::Terse\fR.
.IP "\fB\-linenoise\fR" 4
.IX Item "-linenoise"
Use formatting conventions in which the name of each \s-1OP\s0, rather than being
written out in full, is represented by a one\- or two-character abbreviation.
This is mainly a joke.
.IP "\fB\-debug\fR" 4
.IX Item "-debug"
Use formatting conventions reminiscient of \fBB::Debug\fR; these aren't
very concise at all.
.IP "\fB\-env\fR" 4
.IX Item "-env"
Use formatting conventions read from the environment variables
\&\f(CW\*(C`B_CONCISE_FORMAT\*(C'\fR, \f(CW\*(C`B_CONCISE_GOTO_FORMAT\*(C'\fR, and \f(CW\*(C`B_CONCISE_TREE_FORMAT\*(C'\fR.
.SH "FORMATTING SPECIFICATIONS"
.IX Header "FORMATTING SPECIFICATIONS"
For each general style ('concise', 'terse', 'linenoise', etc.) there are
three specifications: one of how OPs should appear in the basic or exec
modes, one of how 'goto' lines should appear (these occur in the exec
mode only), and one of how nodes should appear in tree mode. Each has the
same format, described below. Any text that doesn't match a special
pattern is copied verbatim.
.IP "\fB(x(\fR\fIexec_text\fR\fB;\fR\fIbasic_text\fR\fB)x)\fR" 4
.IX Item "(x(exec_text;basic_text)x)"
Generates \fIexec_text\fR in exec mode, or \fIbasic_text\fR in basic mode.
.IP "\fB(*(\fR\fItext\fR\fB)*)\fR" 4
.IX Item "(*(text)*)"
Generates one copy of \fItext\fR for each indentation level.
.IP "\fB(*(\fR\fItext1\fR\fB;\fR\fItext2\fR\fB)*)\fR" 4
.IX Item "(*(text1;text2)*)"
Generates one fewer copies of \fItext1\fR than the indentation level, followed
by one copy of \fItext2\fR if the indentation level is more than 0.
.IP "\fB(?(\fR\fItext1\fR\fB#\fR\fIvar\fR\fIText2\fR\fB)?)\fR" 4
.IX Item "(?(text1#varText2)?)"
If the value of \fIvar\fR is true (not empty or zero), generates the
value of \fIvar\fR surrounded by \fItext1\fR and \fIText2\fR, otherwise
nothing.
.IP "\fB#\fR\fIvar\fR" 4
.IX Item "#var"
Generates the value of the variable \fIvar\fR.
.IP "\fB#\fR\fIvar\fR\fIN\fR" 4
.IX Item "#varN"
Generates the value of \fIvar\fR, left jutified to fill \fIN\fR spaces.
.IP "\fB~\fR" 4
.IX Item "~"
Any number of tildes and surrounding whitespace will be collapsed to
a single space.
.PP
The following variables are recognized:
.IP "\fB#addr\fR" 4
.IX Item "#addr"
The address of the \s-1OP\s0, in hexidecimal.
.IP "\fB#arg\fR" 4
.IX Item "#arg"
The OP-specific information of the \s-1OP\s0 (such as the \s-1SV\s0 for an \s-1SVOP\s0, the
non-local exit pointers for a \s-1LOOP\s0, etc.) enclosed in paretheses.
.IP "\fB#class\fR" 4
.IX Item "#class"
The B\-determined class of the \s-1OP\s0, in all caps.
.IP "\fB#classsym\fR" 4
.IX Item "#classsym"
A single symbol abbreviating the class of the \s-1OP\s0.
.IP "\fB#coplabel\fR" 4
.IX Item "#coplabel"
The label of the statement or block the \s-1OP\s0 is the start of, if any.
.IP "\fB#exname\fR" 4
.IX Item "#exname"
The name of the \s-1OP\s0, or 'ex\-foo' if the \s-1OP\s0 is a null that used to be a foo.
.IP "\fB#extarg\fR" 4
.IX Item "#extarg"
The target of the \s-1OP\s0, or nothing for a nulled \s-1OP\s0.
.IP "\fB#firstaddr\fR" 4
.IX Item "#firstaddr"
The address of the \s-1OP\s0's first child, in hexidecimal.
.IP "\fB#flags\fR" 4
.IX Item "#flags"
The \s-1OP\s0's flags, abbreviated as a series of symbols.
.IP "\fB#flagval\fR" 4
.IX Item "#flagval"
The numeric value of the \s-1OP\s0's flags.
.IP "\fB#hyphseq\fR" 4
.IX Item "#hyphseq"
The sequence number of the \s-1OP\s0, or a hyphen if it doesn't have one.
.IP "\fB#label\fR" 4
.IX Item "#label"
\&'\s-1NEXT\s0', '\s-1LAST\s0', or '\s-1REDO\s0' if the \s-1OP\s0 is a target of one of those in exec
mode, or empty otherwise.
.IP "\fB#lastaddr\fR" 4
.IX Item "#lastaddr"
The address of the \s-1OP\s0's last child, in hexidecimal.
.IP "\fB#name\fR" 4
.IX Item "#name"
The \s-1OP\s0's name.
.IP "\fB#NAME\fR" 4
.IX Item "#NAME"
The \s-1OP\s0's name, in all caps.
.IP "\fB#next\fR" 4
.IX Item "#next"
The sequence number of the \s-1OP\s0's next \s-1OP\s0.
.IP "\fB#nextaddr\fR" 4
.IX Item "#nextaddr"
The address of the \s-1OP\s0's next \s-1OP\s0, in hexidecimal.
.IP "\fB#noise\fR" 4
.IX Item "#noise"
The two-character abbreviation for the \s-1OP\s0's name.
.IP "\fB#private\fR" 4
.IX Item "#private"
The \s-1OP\s0's private flags, rendered with abbreviated names if possible.
.IP "\fB#privval\fR" 4
.IX Item "#privval"
The numeric value of the \s-1OP\s0's private flags.
.IP "\fB#seq\fR" 4
.IX Item "#seq"
The sequence number of the \s-1OP\s0.
.IP "\fB#seqnum\fR" 4
.IX Item "#seqnum"
The real sequence number of the \s-1OP\s0, as a regular number and not adjusted
to be relative to the start of the real program. (This will generally be
a fairly large number because all of \fBB::Concise\fR is compiled before
your program is).
.IP "\fB#sibaddr\fR" 4
.IX Item "#sibaddr"
The address of the \s-1OP\s0's next youngest sibling, in hexidecimal.
.IP "\fB#svaddr\fR" 4
.IX Item "#svaddr"
The address of the \s-1OP\s0's \s-1SV\s0, if it has an \s-1SV\s0, in hexidecimal.
.IP "\fB#svclass\fR" 4
.IX Item "#svclass"
The class of the \s-1OP\s0's \s-1SV\s0, if it has one, in all caps (e.g., '\s-1IV\s0').
.IP "\fB#svval\fR" 4
.IX Item "#svval"
The value of the \s-1OP\s0's \s-1SV\s0, if it has one, in a short human-readable format.
.IP "\fB#targ\fR" 4
.IX Item "#targ"
The numeric value of the \s-1OP\s0's targ.
.IP "\fB#targarg\fR" 4
.IX Item "#targarg"
The name of the variable the \s-1OP\s0's targ refers to, if any, otherwise the
letter t followed by the \s-1OP\s0's targ in decimal.
.IP "\fB#targarglife\fR" 4
.IX Item "#targarglife"
Same as \fB#targarg\fR, but followed by the \s-1COP\s0 sequence numbers that delimit
the variable's lifetime (or 'end' for a variable in an open scope) for a
variable.
.IP "\fB#typenum\fR" 4
.IX Item "#typenum"
The numeric value of the \s-1OP\s0's type, in decimal.
.SH "ABBREVIATIONS"
.IX Header "ABBREVIATIONS"
.Sh "\s-1OP\s0 flags abbreviations"
.IX Subsection "OP flags abbreviations"
.Vb 11
\& v OPf_WANT_VOID Want nothing (void context)
\& s OPf_WANT_SCALAR Want single value (scalar context)
\& l OPf_WANT_LIST Want list of any length (list context)
\& K OPf_KIDS There is a firstborn child.
\& P OPf_PARENS This operator was parenthesized.
\& (Or block needs explicit scope entry.)
\& R OPf_REF Certified reference.
\& (Return container, not containee).
\& M OPf_MOD Will modify (lvalue).
\& S OPf_STACKED Some arg is arriving on the stack.
\& * OPf_SPECIAL Do something weird for this op (see op.h)
.Ve
.Sh "\s-1OP\s0 class abbreviations"
.IX Subsection "OP class abbreviations"
.Vb 11
\& 0 OP (aka BASEOP) An OP with no children
\& 1 UNOP An OP with one child
\& 2 BINOP An OP with two children
\& | LOGOP A control branch OP
\& @ LISTOP An OP that could have lots of children
\& / PMOP An OP with a regular expression
\& $ SVOP An OP with an SV
\& " PVOP An OP with a string
\& { LOOP An OP that holds pointers for a loop
\& ; COP An OP that marks the start of a statement
\& # PADOP An OP with a GV on the pad
.Ve
.SH "Using B::Concise outside of the O framework"
.IX Header "Using B::Concise outside of the O framework"
It is possible to extend \fBB::Concise\fR by using it outside of the \fBO\fR
framework and providing new styles and new variables.
.PP
.Vb 11
\& use B::Concise qw(set_style add_callback);
\& set_style($format, $gotofmt, $treefmt);
\& add_callback
\& (
\& sub
\& {
\& my ($h, $op, $level, $format) = @_;
\& $h->{variable} = some_func($op);
\& }
\& );
\& B::Concise::compile(@options)->();
.Ve
.PP
You can specify a style by calling the \fBset_style\fR subroutine. If you
have a new variable in your style, or you want to change the value of an
existing variable, you will need to add a callback to specify the value
for that variable.
.PP
This is done by calling \fBadd_callback\fR passing references to any
callback subroutines. The subroutines are called in the same order as
they are added. Each subroutine is passed four parameters. These are a
reference to a hash, the keys of which are the names of the variables
and the values of which are their values, the op, the level and the
format.
.PP
To define your own variables, simply add them to the hash, or change
existing values if you need to. The level and format are passed in as
references to scalars, but it is unlikely that they will need to be
changed or even used.
.PP
To see the output, call the subroutine returned by \fBcompile\fR in the
same way that \fBO\fR does.
.SH "AUTHOR"
.IX Header "AUTHOR"
Stephen McCamant, \f(CW\*(C`smcc@CSUA.Berkeley.EDU\*(C'\fR
|