LavishScript:Language and Engine Overview

From Lavish Software Wiki
Revision as of 22:28, 18 April 2006 by Lax (talk | contribs)
Jump to navigation Jump to search

Introduction

LavishScript is designed for a mixed, hostile environment. That is, an environment where objects and types of objects may be forcefully removed without notice by an external source. For example, as part of an addon to a game that was not meant to have addons, with scripts to automate gameplay and such. Safety is ensured by discarding object references after use (as each data sequence is closed).

LavishScript is pre-emptively scheduled and also has a concept of atomic code sequences. Pre-emptive scheduling is necessary to allow a script to run "in the background" iteratively while a game plays, as opposed to a purely event-based paradigm, though it is possible to create fully event-driven scripts as well.

LavishScript's structural syntax is derived from C, with statement syntax derived from command-line interpreters.

LavishScript is object-oriented. Each piece of data is an object, and each type of object (object type, also known as data type) may have various operations or other objects associated with it, by containment or otherwise. Object types can be created via script, or in C++. Object types follow a single-inheritance model (though special handling can be used for object types created in C++ to use any sort of inheritance). Object sub-types can be used to create an object that uses another type (compare to C++ templates), such as a collection of strings.

The Language

Preprocessor

LavishScript includes a built-in preprocessor. The preprocessor's job is to take input (generally a file), and apply given transformations (such as word replacements, macros, pre-selection of portions of code, insertion of additional files, and so on), sending the output to the engine for final processing. See the preprocessor page for a complete reference to the LavishScript preprocessor.

Comments

Comments are a method of introducing plain text into code for human readability, and are completely ignored by the script processor. LavishScript supports two types of comments.

ANSI-C Comments

ANSI-C comments begin with /* and end with */. This style of comment may begin and end anywhere without restriction, but may not be nested. For some tips on using ANSI-C comments, see Standards and Style for Coding in ANSI C.

/* This is an ANSI-C Comment */
/********************************
 *                              *
 *          So is this          *
 *                              *
 ********************************/
/*
 * And this
 */

Full-line Comments

Full-line comments begin with a ; as the first non-whitespace character on a line, and end naturally at the end of the line. This style of comment cannot be used in the middle of a line.

; This is a full-line comment
echo hi; This is NOT a full-line comment