'\" te .\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14) .\" .\" Standard preamble: .\" ======================================================================== .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. \*(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- .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\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" 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 "XS::APItest::KeywordRPN 3" .TH XS::APItest::KeywordRPN 3 "2012-11-03" "perl v5.12.5" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XS::APItest::KeywordRPN \- write arithmetic expressions in RPN .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XS::APItest::KeywordRPN qw(rpn calcrpn); \& \& $triangle = rpn($n $n 1 + * 2 /); \& \& calcrpn $triangle { $n $n 1 + * 2 / } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module supplies plugged-in keywords, using the new mechanism in Perl 5.11.2, that allow arithmetic to be expressed in reverse Polish notation, in an otherwise Perl program. This module has serious limitations and is not intended for real use: its purpose is only to test the keyword plugin mechanism. For that purpose it is part of the Perl core source distribution, and is not meant to be installed. .SS "\s-1RPN\s0 expression syntax" .IX Subsection "RPN expression syntax" Tokens of an \s-1RPN\s0 expression may be separated by whitespace, but such separation is usually not required. It is required only where unseparated tokens would look like a longer token. For example, \f(CW\*(C`12 34 +\*(C'\fR can be written as \f(CW\*(C`12 34+\*(C'\fR, but not as \f(CW\*(C`1234 +\*(C'\fR. .PP An \s-1RPN\s0 expression may be any of: .ie n .IP "1234" 4 .el .IP "\f(CW1234\fR" 4 .IX Item "1234" A sequence of digits is an unsigned decimal literal number. .ie n .IP "$foo" 4 .el .IP "\f(CW$foo\fR" 4 .IX Item "$foo" An alphanumeric name preceded by dollar sign refers to a Perl scalar variable. Only variables declared with \f(CW\*(C`my\*(C'\fR or \f(CW\*(C`state\*(C'\fR are supported. If the variable's value is not a native integer, it will be converted to an integer, by Perl's usual mechanisms, at the time it is evaluated. .ie n .IP "\fIA\fR \fIB\fR ""+""" 4 .el .IP "\fIA\fR \fIB\fR \f(CW+\fR" 4 .IX Item "A B +" Sum of \fIA\fR and \fIB\fR. .ie n .IP "\fIA\fR \fIB\fR ""\-""" 4 .el .IP "\fIA\fR \fIB\fR \f(CW\-\fR" 4 .IX Item "A B -" Difference of \fIA\fR and \fIB\fR, the result of subtracting \fIB\fR from \fIA\fR. .ie n .IP "\fIA\fR \fIB\fR ""*""" 4 .el .IP "\fIA\fR \fIB\fR \f(CW*\fR" 4 .IX Item "A B *" Product of \fIA\fR and \fIB\fR. .ie n .IP "\fIA\fR \fIB\fR ""/""" 4 .el .IP "\fIA\fR \fIB\fR \f(CW/\fR" 4 .IX Item "A B /" Quotient when \fIA\fR is divided by \fIB\fR, rounded towards zero. Division by zero generates an exception. .ie n .IP "\fIA\fR \fIB\fR ""%""" 4 .el .IP "\fIA\fR \fIB\fR \f(CW%\fR" 4 .IX Item "A B %" Remainder when \fIA\fR is divided by \fIB\fR with the quotient rounded towards zero. Division by zero generates an exception. .PP Because the arithmetic operators all have fixed arity and are postfixed, there is no need for operator precedence, nor for a grouping operator to override precedence. This is half of the point of \s-1RPN\s0. .PP An \s-1RPN\s0 expression can also be interpreted in another way, as a sequence of operations on a stack, one operation per token. A literal or variable token pushes a value onto the stack. A binary operator pulls two items off the stack, performs a calculation with them, and pushes the result back onto the stack. The stack starts out empty, and at the end of the expression there must be exactly one value left on the stack. .SH "OPERATORS" .IX Header "OPERATORS" These are the operators being added to the Perl language. .IP "rpn(\s-1EXPRESSION\s0)" 4 .IX Item "rpn(EXPRESSION)" This construct is a Perl expression. \fI\s-1EXPRESSION\s0\fR must be an \s-1RPN\s0 arithmetic expression, as described above. The \s-1RPN\s0 expression is evaluated, and its value is returned as the value of the Perl expression. .IP "calcrpn \s-1VARIABLE\s0 { \s-1EXPRESSION\s0 }" 4 .IX Item "calcrpn VARIABLE { EXPRESSION }" This construct is a complete Perl statement. (No semicolon should follow the closing brace.) \fI\s-1VARIABLE\s0\fR must be a Perl scalar \f(CW\*(C`my\*(C'\fR variable, and \fI\s-1EXPRESSION\s0\fR must be an \s-1RPN\s0 arithmetic expression as described above. The \s-1RPN\s0 expression is evaluated, and its value is assigned to the variable. .SH "BUGS" .IX Header "BUGS" This module only performs arithmetic on native integers, and only a small subset of the arithmetic operations that Perl offers. This is due to it being intended only for demonstration and test purposes. .PP The \s-1RPN\s0 parser is liable to leak memory when a parse error occurs. It doesn't leak on success, however. .\" Oracle has added the ARC stability level to this manual page .SH ATTRIBUTES See .BR attributes (5) for descriptions of the following attributes: .sp .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability runtime/perl-512 = Stability Uncommitted .TE .PP .SH "SEE ALSO" .IX Header "SEE ALSO" Devel::Declare, \&\*(L"PL_keyword_plugin\*(R" in perlapi .SH "AUTHOR" .IX Header "AUTHOR" Andrew Main (Zefram) .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2009 Andrew Main (Zefram) .SH "LICENSE" .IX Header "LICENSE" This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH NOTES .\" Oracle has added source availability information to this manual page This software was built from source available at https://java.net/projects/solaris-userland. The original community source was downloaded from http://www.cpan.org/src/5.0/perl-5.12.5.tar.bz2 Further information about this software can be found on the open source community website at http://www.perl.org/.