Lape is a scripting engine with a Pascal derived syntax for Free Pascal and Delphi. It's written with speed and a broad platform compatibility in mind. The syntax is backwards compatible with Pascal Script (to a certain degree).
Lape is:
Integer
, Float
, Char
, String
, Boolean
, Variant
, Array
, Record
, Union
, Enum
, Set
, Pointer
, Function pointer
:=
=
<>
>
>=
<
<=
@
^
+
-
*
/
**
AND
OR
DIV
XOR
NOT
IN
SHL
SHR
MOD
If
For
Case
Repeat
While
Try
Label
+=
/=
*=
-=
override
, overload
, static
, deprecated
, experimental
, unimplemented
"
array.SetLength(5)
, array.Pop()
and many moreuses
Classes, Sysutils, lpparser, lpcompiler, lpinterpreter;
const
MyScript = 'function DiceRoll: Int32;' + LineEnding +
'begin' + LineEnding +
' Result := Random(1, 6);' + LineEnding +
'end;' + LineEnding +
'' + LineEnding +
'begin' + LineEnding +
' WriteLn("Rolled a ", DiceRoll());' + LineEnding +
'end.';
var
Compiler: TLapeCompiler;
begin
Randomize();
Compiler := TLapeCompiler.Create(TLapeTokenizerString.Create(MyScript));
try
if Compiler.Compile() then
RunCode(Compiler.Emitter);
except
on E: Exception do
WriteLn(E.ToString());
end;
Compiler.Free();
ReadLn;
end.