SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Old RedHat 7.X perl-Language-Basic-1.44-8.i386.rpm

Language::Basic::Expression

Section: User Contributed Perl Documentation (3)
Updated: perl v5.6.0
Index 

NAME

Language::Basic::Expression - Package to handle string, numeric, andboolean expressions.  

SYNOPSIS

See the Language::Basic manpage for the overview of how the Language::Basic moduleworks. This pod page is more technical.

    # Given an LB::Token::Group, create an expression I<and> parse it    my $exp = new LB::Expression::Arithmetic $token_group;    # What's the value of the expression?    print $exp->evaluate;    # Perl equivalent of the BASIC expression    print $exp->output_perl;
Expressions are basically the building blocks of Statements, in that everyBASIC statement is made up of keywords (like GOTO, TO, STEP) and expressions.So expressions include not just the standard arithmetic and boolean expressions(like 1 + 2), but also lvalues (scalar variables or arrays), functions, andconstants. See the Language::Basic::Syntax manpage for details on the way expressionsare built. 

DESCRIPTION

BASIC expressions are represented by various objects of subclasses ofLanguage::Basic::Expression. Most LB::Expressions are in turn made up of otherLB::Expressions. For example an LBE::Arithmetic may be made up of twoLBE::Multiplicative and a ``plus''. ``Atoms'' (indivisible LBE's) includethings like LBE::Constants and LBE::Lvalues (variables). 

The LBE hierarchy

A bunch of LBE subclasses represent various kinds of BASIC expressions.These subclasses closely follow the BASIC syntax diagram.

Expressions can be classified in two ways, which are sort of vertical andhorizontal. One classification method is what subexpressions (if any) anexpression is made of. For example, an Arith. Exp. is made up of one or moreMult. Exps. connected by plus or minus signs, while a Mult. Exp. is made up ofone or more Unary Exps. This is a hierarchical (or vertical) distinction,important for building up the tree of objects that represent a BASICexpression.

(Note that not all levels in the hierarchy have to be filled. We don'tbother making an Arith. Exp. which contains just one Mult. Exp. which containsjust one Unary Exp. Instead, we just use the Unary Exp. itself (when it'ssafe to do so!)

The second way of classifying expressions is by their return type. A StringExp. is a string constant, a string variable, a string function, or some otherexpression whose value when evaluated will be a string. A Numeric Exp.evaluates to a number, and a Boolean to a True or False value. Thisdistinction is important for typechecking and finding syntax errors in BASICcode. (Note that in BASIC --- unlike Perl or C --- you can't ``cast'' a booleanvalue into an integer or string. This actually makes parsing more difficult.)

Some expressions don't exactly fit any of these distinctions. For example, anArglist evaluates to a list of expressions, each of which may be Numeric orBoolean. 

subclass methods

Each subclass has (at least) three methods:
new
The ``new'' method takes a class and a Token::Group (and possibly some otherargs). It eats one or more Tokens from it, parsing them, creating a new objectof that class I, and setting various fields in that object, which it returns.If the tokens don't match the class, ``new'' returns undef.

If an expression contains just one subexpression often we'll just return thesubexpression. So if an Arith. Exp. contains just one Mult. Exp., we'll justreturn the LBE::Multiplicative object and not an LBE::Arithmetic object.

evaluate
Actually calculates the value of the expression. For a stringor numeric constant or variable, that just means taking the stored valueof that object. For other Expressions, you actually need to do math.
output_perl
Gives a string with the Perl equivalent to a BASIC expression. ``1+2'' isconverted to ``1+2'', but ``A'' becomes ``$a'', ``A$'' becomes ``$a_str'', andfunction calls may be even more complicated.
 

LBE subclasses

The hierarchical list of subclasses follows:
Arithmetic
An arithmetic expression is a set of multiplicative expressions connected byplus or minus signs. (String expressions can only be connected by plus,which is the BASIC concatenation operator.)
Multiplicative
a set of unary expressions connected by '*' or '/'.
Unary
a variable, a function, a string or numeric constant, or an arithmeticexpression in parentheses, potentially with a unary minus sign.
Constant
a string or numeric constant, like ``17'' or 32.4
Lvalue
a settable expression: a variable, X, or one cell in an array, A(17,Q). The``variable'' method returns the actual LB::Variable::Scalar object referenced bythis Lvalue.
Function
Either an Intrinsic or a User-Defined function.
Arglist
a list of arguments to an array or function
Logical_Or
a set of Logical_And expressions connected by ``OR''
Logical_And
a set of Relational expressions connected by ``AND''
Relational
A relational expression, like ``A>B+C'', optionally with a NOT in front of it.


 

Index

NAME
SYNOPSIS
DESCRIPTION
The LBE hierarchy
subclass methods
LBE subclasses

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector