
PFCLScript
Introduction
PFCLScript is a simple scripting language currently implemented in PL/SQL. The project started out as a way to show that it is possible to do extreme programming in PL/SQL. My first language was C and C can be used for system level projects such as writing operating systems like Unix or Windows or to write compilers and interpreters or to create multi-tasking software or virtual machines...
I like PL/SQL and have been programming it for around 32 years since the mid 1990s. I write a lot of PL/SQL and have given away a lot of scripts and free tools written in PL/SQL, many on this site and also with the materials of my training classes. I wanted to show that PL/SQL can also be used to do system level programming and as I said I called it Extreme PL/SQL. I have plans to write even more low level tools/code/things in PL/SQL if and as time allows in addition to what is presented here.
This first project started out as an implementation of an interpreter written in PL/SQL to parse and execute a simple version of the BASIC programming language. As I created the PL/SQL I kept notes of all of the development so that the complete story of the development and design of the language and the interpreter will be added to this site as a set of blogs or chapters of a book even though its not a printed book.
These chapters or articles will be added to this page which will act as an index page for all interpreter and compiler articles and possibly more complex or Extreme PL/SQL. I have also written a VM in PL/SQL and an assembler in PL/SQL and also a compiler written in PL/SQL that generates ASM to be run in the VM.
The final goal is to embed the VM or the interpreter into an existing PL/SQL program so thatb it can be scripted and modified at run time.
Why?
Why did i want to do this project?
As I said I write code in C and one of the things we have done is written parsers for PL/SQL in C using Lex and Yacc for our PL/SQL code security analyser and also for our PL/SQL obfuscator. One part of those applications and also part of our database scanner for Oracle security is the use of the Lua programming language. We write a lot of checks in Lua and we have embedded Lua into our C code. This is a design feature of Lua; to be able to embed the language into your own applications and extend the language to add your own calls to your own code.
This is exactly what I wanted to do with this scripting language. I want to provide a stand alone script language that can be used to extend PL/SQL applications including those in APEX. I want a user of a PL/SQL language based application to be able to extend the application not through screens of settings or parameters or... but be able to do that through scripts. We could use PL/SQL to extend an application BUT this is a risk for security. If we embed a script parser into an application then we limit how the script interacts with the whole application.
This is what we will achieve with this script interface; allow it to be embedded into any PL/SQL application
Article Series
There are three sets of articles that have been written and created by Pete Finnigan and presented here. The first is the articles on the design and creation of the interpreter written in PL/SQL; The second is the articles written on the design and build of a VM, Assembler, Compiler and associated test suites also written in PL/SQL; The third set of articles is covering the embedding of scripts into existing PL/SQL.
There are in fact four sections as there is also a small section listing existing blogs on the subjects of compilers, interpreters, assemblers, virtual machines (VMs) all written in PL/SQL.
Existing Blog Articles
There are a few articles already released that refer to this project. These are listed here and may be extended outside of the main article series - some may not be directly about languages, interpreters or compilers but they are part of the development:
- Adding Scripting Languages to PL/SQL Applications - Part 1 - 30.09.2022
- Can We Add New Language Features to PL/SQL? - 08.05.2024
- Extreme PL/SQL - 25.06.2024
- Can we Add C Style Pointers to PL/SQL? - 28.06.2024
- Extreme PL/SQL - An Interpreter for a Simple Language - 17.07.2024
- Can We Remove IF Statements from PL/SQL? - 26.07.2024
- Write An Interpreter in PL/SQL - Adding More Features - 01.08.2024
- Extreme PL/SQL - Running an Assembly Language Program in PL/SQL - 16.09.2024
- Extreme PL/SQL - Creating a simple programming language interpreter in PL/SQL - 23.09.2024
Articles about the design and development of the Interpreter
Here is the list of articles / chapters for the development of the PFCLScript language and interpreter. As articles are added I will announce on social media. This list is an indication of the articles to come but they may change slightly before release and additional ones could be added:
- Writing an Interpreter in PL/SQL - Part 01 - Pre-Amble
- Writing an Interpreter in PL/SQL - Part 02 - Introduction
- Writing an Interpreter in PL/SQL - Part 03 - Why?
- Writing an Interpreter in PL/SQL - Part 04 - Defining the Initial Language
- Writing an Interpreter in PL/SQL - Part 05 - Expressions
- Writing an Interpreter in PL/SQL - Part 06 - More Expressions
- Writing an Interpreter in PL/SQL - Part 07 - Lexing or Tokenising
- Writing an Interpreter in PL/SQL - Part 08 - Symbol Table and Variables
- Writing an Interpreter in PL/SQL - Part 09 - The Expression Parser, Finally
- Writing an Interpreter in PL/SQL - Part 10 - Define BNF for the Rest of the Language
- Writing an Interpreter in PL/SQL - Part 11 - Implement the Rest of the Language
- Writing an Interpreter in PL/SQL - Part 12 - Debugging the Interpreter and BASIC Code
- Writing an Interpreter in PL/SQL - Part 13 - Loops, Else, Functions and GOTO
- Writing an Interpreter in PL/SQL - Part 14 - Tuning the Interpreter
- Writing an Interpreter in PL/SQL - Part 15 - Sample Programs
- Writing an Interpreter in PL/SQL - Part 16 - Extending IF
- Writing an Interpreter in PL/SQL - Part 17 - Adding Loops
- Writing an Interpreter in PL/SQL - Part 18 - Designing Functions
- Writing an Interpreter in PL/SQL - Part 19 - Variables, Scope and Calling
- Writing an Interpreter in PL/SQL - Part 20 - Tuning the PL/SQL
- Writing an Interpreter in PL/SQL - Part 21 - Implementing Functions
- Writing an Interpreter in PL/SQL - Part 22 - Implementing Libraries
- Writing an Interpreter in PL/SQL - Part 23 - Implementing User Functions
- Writing an Interpreter in PL/SQL - Part 24 - Input and Output
- Writing an Interpreter in PL/SQL - Part 25 - Adding Local Variables
- Writing an Interpreter in PL/SQL - Part 26 - Malloc, Free and Pointers
Articles about the design and development of the VM, ASM and Compiler
Here is the list of articles / chapters for the development of the VM, ASM and compiler for the scipt language:
- Implement a VM in PL/SQL - Part 01 - Define the VM
- Implement a VM in PL/SQL - Part 02 - Implement the VM Package
- Implement a VM in PL/SQL - Part 03 - Testing
- Implement a VM in PL/SQL - Part 04 - Implement Negative Numbers
- Implement a VM in PL/SQL - Part 05 - The Assembler
- Implement a VM in PL/SQL - Part 06 - Testing the Assembler
- Implement a VM in PL/SQL - Part 07 - Assembler Tutorial
- Implement a VM in PL/SQL - Part 08 - Adding a pseudo instruction
Embedding a virtual machine into an existing PL/SQL program
Here is a list of articles/chapters explaining how to embed the virtual machine into existing PL/SQL programs:
- Embed a VM in PL/SQL - Part 01 - Introduction
- Embed a VM in PL/SQL - Part 02 - Design
- Embed a VM in PL/SQL - Part 03 - Example
Future
I plan to do more with this scripting language. The obvious thing is to convert to a compiler and generate ASM and then assemble that into a binary and then provide a virtual machine in PL/SQL to execute that binary. This will allow more Extreme PL/SQL programming but most likely better speed of execution.
NOTE: I reserve the right to release this as a commercial product.... or not....
