This chapter specifies the lexical structure of Owlet. Owlet programs are written using the ASCII character set.
A comment is text that the compiler ignores but that is useful for programmers. Comments are normally used to embed annotations in the code. The interpreter treats them as white space. Owlet defines two kinds of comments:
/* text */
A traditional comment: all the text from the ASCII characters /* to the ASCII characters */ is ignored (as in C and C++).// text
A single-line comment: all the text from the ASCII characters // to the end of the line is ignored (as in C++).
An atom is the source code representation of a value of a type or the null. There are two types of atoms, atoms and lists. Atoms can be further split into these categories:
- Integers, which can be expressed in decimal or balanced ternary numeral systems. A decimal integer is a sequence of digits that are one of
0123456789
. A balanced ternary integer is preceeded by a suffix0z
, and is a sequence of digits that are one of01N
. - Strings, which are a hash table of ASCII characters combined to produce a run of text. They are circumfixed by the character
"
"quote".
Owlet uses Lisp-style S-expressions in it's syntax. This means that all expressions are either an atom such as foo
, or a list of atoms seperated by whitespace such as (foo 5)
. It is reccomended to put all your code inside a begin statement (see Blocks), like this:
(begin
(print "Hello World")
)
Owlet is a weakly-typed language, which means that variables are not bound to a specific data type.
Owlet v0.2 supports the following types:
Trit
Int
Float
Rat
Table
Tuple
Null
In v0.2 new types can't be added. Functions are represented by a JavaScript object rather than a data type.