| UBFA(6) | Games Manual | UBFA(6) |
ubfa - universal binary format for data transport
UBF(A) is the data transport encoding for Armstrong's Universal Binary Format. It provides four primitive types: atoms (symbolic constants), integers, strings, and binary data. There are two compound types: fixed-length tuples and variable-length lists. Ubfa (2) provides basic support in Limbo for reading and writing streams of UBF(A)-encoded data.
The input syntax is defined by the following rules:
input ::= item* '$'
item ::= integer | atom | string | binary | tuple | list | store | push | comment | tag
integer ::= '-'?[0-9]+
atom ::= "'" ([^\'] | '\\' | "\'")* "'"
string ::= '"' ([^\"] | '\\' | '\"')* '"'
binary ::= '~' byte* '~' # preceded by integer byte count
tuple ::= '{' item* '}'
list ::= '#' (item '&')*
store ::= '>' reg
push ::= reg
reg ::= [^-%"~'`{}#& \n\r\t,0-9]
comment ::= '%' ([^\%] | '\\' | '\%')* '%'
tag ::= '`' ([^\`] | '\\' | '\`')* '`'
White space is any sequence of blank, tab, newline or carriage-return characters, and can appear before or after any instance of item in the grammar.
The input data is interpreted by a simple virtual machine. The machine contains a stack of values of primitive and compound types, and a set of registers also containing values of those types. White space and comments are ignored. Primitive integer, atom and string values are pushed onto the stack as they are recognised. Certain input bytes outside any value act as operators:
Applications using UBF(A) typically take turns to exchange input values on a communication channel.
ubfa (2), json (6), sexprs (6)
J L Armstrong, ``Getting Erlang to talk to the outside world'', ACM SIGPLAN
Erlang workshop 2002 , Pittsburg, PA USA
UBF web page, http://www.sics.se/~joe/ubf/