A short summary of R1 language

R1 is a typeless, concurrent language. It has static process (the number of process is fixed at compile time, cannot dynamically create a process). It is a single load system (no module, everything is known at compile time) and has no dynamic storage. The method of interprocess communication is symmetric synchronous message passing. The protection of shared resources (which are global data) is via semaphores (by specifying critical regions). Scheduling system is a pre-emptive time-slicing round-robin policy. It provides the following real-time facilities : access to clock, delay, and time-out.

The syntax of R1 is intentionally made to be "like" C language. So that the user who is familiar with C language can read and write R1 easily. Informally, the syntax can be described as following (reserved words are in bold face ) :

// comment
global var-list ;
semaphore sem-list ;
function-name (formal-param-list) { body }
process process-name (formal-param-list) { body }
main ( ) { body }

body composed of sequence of statements :

statements examples
assignmenta = b + 1 ;
if-statementif ( expr ) stmt-true [ else stmt-false ] ;
while-statementwhile ( expr ) stmt ;
return-statementreturn ( expr ) ;
function-call function-name ( actual parameters ) ;
process-callprocess-name ( actual parameters ) ;

where var-list is the list of variable name separated by ",", sem-list is similar (but semaphores are special variables), formal-param-list is the usual formal parameter list of a function declaration and body is a usual sequence of statements.

A program is composed of declarations and a main. There are four types of declaration : global variable declaration, semaphore declaration, function declaration, and process declaration. There are several types of statements : assignment statement, flow-control if and while, and some additional function for concurrent processing. Operators are basic operators such as + - * / etc. including addressing operators '*' (dereference) and '&' (address). The scalar data is basically a word (which can be 16 bits or 32 bits depended on the architecture of the target hardware) with no type, so all operators can be applied indiscriminately (this is both good and bad). Only structured data is a one dimensional array of words. Global variables must be declared. Local variables are automatically declared and they are lexical-scoped. Local variables appear in the formal parameter list and can not be an array variable. (Note : the form of intermediate code will be different between 16 bits and 32 bits system.)

An array variable is index by 0..max-1 ( with the syntax array-name[index] ) when max is the size of array (declared in global declaration). The value stored in a variable can be any type : character, integer or pointer. There are two operators for accessing a variable indirectly, * (dereference) and & (address) (both has the meaning similar to the same operators in C language). These two operators are used to pass parameters "by reference" (same as using "var" in formal parameter declaration in Pascal or '*' in C).