Yazoo ---> Online Help Docs

Introduction

This document describes "Yazoo": a simple scripting language for controlling C or C++ routines or for embedding into a larger application. Our exposition can be divided into three parts. In the first part, consisting of Chapters 2 through the beginning of 3, we introduce the use of Yazoo by way of example. The bulk of Chapters 3 and 4 constitutes a more topical discussion of the scripting component, which aims more at being pedagogical than systematic. A reference section comes at the end. The goal is to get the user up to speed with as little reading as possible.

Choosing an appropriate programming language for a given task involves a number of tradeoffs. High-level languages tend to be intuitive and powerful; low-level languages are efficient and can control basic machine functions. Interpreted languages can be made interactive and machine-independent, whereas a compiled language protects source code and executes much more quickly.

Yazoo tries to borrow the best from both worlds. It is a basic high-level, interpreted scripting language that can be fleshed out with the user's own C or C++ routines, which can then be run from script files or through an interactive command prompt. Since the external C code must be incorporated into Yazoo at compile-time, Yazoo is provided as a set of source files rather than an executable. To embed our own routines we simply reference them in one of Yazoo's own source files, re-compile Yazoo -- and voilà: we have an environment for executing these routines and managing their data.

For example, suppose we wish to write a program to alphabetize a list of names. It's a large list and will take quite a while to process, so we opt to write the sorting routine in C.


    int SortPhoneBook(int argc, char **argv)    // format explained later
    {
       ...
    }
   

Speed is not critical for the rest of the job, but the flexibility to call our routine from the command line in a manner of our choosing may be desirable. So we paste the above routine into Yazoo, specifically in the source file userfn.c. We then give our sorting routine a name within Yazoo, by modifying one of the pre-existing lines in userfn.c.


    UserFunction UserFunctionSet[] = { { "DoSort", &SortPhoneBook } };
   

Finally, we re-compile Yazoo.


    user-prompt% make yazoo
   

At this point we can make our list and sort it from Yazoo's own command prompt.


    > ListUSA := load("AllUSA.txt")
    > call("DoSort", ListUSA)
    > save("/Documents/SortedList.txt", ListUSA)
   

And we are done. Of course this example begs some elaboration, which hopefully the following sections will adequately provide.


Prev: Table of Contents   Next: Embedding C/C++ into Yazoo: A Neural Network Tutorial


Last update: July 28, 2013

Get Yazoo scripting language at SourceForge.net. Fast, secure and Free Open Source software downloads