Syntax - Pod file describing syntax understood by Language::Basic module
There is no Language::Basic::Syntax module. This is just a pod file describing the syntax that's supported by the Language::Basic module.
Things in italics are objects. Things in boldface are actual strings (reserved words or punctuation). "[]" means optional, "..." means optionally more copies of the same thing, and things between slashes that look like Perl regexps are Perl regexps.
This syntax description probably isn't exactly correct from a computer science standpoint, but the idea is just to show what LB supports.
Line_Num Statement [: Statement ...]
DATA Constant [ , Constant ...]
DIM Var-Name [ Arglist ] [ , Var-Name [ Arglist ] ...]
Arglist must be made up of constant arithmetic expressions.
DEF Func-Name ( Var-Name [ , Var-Name ...] ) = Arith-Exp
Var-Names must be scalar variables.
END
FOR Lvalue = Arith-Exp TO Arith-Exp [ STEP Arith-Exp]
GOTO Arith-Exp
IF Or-Exp THEN Statement [ : Statement ...] [ ELSE Statement [ : Statement ...]]
IF Or-Exp THEN Line_Num [ ELSE Line_Num ]
INPUT [ Str-Const ; ] Lvalue [ , Lvalue ...]
[LET] Lvalue = Arith-Exp
NEXT Lvalue
ON Arith-Exp GOTO/GOSUB Arith-Exp [ , Arith-Exp ...]
PRINT [ Expression [ Print_Sep ] [ Expression [ Print_Sep ] ...] ]
READ Lvalue [ , Lvalue ...]
Comment
Note that, unlike C or Perl, Boolean values cannot be "cast" to non-Boolean (string or numeric) values and vice versa.
By the way, the classes in module Language::Basic::Expression rather closely mimic this syntax description.
Arith-Exp
Or-Exp
Mult-Exp Arith-Op Mult-Exp
String-Exp + String-Exp
Unary-Exp Mult-Op Unary-Exp
- Unary-Exp
(Arith-Exp)
Lvalue
Function
Constant
Var-Name [ Arglist ]
( Expression [ , Expression ...] )
Func-Name Arglist
Str-Const
Num-Const
The Arith-Exp must be made from Str-Exps.
And-Exp [ OR Or-Exp ]
Rel-Exp [ AND And-Exp ]
NOT Rel-Exp
Arith-Exp Rel-Op Arith-Exp
String-Exp Rel-Op String-Exp
( Or-Exp )
Numeric Identifier
String Identifier
/FN[A-Z]\w+/
/[A-Z]\w*/
/[A-Z]\w*\$/
Tokens, or atoms, are indivisible pieces of text making up a BASIC program
(Note: Language::Basic only pays attention to case in string constants.)
/\d+/
REM /.*/
Note that a comment goes all the way to the end of a line. Colons in a comment do not start a new statement.
DATA | DIM | DEF | END | FOR | GOSUB | GOTO | IF | INPUT | LET | NEXT | ON | PRINT | READ | RETURN | THEN | ELSE | TO | STEP
/(\d*)?\.?\d+/
/".*?"/
< | <= | > | >= | = | <>
+ | -
* | /
, | ;
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head2'
To install Language::Basic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::Basic
CPAN shell
perl -MCPAN -e shell install Language::Basic
For more information on module installation, please visit the detailed CPAN module installation guide.