Wednesday, January 22, 2014

A Little Language

Here I will present the command interface to a program for creating and manipulating objects displayed through computer graphics. Internally, objects are represented as sidedness spaces together with boundaries attached to super-regions representing 2d facets.

In the following, Ca Cb Cc ... represent keys pressed with the control key. F1 F2 ... Fn represent the function keys along the top of the keyboard. Except at the start of a statement, --- represents a subexpression to be evaluated before the containing expression. +++ represents an expression to be parsed but not evaluated. ___ represents a string. abc represents a name. dfe represents a file, directory filename extension. 123 represents an identifier. 012 represents a number. 01 represents a boolean. ... represents repetition. Statements introducing subsequent statements begin with ---. Statements describing commands begin with the command as entered with optional whitespace. The same command may have multiple forms, in which case the statement describing the command begins with each of the forms. For an example of a command with three forms, see the O command.

--- Create objects or parts of objects

O< 012 >
O< 012 012 >
O< < 012 012 > ... > Create space, polytope, or overlap, topologically different from selected.
x Create plane perpendicular to x axis.
y Create plane perpendicular to y axis.
z Create plane perpendicular to z axis.
c Create inflate select object from selected boundaries.
a Add selected facets.
s Subtract selected facets.
d Divide selected facets by new random boundaries.
b Divide selected facets by selected boundaries.
i Create union of selected objects.
j Create intersection of selected objects.
k Create symmetric difference of selected objects.

--- Drag objects or parts of objects to transform them

T Tweak selected.
t Translate selected by drag amount.
R Rotate selected about axis, through pierce point perpendicular to picture plane, by drag amount.
r Rotate selected about axis, through pierce point parallel to picture plane, by drag amount.
X Stretch selected in x dimension by drag amount.
Y Stretch selected in y dimension by drag amount.
Z Scale selected by drag amount.

--- Remove objects or parts of objects

C Remove selected boundaries from selected objects.
m Unshare selected boundaries from selected objects.
o Where possible without changing appearance, combine selected facets, remove selected boundaries, reindex selected objects.

--- Specify objects, object parts, or transformations with entered numbers or identifiers

,{ --- }
,{ --- ... }
,< < 01 ... > ... > Create and select boundaries from sidedness.
.{ --- }
.{ --- ... }
.< 012 ... > Create and select boundary from numbers.
;{ --- }
;{ --- ... }
;< < 123 ... > ... > Create and select object from boundary identifiers.
#{ --- }
#{ --- ... }
#< 012 ... > Transform selected.

--- Return displayed state

@{ --- }
@{ --- ... }
@< 012 ... > Return info about point containers.
${ --- }
${ --- ... }
$< 012 ... > Return info about line pierces.
%{ --- }
%{ --- ... }
%< 012 ... > Return info about plane divides.
W Return selected metrics.
w Return selected identifiers.

--- Select objects or object parts for subsequent commands to operate on

:{ --- }
:{ --- ... }
:< < 123 ... > ... > Set persistent selection from identifiers.
e Toggle whether selected is in persistent selection.
n Deselect from persistent.
u Select to persistent.
Fn Modify selection.

--- Modify behavior of subsequent commands

0{ --- --- }
0< 012 012 >
0{ --- }
0< 012 >
0 Replace mode mask for next command that consumes, push global set and clear mode masks, or pop global masks.
1 Set vertex bit 0x001 in mode mask for next command that consumes.
2 Set edge bit 0x002 in mode mask for next command that consumes.
3 Set face bit 0x004 in mode mask for next command that consumes.
4 Set region bit 0x008 in mode mask for next command that consumes.
5 Set super-region bit 0x010 in mode mask for next command that consumes.
6 Set boundary bit 0x020 in mode mask for next command that consumes.
7 Set object bit 0x040 in mode mask for next command that consumes.
8 Set temporary bit 0x080 in mode mask for next command that consumes.
9 Set tentative bit 0x100 in mode mask for next command that consumes.
Ci Add Cx overload bit 0x200 to mode mask for next command that consumes.
Cj Add Cy overload bit 0x400 to mode mask for next command that consumes.
Ck Add Cz overload bit 0x800 to mode mask for next command that consumes.

--- Ignore except when overloaded

_ Do nothing except consume mode mask.
Cx Do nothing unless overloaded, as by command with Ci mode mask. Issued by Console in mouse click glut callback.
Cy Do nothing unless overloaded, as by command with Cj mode mask. Issued by Console in mouse move glut callback.
Cz Do nothing unless overloaded, as by command with Ck mode mask. Issued by Console in mouse release glut callback.

--- Imply vectors used by subsequent commands

`{ --- }
`{ ---  ... }
`< 012 ... > Find current pierce point from picture plane coordinate, updating temporary selection, coordinate, valid. Issued by Console before Cx.
~{ --- }
~{ --- ... }
~< 012 ... > Find drag point from picture plane coordinate. Issued by Console before Cy and Cz.
Cm{ --- }
Cm( abc ) Change current Layer, updating pierce point, temporary selection, valid.
Cn{ --- }
Cn( abc ) Change current Layer, updating coordinate, valid.
Cu{ --- }
Cu{ --- ... }
Cu< 012 ... > Change current coordinate, updating valid, pierce point, temporary selection.
Cv{ --- }
Cv{ --- ... }
Cv< 012 ... > Change current pierce point, updating temporary selection, coordinate, valid.
Cw{ --- }
Cw{ --- ... }
Cw< 012 ... > Change current drag point.

--- Layer coordinates and mappings onto surfaces

Cl{ --- }
Cl( abc ) Return Layer from Texture, selected objects and facets, poke and scratch.
Co{ --- }
Co{ --- ... }
Co( abc ... ) Display ordered list of Layers.
Cp{ --- }
Cp{ --- ... }
Cp( abc ... ) Restrict Layers according to prominence until they do not overlap.
Cq{ --- }
Cq{ --- ... }
Cq( abc ... ) Extend Layers to their union.
Cr{ --- }
Cr{ --- ... }
Cr( abc ... ) Restrict Layers to their intersection.
Cs{ --- }
Cs{ --- ... }
Cs< 012 ... >
Cs Return ordered list of Layers valid at optional line or current pierce point.
Ct{ --- }
Ct( dfe ) Load and return Texture.

--- Start heuristic to automatically change displayed state

p{ --- }
p( dfe )  Return Heuristic loaded from library.
q{ --- ... }
q( abc ... ) Start Heuristic on selected.

--- Save and restore displayed state

H Redo change to subject.
h Undo change to subject.
L Go to next history branch.
l Go to last history branch.
F{ --- }
F( dfe ) Read subject from file.
f{ --- }
f( dfe ) Save subject to file.
G{ --- }
G( dfe ) Read history from file.
g{ --- }
g( dfe ) Save history to file.

--- Build expressions

" Return text with prepended length.
'{ --- }
'[___] Return text up to terminator.
( abc ... ) Return names.
< 012 ... > Return numbers.
[___] Return text.
{ +++ ... } Return expressions.
+{ --- --- } Add values.
-{ --- --- } Subtract values.
*{ --- --- } Multiply values.
/{ --- --- } Divide values.
\{ --- --- } Return modulus of values.
&{ --- --- } Return and of values.
|{ --- --- } Return or of values.
^{ --- --- } Return exclusive or of values
D{ --- ... } Execute subexpressions, but discard results.
E{ --- ... } Execute subexpressions, and return results in structure.
P Pop from before current frame.
Q{ --- ... } Return elements of subexpressions as multiple results.
S{ --- }
S( abc )
S{ --- --- }
S( abc 012 )
S{ --- --- --- }
S( abc 012 012 )
S{ --- --- --- --- }
S( abc 012 012 abc ) Return size, element, substructure, or copy with range replaced.
Cd{ --- }
Cd( abc ) Return deep copy.

--- Control variables and flow

M{ --- }
M< 012 > Reenter number of nesting levels.
N{ --- }
N< 012 > Break out number of nesting levels.
={ --- --- }
=( abc --- ) Assign value to name.
U{ --- }
U( abc ) Unassign name.
V{ --- }
V( abc ) Return named value.
v{ --- }
v( abc ) Execute named command.

--- Access program state

A Return kernel reference values.
B{ --- }
B( abc ) Set kernel reference values or value chosen by type.
Ce Return new empty Command.

--- Open stream for input and output

!{ --- }
![___] Return Source to pipe commands to Value and from string.
?{ --- }
?[___] Return Source to pipe commands to and from socket.
I{ --- --- }
I( dfe dfe ) Return Source to pipe commands to and from files.
J{ --- }
J[___] Return Source to pipe commands to and from c code.
K{ --- }
K[___] Return Source to pipe commands to and from shell.

--- Replace commands executed by syntax pattern in syntax table

Ca{ --- --- --- }
Ca( abc [___] [___] ) Change command string executed after command associated with pattern in Syntax.
Cb{ --- --- --- }
Cb( abc [___] [___] ) Change command string executed before command associated with pattern in Syntax.
Cc{ --- --- --- }
Cc( abc [___] [___] )
Cc{ --- --- --- --- }
Cc( abc [___] chr 012 ) Change command string or command and mode associated with pattern in Syntax.
Cf{ --- --- --- }

--- Copy and alias portions of value assignments

Cf( abc ( abc ... ) abc )
Cf( abc abc ( abc ... ) ) Copy listed, or all except listed, names from Language.
Cg{ --- --- --- }
Cg( abc ( abc ... ) abc )
Cg( abc abc ( abc ... ) ) Share listed, or all except listed, names with Language (symmetric alias).
Ch{ --- --- --- }
Ch( abc ( abc ... ) abc )
Ch( abc abc ( abc ... ) ) Observe listed, or all except listed, names from Language (asymmetric alias).