lib: new API for Comparator

Also remove old deprecated classes.

Signed-off-by: Jean Privat <jean@pryen.org>
lib: beef-up the Comparator api and documentation

Signed-off-by: Jean Privat <jean@pryen.org>
model: rename LinexComparator::min/max to avoid name conflicts

Signed-off-by: Jean Privat <jean@pryen.org>
stream: Offer string-backed input streams.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Merge: Improve Comparator type-kindness

The Comparator class in Nit was a PITA because, with the traditional modelization with a generic class, Comparator is contravariant but Nit only allows covariance in its genericity.

Example:

~~~nit
var ao = new Array[Object].with_items(2,1,10)
ao.sort_with(alpha_comparator)
print ao.join(" ") # => 1 10 2

var ai = new Array[Int].with_items(2,1,10)
ai.sort_with(alpha_comparator)
# Static error: expected a Comparator[Int], got a Comparator[Object]
~~~

This PR implements the nice proposition of Etienne Gagnon to makes Comparator a non-generic class but use virtual types to control the type of compared elements.

It is clearly an improvement over the previous implementation:

* more expressive (++++)
* less code (+)
* simpler for the client (less generic stuff) (+)
* coherent with the `Comparable` hierarchy that also use virtual types (+)
* a little more complex for the lib (virtual type redefinition) (-)
* loss of information when things are typed with the interface `Comparator`, yielding to more potential covariance error at runtime (--)

While less type-safe than a full (and complex) contravariance solution, the proposed solution is still better in term of type-safety than dynamic languages and non-generic-non-virtual-type solutions (eg. Java4):

* runtime errors are detected earlier than with erasure or with dynamic typing (fail fast)
* some errors are still detected statically:

~~~
var a = [1,10,2,3]
alpha_comparator.sort(a)
print a.join(" ") #=> 1 10 2 3
default_comparator.sort(a)
print a.join(" ") #=> 1 2 3 10

var b = [true, false]
alpha_comparator.sort(b)
print b.join(" ") # => false true
default_comparator.sort(b)
# Static type error: expected Array[Comparable], got Array[Bool]
~~~

Original-Idea-By: Etienne M. Gagnon <egagnon@j-meg.com>

Pull-Request: #803
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
NOTICE: update dates and authors.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
stream: Introduce a push-back reader.

May be useful when implementing backtracking algorithms.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Merge: NOTICE: update dates and authors.

After 2 years, I think the `NOTICE` file need to be updated.

Pull-Request: #804
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Merge: stream: push-back reader

I implemented something similar to http://docs.oracle.com/javase/7/docs/api/java/io/PushbackReader.html last week thinking I needed it for the XML parser, but I ended up with a top-down parser that do not need to backtrack by more than one octet.

Pull-Request: #805
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
xml: Port SAX 2.0.

This is a port of SAX 2.0.1 (http://www.saxproject.org) in Nit. The
following is **not** included in this port:

* Support for SAX1.
* Exceptions.
* Factories (requires run-time loading).

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
xml: Add classes to help testing a SAX parser.

Will be used to test SAXophoNit (A SAX parser in Nit).

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
xml: Introduce SAXophoNit, a SAX processor in Nit.

For the moment, this implementation is mostly non-compliant, but it
works with most common XML documents.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
xml: split SAXophoNit in modules.

Split SAXophoNit in 3 layers:

1. The parser/frontend
2. The lexer
3. The model

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
xml: Normalize white space in attribute values.

In a attribute value, any white space character MUST be normalized as a
space.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
sax: make `NamespaceSupport` compliant with errata.

The original SAX 2.0.1 is not compliant with the errata of
“Namespaces in XML” for backward-compatibility reasons. Since we do not
have to support legacy software in the Nit version, implement the
errata by default.

Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>