nit.git
9 years ago.gitattributes: nodiff all c_src
Jean Privat [Thu, 30 Oct 2014 01:58:12 +0000 (21:58 -0400)]
.gitattributes: nodiff all c_src

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agomkcsrc: rewrite a simplified version
Jean Privat [Thu, 30 Oct 2014 01:51:57 +0000 (21:51 -0400)]
mkcsrc: rewrite a simplified version

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocompile: also generates a makefile named Makefile
Jean Privat [Thu, 30 Oct 2014 01:32:37 +0000 (21:32 -0400)]
compile: also generates a makefile named Makefile

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocompile: add option --group-c-files
Jean Privat [Thu, 30 Oct 2014 01:22:57 +0000 (21:22 -0400)]
compile: add option --group-c-files

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocompile: remove clib from the -I dir because the usufull files are already copied
Jean Privat [Thu, 30 Oct 2014 01:11:03 +0000 (21:11 -0400)]
compile: remove clib from the -I dir because the usufull files are already copied

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocompile: use shortest path from the compiledir to the outname
Jean Privat [Thu, 30 Oct 2014 00:55:15 +0000 (20:55 -0400)]
compile: use shortest path from the compiledir to the outname

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocompiler: add option --max-c-lines
Jean Privat [Thu, 30 Oct 2014 00:47:21 +0000 (20:47 -0400)]
compiler: add option --max-c-lines

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agocompiler: do not create empty .h file
Jean Privat [Thu, 30 Oct 2014 00:36:49 +0000 (20:36 -0400)]
compiler: do not create empty .h file

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Threads
Jean Privat [Wed, 29 Oct 2014 19:11:53 +0000 (15:11 -0400)]
Merge: Threads

Intro the `threads` module with support for POSIX threads, mutex and barriers. Also provides 2 ways to have thread-safe collections: refining existing collections and sub-classing them.

TODO:
* Complete the collection support.
* Modifiy `print` so that printing the user content and the new line is (generally) atomic
* Add more examples/use in real programs
* Reinforce error support.
* Fix compatibility with FFI's global refs.
* Add, when needed, GC_THREADS to `gc_chooser.[c|h]`
* Do not include `gc.h` when not using libgc

ping @egagnon

Pull-Request: #849
Reviewed-by: Jean-Philippe Caissy <jpcaissy@piji.ca>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Etienne M. Gagnon <egagnon@j-meg.com>

9 years agoMerge: neo4j: Implement missing methods in `JsonArray`.
Jean Privat [Wed, 29 Oct 2014 19:11:45 +0000 (15:11 -0400)]
Merge: neo4j: Implement missing methods in `JsonArray`.

Pull-Request: #856
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Workaround nitlight
Jean Privat [Wed, 29 Oct 2014 19:11:41 +0000 (15:11 -0400)]
Merge: Workaround nitlight

nitlight was broken when `is cached` was used because highlight does not like AST transtormations.

This workaround justs disable the `cache` phase until something better is found.

http://nitlanguage.org/code2/nitserial.html#nitserial#MModule#serializable_type

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

9 years agoMerge: lib: fix semantic on has_substring on extreme cases
Jean Privat [Wed, 29 Oct 2014 19:11:38 +0000 (15:11 -0400)]
Merge: lib: fix semantic on has_substring on extreme cases

And avoid illegal access outside the string.

Detected thanks to the interpreted that warns on out-of-bound accesses in nativestrings.

Pull-Request: #854
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agolib/threads: intro an example `concurrent_array_and_barrier`
Alexis Laferrière [Mon, 27 Oct 2014 14:40:51 +0000 (10:40 -0400)]
lib/threads: intro an example `concurrent_array_and_barrier`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/threads: intro new thread-safe concurrent collections
Alexis Laferrière [Sun, 26 Oct 2014 16:23:11 +0000 (12:23 -0400)]
lib/threads: intro new thread-safe concurrent collections

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoneo4j: Implement missing methods in `JsonArray`.
Jean-Christophe Beaupré [Wed, 29 Oct 2014 16:10:42 +0000 (12:10 -0400)]
neo4j: Implement missing methods in `JsonArray`.

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

9 years agolib/threads: optional redefs of collections to be thread-safe
Alexis Laferrière [Sun, 26 Oct 2014 16:21:22 +0000 (12:21 -0400)]
lib/threads: optional redefs of collections to be thread-safe

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/threads: intro of the threads lib, with Thread, Mutex and Barrier
Alexis Laferrière [Sun, 26 Oct 2014 16:19:31 +0000 (12:19 -0400)]
lib/threads: intro of the threads lib, with Thread, Mutex and Barrier

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agohighlight: fix css for line and foldable
Jean Privat [Wed, 29 Oct 2014 13:27:33 +0000 (09:27 -0400)]
highlight: fix css for line and foldable

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agonitlight: disable `cached` since transformed AST cause issues in highlight
Jean Privat [Wed, 29 Oct 2014 13:05:01 +0000 (09:05 -0400)]
nitlight: disable `cached` since transformed AST cause issues in highlight

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoauto_super_init: make code robust if `typing` is disabled
Jean Privat [Wed, 29 Oct 2014 12:52:06 +0000 (08:52 -0400)]
auto_super_init: make code robust if `typing` is disabled

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agophase: make `disabled=` public
Jean Privat [Wed, 29 Oct 2014 12:50:54 +0000 (08:50 -0400)]
phase: make `disabled=` public

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib: fix semantic on has_substring on extreme cases
Jean Privat [Wed, 29 Oct 2014 01:32:53 +0000 (21:32 -0400)]
lib: fix semantic on has_substring on extreme cases

And avoid illegal access outside the string.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Opportunity
Jean Privat [Wed, 29 Oct 2014 00:11:46 +0000 (20:11 -0400)]
Merge: Opportunity

Addresses a few issues mentionned  in #811 :
- Return to the meetup creation page when the creation fails (auto-complete fields with old info)
- Use real buttons for the addition/deletion of an attendee to a Meetup
- Forbid creation of a Meetup without at least one answer

I also added feedback when an error is produced when creating the Meetup via a system similar to what @xymus does for Benitlux.

There were a few bugs hidden in the code, the update of the compiler with checks on useless null tests has revealed two of them.

Pull-Request: #850
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoMerge: example: rosetta code
Jean Privat [Wed, 29 Oct 2014 00:11:43 +0000 (20:11 -0400)]
Merge: example: rosetta code

Starting playing #842
It is zen...

Pull-Request: #844
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: xml: Introduce SAXophoNit, a SAX processor in Nit.
Jean Privat [Wed, 29 Oct 2014 00:11:40 +0000 (20:11 -0400)]
Merge: xml: Introduce SAXophoNit, a SAX processor in Nit.

This is a work in progress for a SAX processor in Nit.

Here is a sumary of what is (and what is not) supported at this point:
- [X] Content
- [X] XML declaration (parse it)
- [X] Acceptation of any XML document that Doxygen generates
- [ ] `DOCTYPE` declaration (or ignore it)
- [ ] XML declaration (do something with the settings)
- [x] Namespaces in XML
- [x] SAX mandatory feature flags
- [ ] XML 1.1
- [ ] Ignorable white space
- [ ] User-defined entities
- [ ] Encodings
- [ ] URIs
- [x] Test suite

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

9 years agoopportunity: Fixed a few typos.
Lucas Bajolet [Tue, 28 Oct 2014 18:38:57 +0000 (14:38 -0400)]
opportunity: Fixed a few typos.

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: grammar: allow '`' inside foreign code blocks
Jean Privat [Tue, 28 Oct 2014 00:30:34 +0000 (20:30 -0400)]
Merge: grammar: allow '`' inside foreign code blocks

This was an old bug causing the use of ``` ` ``` within a foreign code block to break the block. Example:

~~~~
fun foo `{
    // Some comment on entity `foo` would prevent the whole block to be recognize
`}
~~~~

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

9 years agoexample: add some tasks of Rosetta code
Jean Privat [Mon, 27 Oct 2014 19:44:05 +0000 (15:44 -0400)]
example: add some tasks of Rosetta code

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update test_new_native_alt1 becaus eline change in array.nit
Jean Privat [Mon, 27 Oct 2014 23:53:58 +0000 (19:53 -0400)]
tests: update test_new_native_alt1 becaus eline change in array.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib: add Array::+
Jean Privat [Mon, 27 Oct 2014 19:38:30 +0000 (15:38 -0400)]
lib: add Array::+

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agolib/collection: minor fix to doc in list.nit
Alexis Laferrière [Sun, 26 Oct 2014 13:12:59 +0000 (09:12 -0400)]
lib/collection: minor fix to doc in list.nit

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoopportunity: Bugfix for answers at creation of a new attendee for a Meetup
Lucas Bajolet [Mon, 27 Oct 2014 18:50:25 +0000 (14:50 -0400)]
opportunity: Bugfix for answers at creation of a new attendee for a Meetup

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoopportunity: Cosmetic changes to meetup visualization page
Lucas Bajolet [Mon, 27 Oct 2014 18:05:17 +0000 (14:05 -0400)]
opportunity: Cosmetic changes to meetup visualization page

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoopportunity: Fixed useless null check
Lucas Bajolet [Mon, 27 Oct 2014 17:21:30 +0000 (13:21 -0400)]
opportunity: Fixed useless null check

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoopportunity: Creation of a Meetup can now return to its page on error
Lucas Bajolet [Mon, 27 Oct 2014 17:21:15 +0000 (13:21 -0400)]
opportunity: Creation of a Meetup can now return to its page on error

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoxml: Add an usage example.
Jean-Christophe Beaupré [Mon, 27 Oct 2014 16:17:49 +0000 (12:17 -0400)]
xml: Add an usage example.

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

9 years agoxml: Add some tests for SAXpohoNit.
Jean-Christophe Beaupré [Mon, 27 Oct 2014 15:45:06 +0000 (11:45 -0400)]
xml: Add some tests for SAXpohoNit.

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

9 years agoxml: Introduce SAXophoNit, a SAX processor in Nit.
Jean-Christophe Beaupré [Thu, 9 Oct 2014 14:53:46 +0000 (10:53 -0400)]
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>

9 years agoxml: Add classes to help testing a SAX parser.
Jean-Christophe Beaupré [Thu, 25 Sep 2014 19:25:03 +0000 (15:25 -0400)]
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>

9 years agoxml: Port SAX 2.0.
Jean-Christophe Beaupré [Fri, 19 Sep 2014 13:44:15 +0000 (09:44 -0400)]
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>

9 years agogrammar: allow '`' inside foreign code blocks
Alexis Laferrière [Sat, 25 Oct 2014 13:07:52 +0000 (09:07 -0400)]
grammar: allow '`' inside foreign code blocks

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoopportunity: Changed layout from contrainer-fluid to container
Lucas Bajolet [Mon, 27 Oct 2014 15:29:51 +0000 (11:29 -0400)]
opportunity: Changed layout from contrainer-fluid to container

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoopportunity: Corrected typo in welcome message
Lucas Bajolet [Mon, 27 Oct 2014 15:29:31 +0000 (11:29 -0400)]
opportunity: Corrected typo in welcome message

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agolib: add Text::justify
Jean Privat [Sat, 25 Oct 2014 01:59:36 +0000 (21:59 -0400)]
lib: add Text::justify

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: New constructors with the `new` keyword
Jean Privat [Fri, 24 Oct 2014 23:58:38 +0000 (19:58 -0400)]
Merge: New constructors with the `new` keyword

`new` constructors where introduced with the FFI and generalized latter for intern methods.
This PR make them also legal with used-defined code in Nit.

~~~
abstract class Person
   var age: Int
   new(age: Int) do
      if i < 18 then
         return new Adult(age)
      else
         return new Child(age)
      end
end
~~~

A `new` constructor is specified like a static method.
By default it returns the type of self, but this can be changed by the user.

This PR starts by generalizing the `new` constructors. Thus a lot of specific code in engine is removed.
Then additional rules are added to control the usage of user-defined `new` constructors.

The original code was great enough to accepts these new kind of method without heavy modification.

Pull-Request: #840
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: neo: Fix definition lists
Jean Privat [Fri, 24 Oct 2014 23:58:35 +0000 (19:58 -0400)]
Merge: neo: Fix definition lists

Fix the code that load relationships between a property or a class and its definitions.

Pull-Request: #841
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: model: better implementation of the two `intro` methods
Jean Privat [Fri, 24 Oct 2014 23:58:26 +0000 (19:58 -0400)]
Merge: model: better implementation of the two `intro` methods

MClass and MProperty have a `intro` method to get the introducing
definition.
The initial implementation was to return the first known definition, that
make sense for a model constructed from a source-code where introductions
are read before refinements and redefinitions.

However, for a better robustness of the model that allows to load the
model form a serialized form or allows a model partially loaded, the
first-read definition is not necessary the intro.

This new implementation uses a different approach: the introduction is
the definition in the introducing compound (module for classes and
classdefs for properties). The introducing compound is known since the
construction, thus this new implementation is trivial and does not change
the API.

Rewrite-of: #841

Pull-Request: #843
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: update some tests because buggy `new` are let untyped
Jean Privat [Thu, 23 Oct 2014 15:43:04 +0000 (11:43 -0400)]
tests: update some tests because buggy `new` are let untyped

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: add base_new.nit
Jean Privat [Thu, 23 Oct 2014 01:51:06 +0000 (21:51 -0400)]
tests: add base_new.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotyping: ANew accepts only `init` on concrete class
Jean Privat [Thu, 23 Oct 2014 14:12:12 +0000 (10:12 -0400)]
typing: ANew accepts only `init` on concrete class

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoneo: Remove `is_intro`.
Jean-Christophe Beaupré [Thu, 23 Oct 2014 19:33:17 +0000 (15:33 -0400)]
neo: Remove `is_intro`.

`is_intro` is computed by the model and is ignored anyway.

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

9 years agomodel: better implementation of the two `intro` methods
Jean Privat [Fri, 24 Oct 2014 00:37:53 +0000 (20:37 -0400)]
model: better implementation of the two `intro` methods

MClass and MProperty have a `intro` method the get the introducing
definition.
The initial implementation was to return the first known definition, that
make sense for a model constructed from a source-code where introductions
are read before refinements and redefinitions.

However, for a better robustness of the model that allows to load the
model form a serialized form or allows a model partially loaded, the
first-read definition is not necessary the intro.

This new implementation uses a different approach: the introduction is
the definition in the introducing compound (module for classes and
classdefs for properties). The introducing compound is known since the
construction, thus this new implementation is trivial and does not change
the API.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoneo: Fix linking between `MProperty` and `MPropDef`.
Jean-Christophe Beaupré [Thu, 23 Oct 2014 19:18:11 +0000 (15:18 -0400)]
neo: Fix linking between `MProperty` and `MPropDef`.

At loading, `neo.nit` linked each `MPropDef` two times to its
`MProperty`.

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

9 years agotyping: `new`-fatories are like top-level methods
Jean Privat [Thu, 23 Oct 2014 01:48:05 +0000 (21:48 -0400)]
typing: `new`-fatories are like top-level methods

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotyping: allow `new` on interface and abstract classes that have a `new`-factory
Jean Privat [Wed, 22 Oct 2014 19:03:46 +0000 (15:03 -0400)]
typing: allow `new` on interface and abstract classes that have a `new`-factory

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotyping: ANew distinguish the type of the class and the returned type
Jean Privat [Wed, 22 Oct 2014 19:00:47 +0000 (15:00 -0400)]
typing: ANew distinguish the type of the class and the returned type

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agomodel: `new` factories have a return type.
Jean Privat [Wed, 22 Oct 2014 18:56:15 +0000 (14:56 -0400)]
model: `new` factories have a return type.

The default is the definition class, so it remove a special case for
such methods.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agomodel: `new` factories are named "new", not init.
Jean Privat [Wed, 22 Oct 2014 18:52:16 +0000 (14:52 -0400)]
model: `new` factories are named "new", not init.

It means that in `new X`, first the method name `new` is searched,
then the method named `init` as a fallback.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agomodel-clients: use `is_root_init` instead of `.name == "init"`
Jean Privat [Fri, 17 Oct 2014 09:57:22 +0000 (05:57 -0400)]
model-clients: use `is_root_init` instead of `.name == "init"`

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Some gammar improvements
Jean Privat [Wed, 22 Oct 2014 22:45:27 +0000 (18:45 -0400)]
Merge: Some gammar improvements

A bunch of unrelated grammar work: bugfixes, a feature and stuff for future work.

The only implemented feature is the use of extended method identifiers in annotation (setters and operators)

~~~nit
class A
   var foo: String is writable(real_foo=)
   fun foo=(f: String) do
      print "Hello!"
      real_foo = f
   end
end
~~~

Some additional syntax for future works are now accepted but are ignored (or will crash at compile-time).

* user defined factories in class (eg. define `new` in interface)

~~~
interface Buffer
   new do return new FlatBuffer
end
var x = new Buffer
~~~

* code-block in attributes. when the default/lazy value is more complex than a single expression

~~~
class A
   var foo: Int do
      print "Hello!"
      return 5
   end
end
~~~

* generalized tuples. eg. for multiple returns, but more word is needed #839

~~~
fun foo(a,b: Int)
do
   return (a/b, a%b)
end
~~~

In fact, generalized tuples accepts anything that annotations accepts... (eventually they will be rejected just after parsing)

~~~
var x = (1, Array[Int], for x in a do print x, toto=, -)
# in order: a literal expression, a type, a statement, a method identifier (setter),
# an other method identifier (the minus operator)
~~~

Pull-Request: #832
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agotests: update tests because the parser gets better to parse arbitrary things.
Jean Privat [Wed, 22 Oct 2014 14:24:46 +0000 (10:24 -0400)]
tests: update tests because the parser gets better to parse arbitrary things.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: regenerate
Jean Privat [Tue, 21 Oct 2014 23:52:03 +0000 (19:52 -0400)]
parser: regenerate

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agogrammar: allows blocks in attribute definitions
Jean Privat [Tue, 21 Oct 2014 23:45:22 +0000 (19:45 -0400)]
grammar: allows blocks in attribute definitions

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agogrammar: accepts new-factory with code
Jean Privat [Fri, 17 Oct 2014 09:55:28 +0000 (05:55 -0400)]
grammar: accepts new-factory with code

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoannotation: `as_id` works with operators and setters
Jean Privat [Fri, 17 Oct 2014 02:44:18 +0000 (22:44 -0400)]
annotation: `as_id` works with operators and setters

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: generalise Prod::collect_text
Jean Privat [Fri, 17 Oct 2014 02:43:25 +0000 (22:43 -0400)]
parser: generalise Prod::collect_text

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoast: accept methodid in at_args
Jean Privat [Fri, 17 Oct 2014 02:33:37 +0000 (22:33 -0400)]
ast: accept methodid in at_args

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agogrammar: add qmethid for qualified methid id
Jean Privat [Fri, 17 Oct 2014 02:24:40 +0000 (22:24 -0400)]
grammar: add qmethid for qualified methid id

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: neo: Add `MAttributeDef.static_type` in the graph.
Jean Privat [Tue, 21 Oct 2014 23:42:20 +0000 (19:42 -0400)]
Merge: neo: Add `MAttributeDef.static_type` in the graph.

Pull-Request: #838
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoneo: Add `MAttributeDef.static_type` in the graph.
Jean-Christophe Beaupré [Mon, 20 Oct 2014 17:40:59 +0000 (13:40 -0400)]
neo: Add `MAttributeDef.static_type` in the graph.

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

9 years agoMerge: Fix the old bug where (-0.1).to_s == "0.-1"
Jean Privat [Mon, 20 Oct 2014 13:48:17 +0000 (09:48 -0400)]
Merge: Fix the old bug where (-0.1).to_s == "0.-1"

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

9 years agoMerge: neo: correct the documentation of neo.nit according to PR #781.
Jean Privat [Mon, 20 Oct 2014 13:48:12 +0000 (09:48 -0400)]
Merge: neo: correct the documentation of neo.nit according to PR #781.

PR #781 changed the model, but not the documentation of neo.nit.

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

9 years agoMerge: Small compiler things
Jean Privat [Mon, 20 Oct 2014 13:47:55 +0000 (09:47 -0400)]
Merge: Small compiler things

Pull-Request: #834
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: file: Fix `join_path` to handle paths ending with a slash.
Jean Privat [Mon, 20 Oct 2014 13:47:50 +0000 (09:47 -0400)]
Merge: file: Fix `join_path` to handle paths ending with a slash.

That way, we no longer need to manually remove the trailing slash before calling `join_path`.

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

9 years agotests: update savs for tests using the previously broken to_precision
Alexis Laferrière [Fri, 17 Oct 2014 15:36:06 +0000 (11:36 -0400)]
tests: update savs for tests using the previously broken to_precision

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agolib/standard: fix `Float::to_precision`
Alexis Laferrière [Sun, 12 Oct 2014 05:16:00 +0000 (01:16 -0400)]
lib/standard: fix `Float::to_precision`

Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

9 years agoneo: correct the documentation of neo.nit according to PR #781.
Jean-Christophe Beaupré [Fri, 17 Oct 2014 14:41:12 +0000 (10:41 -0400)]
neo: correct the documentation of neo.nit according to PR #781.

PR #781 changed the model, but not the documentation of neo.nit.

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

9 years agoabstract_compiler: prefers implementing expr than stmt in assignments
Jean Privat [Fri, 17 Oct 2014 02:57:07 +0000 (22:57 -0400)]
abstract_compiler: prefers implementing expr than stmt in assignments

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoabstract_compiler: default stmt implmentation do not need to execute variables as...
Jean Privat [Fri, 17 Oct 2014 02:56:17 +0000 (22:56 -0400)]
abstract_compiler: default stmt implmentation do not need to execute variables as statments

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoparser: add tuples
Jean Privat [Thu, 16 Oct 2014 04:18:04 +0000 (00:18 -0400)]
parser: add tuples

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoast: remove classes AAtArg and make them simple AExpr
Jean Privat [Thu, 16 Oct 2014 01:18:46 +0000 (21:18 -0400)]
ast: remove classes AAtArg and make them simple AExpr

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Robust debug
Jean Privat [Fri, 17 Oct 2014 00:21:34 +0000 (20:21 -0400)]
Merge: Robust debug

First pass on the debugger, simple cleanup/fixes that might be helpful for the end-user.

Addresses some of the issues mentioned in #742.

Pull-Request: #822
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Brainfuck
Jean Privat [Fri, 17 Oct 2014 00:21:14 +0000 (20:21 -0400)]
Merge: Brainfuck

As the name implies, this is a very simple Brainfuck interpreter written in Nit.

Yes, it is (mostly) useless, but it might serve as an example of a simple Nit program.

Pull-Request: #828
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoMerge: src: remove two TODO that are done/unneeded
Jean Privat [Fri, 17 Oct 2014 00:21:10 +0000 (20:21 -0400)]
Merge: src: remove two TODO that are done/unneeded

Pull-Request: #830
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: Better varargs
Jean Privat [Fri, 17 Oct 2014 00:20:53 +0000 (20:20 -0400)]
Merge: Better varargs

since their introduction in Nit, varargs had a quick and dirty implementation.
They where implemented with a complex path in the low-level parts of engine instead being implemented at  the AST level as it should be: varargs is more a syntactic sugar than something else.

Thus this PR changes the implementation of varargs in the engines.
This rationalize the `varargize` methods and simplify the code for low-level part (and also solve some bugs)

Additionally, the reverse-vararg, already accepted by the parser but unused until now, is implemented.
The principle it to pass an array where a vararg is expected.
Because of static ambiguities, the array passed as-is must be annotated with an ellipsis (`...`).

~~~nit
fun foo (xs: Object...) do print x.join("-")
foo(1,2,3) # prints "1-2-3"
var a = [1,2,3]
foo(a...) # prints "1-2-3"
foo(a) # pass `[a]`, a new array with a single element `a`, to foo, thus prints "123"
foo(1...) # Static Type Error: expected Array[Object], got Int.
~~~

Still, I think that error messages should be improved (cf. #98) but this seems to need some additional work in the error infrastructure.

A remaining question is what is the best acceptable type passed.
In the proposed implementation, the reverse-vararg must be a compatible Array (so a Sequence or a List are not accepted) and is given as is to the real method, that is allowed to modify it.
Should we change the type on a vararg to be a Sequence, a SequenceRead, of even a simple Collection ?

Pull-Request: #827
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agotests: add base_vararg3.nit
Jean Privat [Wed, 15 Oct 2014 18:53:16 +0000 (14:53 -0400)]
tests: add base_vararg3.nit

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotyping+engines: handle reverse-vararg: passing an array as-is.
Jean Privat [Wed, 15 Oct 2014 14:46:39 +0000 (10:46 -0400)]
typing+engines: handle reverse-vararg: passing an array as-is.

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agofile: Fix `join_path` to handle paths ending with a slash.
Jean-Christophe Beaupré [Thu, 16 Oct 2014 18:16:52 +0000 (14:16 -0400)]
file: Fix `join_path` to handle paths ending with a slash.

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

9 years agobrainfuck: Added a simple Brainfuck interpreter
Lucas Bajolet [Wed, 15 Oct 2014 18:15:59 +0000 (14:15 -0400)]
brainfuck: Added a simple Brainfuck interpreter

Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agogrammar: minus and once do not need nopar variants
Jean Privat [Thu, 16 Oct 2014 00:29:19 +0000 (20:29 -0400)]
grammar: minus and once do not need nopar variants

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agosrc: remove two TODO that are done/unneeded
Jean Privat [Thu, 16 Oct 2014 00:22:02 +0000 (20:22 -0400)]
src: remove two TODO that are done/unneeded

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agoMerge: Manpages
Jean Privat [Wed, 15 Oct 2014 20:16:01 +0000 (16:16 -0400)]
Merge: Manpages

~~~sh
$ man nitg
~~~

A dream come true.

More seriously, toolcontext is extended to be able to generate manpages (in a similar way than completion).
Then a bunch of manpages is generated.

The content of the manpages should be improved but this is better than nothing.

Pull-Request: #825
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: transform loops
Jean Privat [Wed, 15 Oct 2014 20:15:47 +0000 (16:15 -0400)]
Merge: transform loops

In order to activate more optimizations and simplify code generators and analysis, the `while` and `for` loops must be transformed into simpler forms (in fact in complex forms but with simpler elements)

However, to do such a transformation, the escaping mechanism (break/continue/goto) must be rewrote.
Previously, for each loop control structure (loop for, while), a single EscapeMark was generated and breaks and continues are associated to the same mark, even if they branch in distinct points (so each escapemark had 2 branching mechanisms)
Now, with the first commits, two escapemarks are generated for each loop control structure, and breaks and continues are associated to a different one. The advantage is that each mark only have a single branching mechanism and that once associated to their mark, there is no need to distinguish break and continue (both become simple gotos).

The transformations of loops can be then implemented.

The `while`

~~~
while cond do block
~~~

is transformed into

~~~
loop if cond then block else break
~~~

and `for`

~~~
for i in col do block
~~~

is transformed into

~~~
var it = col.iterator
loop
   if it.is_ok then
      var i = it.item
      do block
      # ^ `continue` in the block it attached to the `do`
      # this is why the transformation of escape-marks where needed in fact.
      # and break is associated to the main loop
      it.next
   else
      break
   end
end
it.finish
~~~

Note that these transformations are basically what is currently implemented in rta, niti and nitg. Except that, now with a single transformation point, those three workers does not need to do their own transformation and basically can just rely on the one done on the AST level.

Pull-Request: #818
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>

9 years agoMerge: console: use snake case.
Jean Privat [Wed, 15 Oct 2014 20:13:33 +0000 (16:13 -0400)]
Merge: console: use snake case.

Correct a little mistake.

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

Pull-Request: #826
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

9 years agoshare: generate stubs for manpages
Jean Privat [Wed, 15 Oct 2014 19:04:52 +0000 (15:04 -0400)]
share: generate stubs for manpages

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotests: update sav/test_toolcontext_args*.res
Jean Privat [Wed, 15 Oct 2014 01:59:06 +0000 (21:59 -0400)]
tests: update sav/test_toolcontext_args*.res

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotoolcontext: add --stub-man
Jean Privat [Mon, 6 Oct 2014 12:48:32 +0000 (08:48 -0400)]
toolcontext: add --stub-man

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotransform: move up shortcut-range from abstract_compiler to transform
Jean Privat [Sat, 11 Oct 2014 15:15:28 +0000 (11:15 -0400)]
transform: move up shortcut-range from abstract_compiler to transform

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotransform: shortcut range
Jean Privat [Sat, 11 Oct 2014 15:11:48 +0000 (11:11 -0400)]
transform: shortcut range

Signed-off-by: Jean Privat <jean@pryen.org>

9 years agotransform: transforms `while` and `for`
Jean Privat [Sat, 11 Oct 2014 04:28:37 +0000 (00:28 -0400)]
transform: transforms `while` and `for`

Signed-off-by: Jean Privat <jean@pryen.org>