lib: create directories for some lib (in order to prepare examples)

Signed-off-by: Jean Privat <jean@pryen.org>
lib: move some examples/* into specific subdirectories of their lib

examples/ starts to become a mess.
So move the simple examples of lib into an `example` subdirectory of the lib.

Signed-off-by: Jean Privat <jean@pryen.org>
lib/standard: make IFStream a PollableIStream so it can be used as stdin

Signed-off-by: Jean Privat <jean@pryen.org>
modelbuilder: parent in load_rt_module is optionnal

Signed-off-by: Jean Privat <jean@pryen.org>
niti: add -e to feed the interpreter with a program on the command line

Signed-off-by: Jean Privat <jean@pryen.org>
niti: add -n to run the program for each line in file-name arguments

Signed-off-by: Jean Privat <jean@pryen.org>
niti: introduce `read_variable` and `write_variable`

So the internal map is no more acceded directly, thus opening the door to
a more efficient implementation.

Signed-off-by: Jean Privat <jean@pryen.org>
niti: rename `init_naive_interpreter` as `Interpreter::start`

Signed-off-by: Jean Privat <jean@pryen.org>
niti: change some visibility to avoid unnecessary intrude imports

Signed-off-by: Jean Privat <jean@pryen.org>
Merge: Niti loves the command line

Nit is both a good compiled language and a good interpreted language (except that the naive interpreter is slow).

Some people already use nit as a traditional script-language by including a shebang at the first line of their programs and set them executable (`chmod +x`).

~~~nit
print "Hello world"
~~~

This experimental PR make the nit interpreter more script-useful.

First, it introduces the `-e` option to run a program written on the command line.
Like with ruby, perl, bash and other script language.

~~~sh
$ nit -e 'print 5+5'
10
~~~

Second, and this is just wonderful, it adds the `-n` option (from ruby and perl) to automatically iterate over the lines of files given as arguments. The current line is named `sys.line` (instead of `$_` in perl and ruby).

It works for stdin if no argument

~~~sh
$ echo "hello world" | nit -n -e 'print sys.line.capitalized'
Hello World
~~~

or on the arguments (as files) if one or more is given (it is the perl and ruby semantic)

~~~sh
$ nit -n -e 'print sys.line.capitalized' README
Nit Is A Statically Typed Object-Oriented Programming Language.
The Goal Of Nit Is To Propose A Statically Typed Programming Language Where Structure Is Not A Pain.
[...]
~~~

The logic of the `-n` is written in a library loaded at runtime (`niti_runtime.nit`), so can be updated without having to recompile the interpreter.

Pull-Request: #799
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: Niti: small refactoring

Some small improvements in the interpreter code infrastructure.

Pull-Request: #801
Merge: lib: move some examples/* into specific subdirectories of their lib

examples/ starts to become a mess.
So move the simple examples of lib into an `example` subdirectory of the lib.

But I am not really sure that it is a good idea.

Before: 132 projects, now 120 projects.

Pull-Request: #793
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>