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 30 years at the time this page is written in 2024. 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. There are plans to write more low level tools/code/things in PL/SQL if and as time allows.
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 can 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 my blog and also links 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. The plan is to convert the interpreter to a compiler that emits assembly language that is itself then assembled into a binary form and then executed in a virtual machine for a self designed CPU. All of this to be written in PL/SQL of course. The interpreter exists and the script language - PFCLScript - is evolving from a simple version of BASIC to a much more rounded language with better control constructs and functions.
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 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
Here is the list of articles / chapters for the development of the PFCLScript language and the development. As articles are added to the blog a link will be added here. This list is an indication of the articles to come but they may change slightly before release and additonal 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 Intial 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 aor 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
Future
I plan to do more with this scripting language. The obvious thing is to convert to a complier 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....