Adept PLC Technical

Technical Info

PLC is divided into 2 parts, the compiler and the executor. The compiler parses text into tokens according to the rules setup up in the language module. Each separate routine has its own environment, providing local variable scope. The executor begins execution with the routine specified, and stops when the routine returns control. If any expressions exist outside of a routine, in the header of a source file, they are always executed BEFORE any other execution. This allows for initialization of global variables.

Note: The PLC library uses 8 byte structure alignment so make sure your compiler is set the same.

Language plugins provide details and code for operators, keywords, symbols, and other language elements. A language plugin works in conjunction with the separate, modular Data Type library. The complete source code to the C language plugin and an example project are included with the freeware PLC library.

PLC was written entirely in Visual C for Windows.


There are a few limitations to the PLC library, but with PLC's modularity so you can create features like these after obtaining the PLC Pro source code.
  • Variables and routines may not be declared; a variable's type is determined automatically when an assignment first takes place
  • There are no structures, arrays, or pointers
  • Creating a Language

    To create a language you need to first set up data structures for common strings, keywords, and operators (about 200 lines of code). These are all used in the compilation process. You also need a routine to handle the behavior of keywords during execution, and a routine to define the behavior of operators on different data types during execution (about 300 lines of code).

    The easiest way to learn how to create a language is by example. Examine the source code for the C language module &"PLC_C.*". The operators work for most languages, so you may find it easiest to copy this file and modify it to match the requirements of the language you are creating.