What is OpScript?

Opscript is an scripting engine based on Object Pascal. This engine takes advantage of Active Scripting to integrate with Microsoft Windows so it can be used in all the same places Jscript and VBscript can. It is designed from the ground up using C++. The parser was implemented using Bison and Flex (also known as Lex and Yacc).

In previous years, if you wanted to do scripting in Windows that meant using Jscript, VBscript, or even worse, batch files (yuck!) Recent development of other Active Scripting engines (such as Perl, Python, Ruby, Rexx, to name a few) has greatly improved that situation. There are currently no such engines for pascal, however, although there are a few Pascal based scripting engines in existence (most of them are components that can be embedded in Delphi and C++ builder applications.)

I created this engine to add Object Pascal to the Active Scripting repertoire. While many would say Pascal is an ancient language (hey, Cobol is still alive and well, even with a .NET implementation) there are many a delphi programmer that would be more than happy to disagree! Pascal is a relatively easy language to learn (and implement), and yet it is powerful enough to tackle most programming tasks. Starting with Windows 2000 and later versions, almost everything in the operating system is scriptable, which allows admins and developers to automate all kinds of processes. For an example, the C# team at Microsoft uses Active Perl to automate the testing process of the compiler (more here...) and it is also used for setting up source servers.

Here are some of the hosts that OpScript can run under:

  • Internet Explorer
  • ASP pages under IIS
  • WScript Host
  • Activex Scripting Host

Object Pascal

Pascal was originally invented by Professor Niklaus Wirth around 1969, with the first version of the language implemented on the CDC 6000 in 1970. It then went through several standardization committees (including ANSI and ISO) and various drafts until in 1983 a final draft was approved, ISO 7185 (also known as unextended Pascal.)

In 1989 revisions were done to the original ISO 7185 Pascal standard to correct errors and ambiguities. As a result of that work, extensions to the language were introduced and fomalized as Pascal ISO 10206 in 1991 (commonly known as extended pascal). This standard introduced several concepts to the original language, such as:

  • Modules (which are similar to Delphi units)
  • Value Constructors
  • Enhanced string capabilities
  • Complex Numbers

After finalizing these extensions, the standardization group in charge of these changes (X3J9) set out to add object oriented support to Pascal. The result of that work was a technical report, which was released in 1993. It was not a formal standard but rather a set of general guidelines for adding OO support to Pascal.

In 1995 Borland released the first version of Delphi. Delphi's object pascal borrowed some concepts from the technical report, but also introduced many concepts that were not part of that report (and left out many others). Because of the success Delphi has enjoyed, its syntax has become the de facto standard for Pascal Object Orientation.

So to recap there are 4 different variants of Pascal:

  • Unextended Pascal (ISO 7185 )
  • Extended Pascal (ISO 10206)
  • Object Oriented Extensions ( 1993 Draft )
  • Borland Object Pascal.

Where does OpScript fit into this picture? I am hoping to include Extended Pascal, the 1993 OOE draft, as well as the Borland Object Pascal syntax, with some things left out that don't make sense in a scripting language (such as pointers, for example.) Currently, the grammar is able to parse Borland Pascal, though there are several constructs that are not implemented at the interpreter level (such as class construction.) I am also currently working on the grammar, which should eventually go up in the documentation section. Check out the current features to see what's currently implemented.