Lpp objects can be read and constructed from C++ input streams.
| read | Function |
| read stream | Function |
read reads one Lpp object from the C++ input stream
stream and returns that object. The syntax of such objects on
stream is the same as Common Lisp except with no special
dispatching characters such as "#" or quote. Lpp read does
ignore semicolon comments to the end of line however. If the
stream argument is not provided cin is assumed. For
example suppose that we type (to cin) the following:
red
"Hello world"
(1 two 3)
Then calling read three times will produce:
let symbol1 = read();
let string1 = read();
let list1 = read();
symbolp(symbol1) => t
stringp(string1) => t
listp(list1) => t
numberp(first(list1)) => t
list(symbol1, string1, list1)
=> (red "Hello world" (1 two 3))
| readFromString string | Function |
The argument string is either a char* string or an Lpp
String object. readFromString is the same as read but uses the
string string instead of a C++ stream. For example:
let symbol1 = readFromString("red");
let string1 = readFromString("\"Hello world\"");
let list1 = readFromString("(1 two 3")
symbolp(symbol1) => t
stringp(string1) => t
listp(list1) => t
numberp(first(list1)) => t
list(symbol1, string1, list1)
=> (red "Hello world" (1 two 3))