# The SCI Compiler

New with SCICompanion version 3, the compiler supports a syntax (which we’ll call Sierra Script) that is nearly identical to the original script that was used by Sierra.

SCI is an object-oriented language with message passing semantics (like Objective-C or SmallTalk). Syntactically, it looks a lot like LISP (due to the plethora of parentheses).

One difference that will be programmers familiar with C++, C# or java, is that expressions use Prefix notation instead of Infix notation. For instance, to add two numbers together and assign them to a variable in C#, might look like this:

    // C#
    int i = 5 + 6;

But in SCI script it looks like:

    ; SCI
    (= i (+ 5 6))

The topics below describe all the various language features and syntax.

- Differences from SCI Studio syntax
  - Quick guide
  - Identifying a script as being in Sierra Script
  - Enclosing expressions in parentheses
  - Public exports
  - The send keyword
  - and/or operators are now prefix
  - Switch and Switchto
  - Loops
  - Strings
- Classes and instances
- Properties
- Procedures
- Public exports
- Variables
- Variable types
  - Number
  - Boolean
  - String
  - HeapPtr
  - Rect
  - Point
- Comments
- define and enum
- include
  - Message files and polygon files
- use
- Strings
- said strings
  - Some more examples
- Synonyms
- Selectors
- self and super
- return
- Assignment operators
- Arithmetic Operators
  - Addition +
  - Subtraction -
  - Multiplication *
  - Division
  - Modulus mod
  - Increment ++
  - Decrement –
- Bitwise operators
  - Bitwise AND: &
  - Bitwise OR: |
  - Bitwise exclusive OR: ^
  - Bitwise shift left: <<
  - Bitwise shift right: >>
  - Binary NOT: ~
- Relational operators
  - Equal: ==
  - Not equal: !=
  - Less than and greater than operators
- Other operators
  - not
  - -
- Conditional expressions
- if statements
- cond statements
- switch statement
- switchto statement
- while statement
- repeat statement
- for loop
- break and breakif statements
- continue and contIf statements
- &rest
- Inline assembly
- Object files
  - The object file format
- Accessing an object’s header