Next: CCL Expressions, Previous: CCL Syntax, Up: CCL [Contents][Index]
The SXEmacs Code Conversion Language provides the following statement types: set, if, branch, loop, repeat, break, read, write, call, and end.
The set statement has three variants with the syntaxes
‘(reg = expression)’,
‘(reg assignment_operator expression)’, and
‘integer’. The assignment operator variation of the
set statement works the same way as the corresponding C expression
statement does. The assignment operators are +=
, -=
,
*=
, /=
, %=
, &=
, |=
, ^=
,
<<=
, and >>=
, and they have the same meanings as in C. A
"naked integer" integer is equivalent to a set statement of
the form (r0 = integer)
.
The read statement takes one or more registers as arguments. It reads one byte (a C char) from the input into each register in turn.
The write takes several forms. In the form ‘(write reg ...)’ it takes one or more registers as arguments and writes each in turn to the output. The integer in a register (interpreted as an Emchar) is encoded to multibyte form (ie, Bufbytes) and written to the current output buffer. If it is less than 256, it is written as is. The forms ‘(write expression)’ and ‘(write integer)’ are treated analogously. The form ‘(write string)’ writes the constant string to the output. A "naked string" ‘string’ is equivalent to the statement ‘(write string)’. The form ‘(write reg array)’ writes the regth element of the array to the output.
The if statement takes an expression, a CCL block, and an optional second CCL block as arguments. If the expression evaluates to non-zero, the first CCL block is executed. Otherwise, if there is a second CCL block, it is executed.
The read-if variant of the if statement takes an
expression, a CCL block, and an optional second CCL
block as arguments. The expression must have the form
(reg operator operand)
(where operand is
a register or an integer). The read-if
statement first reads
from the input into the first register operand in the expression,
then conditionally executes a CCL block just as the if
statement
does.
The branch statement takes an expression and one or more CCL
blocks as arguments. The CCL blocks are treated as a zero-indexed
array, and the branch
statement uses the expression as the
index of the CCL block to execute. Null CCL blocks may be used as
no-ops, continuing execution with the statement following the
branch
statement in the containing CCL block. Out-of-range
values for the expression are also treated as no-ops.
The read-branch variant of the branch statement takes an
register, a CCL block, and an optional second CCL
block as arguments. The read-branch
statement first reads from
the input into the register, then conditionally executes a CCL
block just as the branch
statement does.
The loop statement creates a block with an implied jump from the
end of the block back to its head. The loop is exited on a break
statement, and continued without executing the tail by a repeat
statement.
The break statement, written ‘(break)’, terminates the current loop and continues with the next statement in the current block.
The repeat statement has three variants, repeat
,
write-repeat
, and write-read-repeat
. Each continues the
current loop from its head, possibly after performing I/O.
repeat
takes no arguments and does no I/O before jumping.
write-repeat
takes a single argument (a register, an
integer, or a string), writes it to the output, then jumps.
write-read-repeat
takes one or two arguments. The first must
be a register. The second may be an integer or an array; if absent, it
is implicitly set to the first (register) argument.
write-read-repeat
writes its second argument to the output, then
reads from the input into the register, and finally jumps. See the
write
and read
statements for the semantics of the I/O
operations for each type of argument.
The call statement, written ‘(call ccl-program-name)’, executes a CCL program as a subroutine. It does not return a value to the caller, but can modify the register status.
The end statement, written ‘(end)’, terminates the CCL program successfully, and returns to caller (which may be a CCL program). It does not alter the status of the registers.
Next: CCL Expressions, Previous: CCL Syntax, Up: CCL [Contents][Index]