Cicada ---> Online Help Docs

Introduction

Cicada script is a simple, interpreted language that interfaces naturally with C and C++. Its goal is to have the best from two worlds: an interactive and portable scripting language, embedded with our C routines that run at the top speed of the machine. We build a Cicada program by compiling the Cicada source files (which are written in C/C++) together with our own C/C++ files. Voilà, this gives us a command-line environment for executing our C routines and managing their data.

For example, suppose we want 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 it would be nice to be able to call our routine from the command line. So we paste our C routine into Cicada, specifically in the source file userfn.c. We then give our sorting routine a name within Cicada, by modifying one of the pre-existing lines in userfn.c.


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

Finally, we update our Makefile and re-compile Cicada.


    user-prompt% make cicada
   

Finally we run Cicada, which brings up a command prompt allowing us to make our list and sort it.


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

And we are done. Of course there are a few details. The syntax should be easy to grasp at a glance -- in fact you can change the default syntax if you want -- but at its heart this language is a bit of an oddball. For example, many Cicada functions will call their own arguments.

The rest of this document explains the Cicada language in more detail three times over: through an extended example (Chapter 2), a textbook-style explanation (Chapters 3 and 4), and a reference section (Chapter 5).


Prev: Table of Contents   Next: Example: neural networks in Cicada


Last update: May 11, 2017

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