About Buy News Guide Ideas
Get a phatIO device here!

Back to Table of Contents

Syntax and Concepts

LIO has similar syntax to lisp but is not lisp. The syntax was chosen due to simplicity in parsing and storing.

LIO is a simple way of executing builtin phatIO functionality, that functionality is executed by an expression wrapped in parenthesis ‘(’ ‘)’ with the name of the function as the first item, and the arguments to the function as the remaining items in the expression:

(function-name arg1 arg2 arg3)

For example, phatIO has the ability to send keyboard data to the host computer (as if someone had typed something at a USB keyboard) using the keyboard function. The following expression sends the arguments “hello ” and “world” to the keyboard function. Which will result in “hello world” being printed (or rather typed to the computer).

(keyboard "hello " "world")

This can be tested by opening “PHATIO/io/run.lio” in a text editor entering the above and saving.

The above is an expression - the keyboard function is passed the two arguments - it then asks the LIO system to evaulate each in turn as a strings and types those values to the host computer.

In the following the keyboard function asks LIO to evalate the first argument as a string receives “1+1=” and types it to the keyboard, it then asks LIO to evaulate the second argument as a string. LIO sees this is another expression (+ 1 1) sends the two arguments (1 and 1) to the ‘+’ function, this requests each argument as an integer and returns the addition of both (2), LIO then converts this to a string “1” and returns it to keyboard which types it to the host computer “1+1=1”.

(keyboard "1+1=" (+ 1 1))

It is important to remember that expressions are evaluated as they are used/requested by functions and that every function returns a value. The keyboard function returns the last string it has typed so the following would type “hello worldworld”:

(keyboard (keyboard "hello " "world"))


The only other syntactic structure in LIO is the comment - anything after a hash or semicolon (‘#’ or ‘;’) will be treated as a comment until a newline is read.

; copy this file to run.lio on your phatIO device
(config 1 1); print errors at keyboard
(keyboard "hello"); type hello


The basic/default type in LIO is a 16 bit unsigned integer treated as decimal unless proceeded with ‘0x’ then treated as hexidecimal. A single character enclosed in single quotes - ‘a’ will be converted to an integer.

phatIO has a limited support for strings - which should be surrounded by double quotes (").

Booleans are supported by a 0 integer (false) and non zero (true).

@Contact  |   Legal & Privacy  |    RSS  |   Development Twitter  |   Official Twitter
© phatIO 2012, All Rights Reserved.