GARA Primitives

From Mavaball

Jump to: navigation, search

(Note: These are very rough working notes and will change without notice)

This page discusses the primitive data types and operations of the GARA programming language

Contents

GARA Primitive Abstract Model

This section describes the abstract model that describes primitive objects and operations within GARA.

Abstract Primitive types

value

  • bitstring - An ordered sequence of zero or more bits that can each have the value 0 or 1. The first bit is on the left, and the last bit is on the right. The length of a bit string is described by a non-negative integer.
  • int - A mathematical integer that can hold any negative or positive whole number, or zero.
  • uint - A non-negative integer (i.e., unsigned integer)

notation

  • variable - A label (or symbol) that contains a value.

GARA primitive operations

  • assign a value to a variable. Denoted with an arrow <- (greater-than sign '<' with a minus sign '-').

Creation/Destruction

  • Create a new value as a bit string with given value (possibly NULL) and length.

Combining/Separating

  • Create a new value as the concatenate of two bitstring values
  • Create a new value by extracting the left-most N bits (i.e. first bits in bitstring)
  • Create a new value by extracting the right-most N bits (i.e. last bits in bitstring)

Logic Operations

  • Invert a bit string so that zeros become ones and ones become zeros
  • Compute the logical bit-wise AND operation between corresponding bits of two equal-length bit strings
  • Compute the logical bit-wise OR operation between corresponding bits of two equal-length bit strings

Control flow

The program consists of an immutable ordered sequence of instruction symbols. By default, the program flow starts from the first symbol and continues to the next instruction symbol in the sequence. Optionally, a program may branch from a given instruction symbol to any other symbol in the sequence.

The basic branching instruction takes a bit string and branches if any bit in the bit string is not zero. Otherwise, if the string contains all zeros, the program execution continues at the next symbol.

Binary Turing Machine

A binary Turing machine is a Turning machine that uses binary digits (i.e. 0 or 1) as its symbol. Such a machine can compute anything that is computable (i.e., it is universal).

Personal tools