1. Introduction
Any time ago i have downloaded from Oasis hintp - .ppo interpreter. It
works but not as good as i expected. So i wrote my own interpreter -
BL. BL is scripting language for Clipper programs. Source code of BL
is pure Clipper and can be compiled with any Clipper 5.x compiler or
FlagShip. BL is simple and rather fast because uses Clipper for
expression evaluation. BL is not a ppo interpreter, it's a different
language.
1.1 Where to get BL
You can download sources here (about 12Kb)
1.2 How to contact author
My name is Sergey Aleshin, i am programmer from Russia
e-mail: asg2@mail.ru
2. Expressions
Expressions in BL same as Clipper expressions except for ++,--,+= etc.
You can't write code blocks like in Clipper but can use 'block'
function: {|x,y,..| f(x,y,...)} must be replaced with
block("f(x,y,...)",{"x","y",...})
In short, you can use any expression that allowed in code block.
3. Program structure
BL program consists from main part - sequence of operators, and
procedure definitions:
<operator0>
...
<operatorN>
proc p1
<operators>
endp
...
proc pN
<operators>
endp
For BL program sample see *.bl files.
Operators delimited by CR+LF (LF on UNIX) so you can write only one
operator per line.
4. Operators
4.1 If
Syntax:
if <expr>
<operators>
[elif <expr>
<operators>]
...
[elif <expr>
<operators>]
[else
<operators>]
endif
4.2 For
Syntax (similar to C):
for [<init_expr>];[<exit_expr>];[<iteration_expr>]
<operators>
next
Sample:
for i:=1;i<=10;i:=i+1
s:=s+i
next
Endless loop:
for ;;
k:=inkey(0)
if k==27
exit
endif
next
4.3 While
Syntax:
while <expr>
<operators>
endw
4.4 Exit
Exits closest For or While.
4.5 Loop
Go to next loop iteration.
4.6 Call
Syntax:
call <BL procedure name>
4.7 Return
Return from any place of BL procedure Syntax:
return [<expr>]
If <expr> is specified, it will evaluated and pushed to stack
4.8 Private
Declare private variables. Syntax:
private var1,...,varN
4.9 Public
Declare public variables. Syntax same as for private.
4.10 Release
Destroy any private or public variables. Syntax:
release var1,...,varN
5. Procedures
Syntax:
proc <procedure name>
[param p1,...,pN]
<operators>
endp
Keyword 'param' can be used to declare procedure parameters.
Parameters for procedure must be placed in stack with push operator,
then procedure can be called with call operator:
push x
push y
call mul
pop result
proc mul
param a,b
return a*b
endp
param p1,...,pN is short representation of
private p1,..,pN
pop pN
...
pop p1
You can use recursion in BL.
6. Using external scripts
You can use loadlib operator to include code from other file to your
script. Syntax:
loadlib <filename.ext>
7. Using BL from Clipper
There are 2 functions, 'progparse' and 'progrun'. PROGPARSE takes the
text of program and produces array with precompiled code. Then code
can be executed with PROGRUN function. See main.prg for example.
8. Licence
Public Domain
9. Known problems
BL stores procedures entry points in static array. So you can't
execute more than one precompiled script if it uses procedures:
progparse clears that array. You'll need to call both progparse and
progrun for such scripts.
10. Future plans
I think that simple visual debugger like cld may be useful.