# See the License for the specific language governing permissions and
# limitations under the License.
-import java_api
+import java_api is example
# Get a Java string
var str = java_lang_integer_to_string_int(5678)
# See the License for the specific language governing permissions and
# limitations under the License.
+module user_test is example
+
import queue
var queue = new JavaQueue
# Example of a calculation used nitcc
# see `calc.sablecc` for the grammar
-module calc
+module calc is example
# Reuse the test program to simplify the code
import calc_test_parser
+module minilang is example
+
import minilang_test_parser
# An naive recursive stack-based interpreter of the minilang language.
# limitations under the License.
# Example that uses `shibuqam` to authenticate users and count the number of time they reload.
-module reloadgame
+module reloadgame is example
import popcorn
import counter
# * no `client_id`: because we do not want to code a db of clients. The `redirect_uri` can be seen as a simple client_id. We have also no way to present the client to the user since we do not control the authorization page of shibboleth since is done by the reverse proxy.
# * no `scope` and no `authorisation_code` since since there is nothing to access. We just get minimal information after the successful shibboleth login. Thus we have nothing more to authorise once the user is authenticated.
# * no `client_secret`: the user information are already public. There is no need to make the code more complex to protect public information.
-module shibuqamoauth
+module shibuqamoauth is example
import popcorn
import popcorn::pop_json
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+module blink is example
+
import wiringPi
if args.length != 1 then
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+module read is example
+
import wiringPi
if args.length != 1 then
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
+module wiringPi is example
+
import wiringPi
if args.is_empty or args.length > 2 then
# Example of an implementation of circular lists
# This example shows the usage of generics and somewhat a specialisation of collections.
-module circular_list
+module circular_list is example
# Sequences of elements implemented with a double-linked circular list
class CircularList[E]
# limitations under the License.
# Simple example of refinement where a method is added to the integer class.
-module fibonacci
+module fibonacci is example
redef class Int
# Calculate the self-th element of the fibonacci sequence.
# An example that defines and uses stacks of integers.
# The implementation is done with a simple linked list.
# It features: free constructors, nullable types and some adaptive typing.
-module int_stack
+module int_stack is example
# A stack of integer implemented by a simple linked list.
# Note that this is only a toy class since a real linked list will gain to use
# Example of a procedural program (without explicit class definition).
# This program manipulates arrays of integers.
-module procedural_array
+module procedural_array is example
# The sum of the elements of `a'.
# Uses a 'for' control structure.
# limitations under the License.
# a "Framework" to make Multi-Agent Simulations in Nit
-module agent_simulation is no_warning("missing-doc")
+module agent_simulation is example, no_warning("missing-doc")
import actors
# The steps consist of each agent greeting each other, and
# waiting for every other agent to respond before notifying
# to the `ClockAgent` that they finished their step.
-module simple_simulation
+module simple_simulation is example
import agent_simulation
#
# Complete description of the chameneos-redux :
# https://benchmarksgame.alioth.debian.org/u64q/chameneosredux-description.html#chameneosredux
-module chameneosredux is no_warning("missing-doc")
+module chameneosredux is example, no_warning("missing-doc")
import actors
#
# Complete description of the fannkuch-redux :
# https://benchmarksgame.alioth.debian.org/u64q/fannkuchredux-description.html#fannkuchredux
-module fannkuchredux is no_warning("missing-doc")
+module fannkuchredux is example, no_warning("missing-doc")
import actors
#
# Complete description of mandelbrot :
# https://benchmarksgame.alioth.debian.org/u64q/mandelbrot-description.html#mandelbrot
-module mandelbrot is no_warning("missing-doc")
+module mandelbrot is example, no_warning("missing-doc")
import actors
# limitations under the License.
# A very simple example of the actor model
-module simple
+module simple is example
import actors
#
# Complete description of the thread-ring :
# http://benchmarksgame.alioth.debian.org/u64q/threadring-description.html#threadring
-module thread_ring
+module thread_ring is example
import actors
#
# The shortest plan, in two steps, is to move *up* the tile under the hole (e),
# then to move *left* the tile after the hole (h).
+module puzzle is example
+
import ai::search
# The state (`S`) is a square grid, modeled as a one-dimensional array of Tile.
#
# This program takes an integer n as argument then display all solutions for the
# n-queens proglem (ie. on a n*n board).
-module queens
+module queens is example
import ai::backtrack
# Test for app.nit's UI services
module ui_test is
+ example
app_name "app.nit UI test"
app_version(0, 1, git_revision)
app_namespace "org.nitlanguage.ui_test"
# Example for the `app::http_request` main service `AsyncHttpRequest`
module http_request_example is
+ example
app_name "app.nit HTTP"
app_namespace "org.nitlanguage.http_example"
android_api_target 15
# User interface example using `app::ui`
module ui_example is
+ example
app_name "app.nit UI"
app_namespace "org.nitlanguage.ui_example"
android_api_min 21
# See the License for the specific language governing permissions and
# limitations under the License.
-module blink
+module blink is example
import bcm2835
# See the License for the specific language governing permissions and
# limitations under the License.
-module input
+module input is example
import bcm2835
# limitations under the License.
# Test extern classes from the Cocoa framework and extern factories
-module cocoa_extern_types
+module cocoa_extern_types is example
import cocoa
# limitations under the License.
# Simple message box using the Cocoa framework
-module cocoa_message_box
+module cocoa_message_box is example
import cocoa
# limitations under the License.
# Hello world using the Cocoa framework
-module hello_cocoa
+module hello_cocoa is example
import cocoa::foundation
# See the License for the specific language governing permissions and
# limitations under the License.
+module repeating_key_xor_solve is example
+
import base64
import crapto
# limitations under the License.
# Example use of the Curl module
-module curl_http
+module curl_http is example
import curl
# another product.
# Simple XML validity checker using the `dom` module
-module checker
+module checker is example
import dom
# limitations under the License.
# Example from http://www.graphviz.org/content/cluster
+module clusters is example
import dot
# limitations under the License.
# Example from http://www.graphviz.org/content/hello
+module hello is example
import dot
# limitations under the License.
# Example from http://www.graphviz.org/Gallery/undirected/fdpclust.html
+module undirected_clusters is example
import dot
# Font support showcase
module fonts_showcase is
+ example
app_name "gamnit fonts"
app_namespace "org.gamnit.fonts_showcase"
app_version(1, 0, git_revision)
# Template for a 2D gamnit game
module template is
+ example
app_name "gamnit template"
app_namespace "org.gamnit.template"
app_version(0, 1, git_revision)
# * The book OpenGL ES 2.0 Programming Guide
# * https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
module portable_triangle is
+ example
app_name "gamnit Triangle"
app_namespace "org.nitlanguage.triangle"
app_version(1, 1, git_revision)
# References:
# * The book OpenGL ES 2.0 Programming Guide
# * https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
-module standalone_triangle
+module standalone_triangle is example
import app
import gamnit::display
# limitations under the License.
# Sample module showing the use of the i18n annotation
-module langannot is i18n
+module langannot is example, i18n
import gettext
#
# From the book OpenGL ES 2.0 Programming Guide, see code reference:
# https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c
-module opengles2_hello_triangle
+module opengles2_hello_triangle is example
import glesv2
import egl
# See the License for the specific language governing permissions and
# limitations under the License.
+module html_page is example
+
import html
class NitHomepage
# Simple iOS app with a single label
module hello_ios is
+ example
app_name "Hello iOS"
app_namespace "nit.app.hello_ios"
app_version(0, 5, git_revision)
# See the License for the specific language governing permissions and
# limitations under the License.
-module mpi_simple
+module mpi_simple is example
import mpi
# Hyper Text Coffee Pot Control Protocol
# A server that implements HTCPCP. At the moment there are no additions.
-module htcpcp_server
+module htcpcp_server is example
import nitcorn
# The main page, `index.html`, is served dynamicly with `MyAction`.
# The rest of the Web site fetches files from the local directory
# `www/hello_world/`.
-module nitcorn_hello_world
+module nitcorn_hello_world is example
import nitcorn
# limitations under the License.
# Minimal example using a `ProxyAction`
+module nitcorn_reverse_proxy is example
import nitcorn::proxy
# limitations under the License.
# Example for the `restful` annotation documented at `lib/nitcorn/restful.nit`
-module restful_annot
+module restful_annot is example
import nitcorn::restful
import nitcorn::pthreads
#
# To be safe, it is recommended to run this program with its own username:
# `sudo file_server -u nitcorn:www`
-module simple_file_server
+module simple_file_server is example
import nitcorn
import privileges
# See the License for the specific language governing permissions and
# limitations under the License.
+module test_restful_annot is example
+
import nitcorn::restful_annot
import pthreads
# Creates a converter and initializes it
# Finally checks for dictionaries
-import pnacl
+import pnacl is example
class Converter
super PnaclApp
# See the License for the specific language governing permissions and
# limitations under the License.
+# This is an example of how to use angular.js with popcorn
+module example_angular is example
+
import popcorn
import popcorn::pop_json
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_post_handler is example
+
import popcorn
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_query_string is example
+
import popcorn
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_hello is example
+
import popcorn
class HelloHandler
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_advanced_logger is example
+
import popcorn
import realtime
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_html_error_handler is example
+
import popcorn
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_simple_logger is example
+
import popcorn
class SimpleLoggerHandler
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_mongodb is example
+
import popcorn
import mongodb
import template
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_glob_route is example
+
import popcorn
class UserItem
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_param_route is example
+
import popcorn
class UserHome
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_router is example
+
import popcorn
class AppHome
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_session is example
+
import popcorn
redef class Session
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_static is example
+
import popcorn
var app = new App
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_static_default is example
+
import popcorn
var app = new App
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_static_multiple is example
+
import popcorn
var app = new App
# See the License for the specific language governing permissions and
# limitations under the License.
+module example_templates is example
+
import popcorn
import popcorn::pop_templates
# limitations under the License.
# Example using the privileges module to drop privileges from root
-module drop_privileges
+module drop_privileges is example
import privileges
#
# 20 threads share an array and a barrier. They each insert 1000 strings into
# the array and wait at a barrier before finishing.
-module concurrent_array_and_barrier
+module concurrent_array_and_barrier is example
import pthreads::concurrent_collections
# limitations under the License.
# Simple example of joinable task using threadpool
-module jointask_example
+module jointask_example is example
import threadpool
# limitations under the License.
# test for threaded annotation
-module threaded_example
+module threaded_example is example
import pthreads
# limitations under the License.
# Simple example using threadpool
-module threadpool_example
+module threadpool_example is example
import threadpool
# limitations under the License.
# An example to test and demonstrate the `sdl2` lib with `image` and `events`
-module minimal
+module minimal is example
import sdl2::all
#
# The advantage of the approach is that it is done programmatically so can be adapted to real complex use cases.
# Basically, this is half-way between the full automatic serialization and the full manual serialisation.
-module custom_serialization
+module custom_serialization is example
import serialization
import json::serialization_write
# See the License for the specific language governing permissions and
# limitations under the License.
+module tmpl_composer is example
+
import template
### Here, definition of the specific templates
# limitations under the License.
# Sample module for a minimal chat server using Websockets on port 8088
-module websocket_server
+module websocket_server is example
import websocket
# ~~~raw
# get_mclasses ../../lib core::Array Array care::Arrow Fail
# ~~~
-module get_mclasses
+module get_mclasses is example
import parser_util
import modelbuilder
# This is an example of a client of the frontend without command-line processing.
#
# It offers a simple nitcorn web server that offers a textarea and nitpick and nitlignt it.
-module nitlight_as_a_service
+module nitlight_as_a_service is example
import frontend
import highlight
# limitations under the License.
# Crawler on the nitweb web API
-module nitwebcrawl
+module nitwebcrawl is example
import json::static
# Sample program that scan and load things.
#
# It shows the difference betwenn the various services of the `loader`.
-module test_loader
+module test_loader is example
import loader