trademark tree pattern

CTCL

Turn statement

The turn statement is the natural verb to describe the changing of light patterns. Patterns, groups, blocks and outlets may be turned on, off, etc.

Usage

Here are some samples, assuming that the colors red, blue and green have been declared, and that we have structures (patterns or groups) called "row" and "column":
turn block 1 green           -- green lights in block 1 turned on, nothing off.
turn block 1 green off       -- green lights in block 1 turned on, all others off.
turn block 1 green blue off  -- green and blue lights in block 1 on, all others off.
turn block 1 off             -- turn all lights off in block 1.
turn block 1 off green       -- turn green lights off in block 1, leave others alone.
turn block 1 green off red   -- turn green lights on, red lights off in block 1.
turn block 1                 -- turn all lights on in block 1.
turn block 1 green off red blue -- turn green on, red and blue off in block 1.
turn block i red -- variable counters don't seem to work for blocks. Sorry.
turn row 2 blue              -- turn blue on in every block of group "row 2".
turn column i red            -- turn column i red, i = valid column number.
turn row (5 - j) color_a     -- calculate (5-j), turn that row color_a.
-- and for individual outlets,
turn outlet 5 on             -- kind of obvious, right?
turn outlet 5 off            -- ditto
turn outlet i on             -- where i = valid outlet number Oops! This may not work either
turn bush 3 on               -- where bush 3 is plugged into an outlet
turn bush i on               -- where i = valid bush number
turn bushes off              -- turn off bushes 1, 2, 3, ... in group "bushes"
The general syntax is:
turn structure_or_group [number] color_or_condition
where

How It Works

The structures are placed into a logical tree structure. The tree is housed in an array of integer pairs. The compiler's symbol table maps each name to an array subscript.

There are three types of records in the array. Interior nodes represent structures, patterns or groups. The first integer is the beginning subscript of the structure and the second integer is the ending subscript. The turn statement traverses the tree recursively until it gets to leaf nodes, which can be either blocks or outlets. Blocks and outlets are distinguished by having zero as the second integer. Blocks require further processing to determine which outlet corresponds to the color given, whereas outlets are either "off" or "on". Within the array, blocks are denoted by positive integers, outlets by negative.