Lape
Scripting engine with Pascal-like syntax for FPC and Delphi
Install / Use
/learn @nielsAD/LapeREADME
Lape
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:
- A scripting engine
- A Pascal derived language
- Basetypes:
Integer,Float,Char,String,Boolean,Variant,Array,Record,Union,Enum,Set,Pointer,Function pointer - Operations:
:==<>>>=<<=@^+-*/**ANDORDIVXORNOTINSHLSHRMOD - Constructs:
IfForCaseRepeatWhileTryLabel - Optional C style operators:
+=/=*=-= - Internal and external functions (with support for default params & type methods)
- Internal/external variables and constants (every variable is represented exactly as how it would be by FPC/Delphi)
- Function directives:
override,overload,static,deprecated,experimental,unimplemented - Support for local (nested) declarations. So function can have their own constants/types/variables/functions.
- Operator overloading
- Multiline strings using double quotes
" - Optional array "helpers" such as
array.SetLength(5),array.Pop()and many more
- Basetypes:
- Portable
- Fully written in FPC/Delphi. No need for external libraries.
- Tested with Linux(x64/aarch64), Windows(x86/x64) and Mac OS(x64/aarch64), but supports virtually every platform FPC supports.
- Extensible
- New types can easily be added with specified behaviour for operations.
- Optional foreign function interface which allows native calling of Lape functions and importing of functions without creating wrappers.
- Fast
Simple example of running a script:
- Remember to add unit & include search paths to the lape directory
uses
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.
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
