MAN page from Old RedHat 7.X perl-Language-Basic-1.44-8.i386.rpm
Language::Basic::Statement
Section: User Contributed Perl Documentation (3)
Updated: perl v5.6.0
Index NAME
Language::Basic::Statement - Package to handle parsing and implementing single
BASIC statements.
SYNOPSIS
See the Language::Basic manpage for the overview of how the Language::Basic moduleworks. This pod page is more technical.
A Statement is something like 'GOTO 20' or 'PRINT ``HELLO'''. A line ofBASIC code is made up of one or more Statements.
# Create the statement from an LB::Token::Group and # bless it to an LBS::* subclass my $statement = new Language::Basic::Statement $token_group; $statement->parse; # Parse the statement $statement->implement; # Implement the statement
# Return a string containing the Perl equivalent of the statement $str = $statement->output_perl;
DESCRIPTION
Take a program like:
5 LET A = 2
10 IF A >= 3 THEN GOTO 20 ELSE PRINT "IT'S SMALLER"
Line 5 has just one statement. Line 10 actually contains three. The firstis an
IF statement, but the results of the
THEN and the
ELSE are entirestatements in themselves.
Each type of statement in BASIC has an associated LB::Statement class.For example, there's LB::Statement::Let and LB::Statement::If. (But noLB::Statement::Then! Instead the ``then'' field of the LB::Statement::Ifobject will point to another statement. In the above program, it wouldpoint to a LB::Statement::Goto.)
Parsing a line of BASIC starts with removing the line number and lexingthe line, breaking it into Tokens which are held in an LB::Token::Group.LB::Statement::new, refine, and parse, are all called with a Token::Groupargument. These methods gradually ``eat'' their way through the Tokens.
LBS::new simply creates an LBS object. However, it then calls LBS::refine,which looks at the first Token of the command and blesses the object tothe correct LBS::* subclass.
Each LBS subclass then has (at least) the methods parse, implement,and output_perl.
The parse method goes through the text and digests it and sets variousfields in the object, which are used by implement and output_perl. Theimplement method actually implements the BASIC command. Theoutput_perl method returns a string (with ; but not \n at the end) of the Perlequivalent of the BASIC statement.
Index
- NAME
- SYNOPSIS
- DESCRIPTION
This document was created byman2html,using the manual pages.