'# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Alexis Laferrière ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text 'import' Keyword ' ' Text 'gtk' Name '\n\n' Text 'class' Keyword ' ' Text 'CalculatorContext' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'result' Name ' ' Text ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'Float' Name.Class ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\n\t' Text 'var' Keyword ' ' Text 'last_op' Name ' ' Text ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'Char' Name.Class ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\n\t' Text 'var' Keyword ' ' Text 'current' Name ' ' Text ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'Float' Name.Class ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t' Text 'var' Keyword ' ' Text 'after_point' Name ' ' Text ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'Int' Name.Class ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\n\t' Text 'fun' Keyword ' ' Text 'push_op' Name '(' Punctuation ' ' Text 'op' Name ' ' Text ':' Punctuation ' ' Text 'Char' Name.Class ' ' Text ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'apply_last_op_if_any' Name '\n\t\t' Text 'if' Keyword ' ' Text 'op' Name ' ' Text '==' Operator ' ' Text "'C'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'self' Name '.' Punctuation 'result' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '.0' Literal.Number.Float '\n\t\t\t' Text 'last_op' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t\t' Text 'else' Keyword '\n\t\t\t' Text 'last_op' Name ' ' Text '=' Operator ' ' Text 'op' Name ' ' Text '# store for next push_op' Comment.Single '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text '# prepare next current' Comment.Single '\n\t\t' Text 'after_point' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t\t' Text 'current' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t' Text 'end' Keyword '\n\n\t' Text 'fun' Keyword ' ' Text 'push_digit' Name '(' Punctuation ' ' Text 'digit' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'current' Name ' ' Text '=' Operator ' ' Text 'current' Name '\n\t\t' Text 'if' Keyword ' ' Text 'current' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'current' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '.0' Literal.Number.Float '\n\n\t\t' Text 'var' Keyword ' ' Text 'after_point' Name ' ' Text '=' Operator ' ' Text 'after_point' Name '\n\t\t' Text 'if' Keyword ' ' Text 'after_point' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword '\n\t\t\t' Text 'current' Name ' ' Text '=' Operator ' ' Text 'current' Name ' ' Text '*' Operator ' 10' Literal.Number.Float '.0' Literal.Number.Float ' ' Text '+' Operator ' ' Text 'digit' Name '.' Punctuation 'to_f' Name '\n\t\t' Text 'else' Keyword '\n\t\t\t' Text 'current' Name ' ' Text '=' Operator ' ' Text 'current' Name ' ' Text '+' Operator ' ' Text 'digit' Name '.' Punctuation 'to_f' Name ' ' Text '*' Operator ' 10' Literal.Number.Float '.0' Literal.Number.Float '.' Punctuation 'pow' Name '(' Punctuation 'after_point' Name '.' Punctuation 'to_f' Name ')' Punctuation '\n\t\t\t' Text 'self' Name '.' Punctuation 'after_point' Name ' ' Text '-' Operator '=' Operator ' 1' Literal.Number.Float '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text 'self' Name '.' Punctuation 'current' Name ' ' Text '=' Operator ' ' Text 'current' Name '\n\t' Text 'end' Keyword '\n\n\t' Text 'fun' Keyword ' ' Text 'switch_to_decimals' Name '\n\t' Text 'do' Keyword '\n\t\t' Text 'if' Keyword ' ' Text 'self' Name '.' Punctuation 'current' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'current' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '.0' Literal.Number.Float '\n\t\t' Text 'if' Keyword ' ' Text 'after_point' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'return' Keyword '\n\n\t\t' Text 'after_point' Name ' ' Text '=' Operator ' ' Text '-1' Literal.Number.Float '\n\t' Text 'end' Keyword '\n\n\t' Text 'fun' Keyword ' ' Text 'apply_last_op_if_any' Name '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'op' Name ' ' Text '=' Operator ' ' Text 'last_op' Name '\n\n\t\t' Text 'var' Keyword ' ' Text 'result' Name ' ' Text '=' Operator ' ' Text 'result' Name '\n\t\t' Text 'if' Keyword ' ' Text 'result' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'result' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '.0' Literal.Number.Float '\n\n\t\t' Text 'var' Keyword ' ' Text 'current' Name ' ' Text '=' Operator ' ' Text 'current' Name '\n\t\t' Text 'if' Keyword ' ' Text 'current' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'current' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '.0' Literal.Number.Float '\n\n\t\t' Text 'if' Keyword ' ' Text 'op' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword '\n\t\t\t' Text 'result' Name ' ' Text '=' Operator ' ' Text 'current' Name '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'op' Name ' ' Text '==' Operator ' ' Text "'+'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'result' Name ' ' Text '=' Operator ' ' Text 'result' Name ' ' Text '+' Operator ' ' Text 'current' Name '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'op' Name ' ' Text '==' Operator ' ' Text "'-'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'result' Name ' ' Text '=' Operator ' ' Text 'result' Name ' ' Text '-' Operator ' ' Text 'current' Name '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'op' Name ' ' Text '==' Operator ' ' Text "'/'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'result' Name ' ' Text '=' Operator ' ' Text 'result' Name ' ' Text '/' Operator ' ' Text 'current' Name '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'op' Name ' ' Text '==' Operator ' ' Text "'*'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'result' Name ' ' Text '=' Operator ' ' Text 'result' Name ' ' Text '*' Operator ' ' Text 'current' Name '\n\t\t' Text 'end' Keyword '\n\t\t' Text 'self' Name '.' Punctuation 'result' Name ' ' Text '=' Operator ' ' Text 'result' Name '\n\t\t' Text 'self' Name '.' Punctuation 'current' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'class' Keyword ' ' Text 'CalculatorGui' Name.Class '\n\t' Text 'super' Keyword ' ' Text 'GtkCallable' Name.Class '\n\n\t' Text 'var' Keyword ' ' Text 'win' Name ' ' Text ':' Punctuation ' ' Text 'GtkWindow' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'container' Name ' ' Text ':' Punctuation ' ' Text 'GtkGrid' Name.Class '\n\n\t' Text 'var' Keyword ' ' Text 'lbl_disp' Name ' ' Text ':' Punctuation ' ' Text 'GtkLabel' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'but_eq' Name ' ' Text ':' Punctuation ' ' Text 'GtkButton' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'but_dot' Name ' ' Text ':' Punctuation ' ' Text 'GtkButton' Name.Class '\n\n\t' Text 'var' Keyword ' ' Text 'context' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorContext' Name.Class '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'signal' Name '(' Punctuation ' ' Text 'sender' Name ',' Punctuation ' ' Text 'user_data' Name ' ' Text ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'after_point' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'after_point' Name '\n\t\t' Text 'if' Keyword ' ' Text 'after_point' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' \n\t\t ' Text 'after_point' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t\t' Text 'else' Keyword '\n\t\t ' Text 'after_point' Name ' ' Text '=' Operator ' ' Text '(' Punctuation 'after_point' Name '.' Punctuation 'abs' Name ')' Punctuation '\n\t\t' Text 'end' Keyword '\n\t\t\n\t\t' Text 'if' Keyword ' ' Text 'user_data' Name ' ' Text 'isa' Keyword ' ' Text 'Char' Name.Class ' ' Text 'then' Keyword ' ' Text '# is an operation' Comment.Single '\n\t\t\t' Text 'var' Keyword ' ' Text 'c' Name ' ' Text '=' Operator ' ' Text 'user_data' Name '\n\t\t\t' Text 'if' Keyword ' ' Text 'c' Name ' ' Text '==' Operator ' ' Text "'.'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t\t' Text 'but_dot' Name '.' Punctuation 'sensitive' Name '=' Operator ' ' Text 'false' Keyword '\n\t\t\t\t' Text 'context' Name '.' Punctuation 'switch_to_decimals' Name '\n\t\t\t\t' Text 'lbl_disp' Name '.' Punctuation 'text' Name ' ' Text '=' Operator ' ' Text '"{' Literal.String 'context' Name '.' Punctuation 'current' Name '.' Punctuation 'to_i' Name '}."' Literal.String '\n\t\t\t' Text 'else' Keyword '\n\t\t\t\t' Text 'but_dot' Name '.' Punctuation 'sensitive' Name '=' Operator ' ' Text 'true' Keyword '\n\t\t\t\t' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text 'c' Name ' ' Text ')' Punctuation '\n\t\t\t\t\n\t\t\t\t' Text 'var' Keyword ' ' Text 's' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision_native' Name '(6' Literal.Number.Float ')' Punctuation '\n\t\t\t\t' Text 'var' Keyword ' ' Text 'index' Name ' ' Text ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'Int' Name.Class ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t\t\t\t' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text 's' Name '.' Punctuation 'length' Name '.' Punctuation 'times' Name ' ' Text 'do' Keyword '\n\t\t\t\t ' Text 'var' Keyword ' ' Text 'chiffre' Name ' ' Text '=' Operator ' ' Text 's' Name '.' Punctuation 'chars' Name '[' Punctuation 'i' Name ']' Punctuation '\n\t\t\t\t ' Text 'if' Keyword ' ' Text 'chiffre' Name ' ' Text '==' Operator ' ' Text "'0'" Literal.String.Char ' ' Text 'and' Keyword ' ' Text 'index' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword '\n\t\t\t\t\t' Text 'index' Name ' ' Text '=' Operator ' ' Text 'i' Name '\n\t\t\t\t ' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'chiffre' Name ' ' Text '!=' Operator ' ' Text "'0'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t\t\t' Text 'index' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t\t\t\t ' Text 'end' Keyword '\n\t\t\t\t' Text 'end' Keyword '\n\t\t\t\t' Text 'if' Keyword ' ' Text 'index' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword '\n\t\t\t\t\t' Text 's' Name ' ' Text '=' Operator ' ' Text 's' Name '.' Punctuation 'substring' Name '(0' Literal.Number.Float ',' Punctuation ' ' Text 'index' Name ')' Punctuation '\n\t\t\t\t\t' Text 'if' Keyword ' ' Text 's' Name '.' Punctuation 'chars' Name '[' Punctuation 's' Name '.' Punctuation 'length' Name '-1' Literal.Number.Float ']' Punctuation ' ' Text '==' Operator ' ' Text "','" Literal.String.Char ' ' Text 'then' Keyword ' ' Text 's' Name ' ' Text '=' Operator ' ' Text 's' Name '.' Punctuation 'substring' Name '(0' Literal.Number.Float ',' Punctuation ' ' Text 's' Name '.' Punctuation 'length' Name '-1' Literal.Number.Float ')' Punctuation '\n\t\t\t\t' Text 'end' Keyword '\n\t\t\t\t' Text 'lbl_disp' Name '.' Punctuation 'text' Name ' ' Text '=' Operator ' ' Text 's' Name '\n\t\t\t' Text 'end' Keyword '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'user_data' Name ' ' Text 'isa' Keyword ' ' Text 'Int' Name.Class ' ' Text 'then' Keyword ' ' Text '# is a number' Comment.Single '\n\t\t\t' Text 'var' Keyword ' ' Text 'n' Name ' ' Text '=' Operator ' ' Text 'user_data' Name '\n\t\t\t' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' ' Text 'n' Name ' ' Text ')' Punctuation '\n\t\t\t' Text 'lbl_disp' Name '.' Punctuation 'text' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'current' Name '.' Punctuation 'to_precision_native' Name '(' Punctuation 'after_point' Name ')' Punctuation '\n\t\t' Text 'end' Keyword '\n\t' Text 'end' Keyword '\n\n\t' Text 'init' Keyword '\n\t' Text 'do' Keyword '\n\t\t' Text 'init_gtk' Name '\n\n\t\t' Text 'win' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkWindow' Name.Class '(' Punctuation ' 0' Literal.Number.Float ' ' Text ')' Punctuation '\n\n\t\t' Text 'container' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkGrid' Name.Class '(5' Literal.Number.Float ',5' Literal.Number.Float ',' Punctuation 'true' Name ')' Punctuation '\n\t\t' Text 'win' Name '.' Punctuation 'add' Name '(' Punctuation ' ' Text 'container' Name ' ' Text ')' Punctuation '\n\n\t\t' Text 'lbl_disp' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkLabel' Name.Class '(' Punctuation ' ' Text '"_"' Literal.String ' ' Text ')' Punctuation '\n\t\t' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'lbl_disp' Name ',' Punctuation ' 0' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float ',' Punctuation ' 5' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n\n\t\t' Text '# digits' Comment.Single '\n\t\t' Text 'for' Keyword ' ' Text 'n' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation '9' Literal.Number.Integer ']' Punctuation ' ' Text 'do' Keyword '\n\t\t\t' Text 'var' Keyword ' ' Text 'but' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkButton' Name.Class '.' Punctuation 'with_label' Name '(' Punctuation ' ' Text 'n' Name '.' Punctuation 'to_s' Name ' ' Text ')' Punctuation '\n\t\t\t' Text 'but' Name '.' Punctuation 'request_size' Name '(' Punctuation ' 64' Literal.Number.Float ',' Punctuation ' 64' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t\t' Text 'but' Name '.' Punctuation 'signal_connect' Name '(' Punctuation ' ' Text '"clicked"' Literal.String ',' Punctuation ' ' Text 'self' Name ',' Punctuation ' ' Text 'n' Name ' ' Text ')' Punctuation '\n\t\t\t' Text 'if' Keyword ' ' Text 'n' Name ' ' Text '==' Operator ' 0' Literal.Number.Float ' ' Text 'then' Keyword '\n\t\t\t\t' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'but' Name ',' Punctuation ' 0' Literal.Number.Float ',' Punctuation ' 4' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t\t' Text 'else' Keyword ' ' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'but' Name ',' Punctuation ' ' Text '(' Punctuation 'n' Name '-1' Literal.Number.Float ')' Punctuation '%3' Literal.Number.Float ',' Punctuation ' 3' Literal.Number.Float '-' Operator '(' Punctuation 'n' Name '-1' Literal.Number.Float ')' Punctuation '/3' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text '# operators' Comment.Single '\n\t\t' Text 'var' Keyword ' ' Text 'r' Name ' ' Text '=' Operator ' 1' Literal.Number.Float '\n\t\t' Text 'for' Keyword ' ' Text 'op' Name ' ' Text 'in' Keyword ' ' Text '[' Punctuation "'+'" Literal.String.Char ',' Punctuation ' ' Text "'-'" Literal.String.Char ',' Punctuation ' ' Text "'*'" Literal.String.Char ',' Punctuation ' ' Text "'/'" Literal.String.Char ' ' Text ']' Punctuation ' ' Text 'do' Keyword '\n\t\t\t' Text 'var' Keyword ' ' Text 'but' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkButton' Name.Class '.' Punctuation 'with_label' Name '(' Punctuation ' ' Text 'op' Name '.' Punctuation 'to_s' Name ' ' Text ')' Punctuation '\n\t\t\t' Text 'but' Name '.' Punctuation 'request_size' Name '(' Punctuation ' 64' Literal.Number.Float ',' Punctuation ' 64' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t\t' Text 'but' Name '.' Punctuation 'signal_connect' Name '(' Punctuation ' ' Text '"clicked"' Literal.String ',' Punctuation ' ' Text 'self' Name ',' Punctuation ' ' Text 'op' Name ' ' Text ')' Punctuation '\n\t\t\t' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'but' Name ',' Punctuation ' 3' Literal.Number.Float ',' Punctuation ' ' Text 'r' Name ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t\t' Text 'r' Name '+' Operator '=1' Literal.Number.Float '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text '# =' Comment.Single '\n\t\t' Text 'but_eq' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkButton' Name.Class '.' Punctuation 'with_label' Name '(' Punctuation ' ' Text '"="' Literal.String ' ' Text ')' Punctuation '\n\t\t' Text 'but_eq' Name '.' Punctuation 'request_size' Name '(' Punctuation ' 64' Literal.Number.Float ',' Punctuation ' 64' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t' Text 'but_eq' Name '.' Punctuation 'signal_connect' Name '(' Punctuation ' ' Text '"clicked"' Literal.String ',' Punctuation ' ' Text 'self' Name ',' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n\t\t' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'but_eq' Name ',' Punctuation ' 4' Literal.Number.Float ',' Punctuation ' 3' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n\n\t\t' Text '# .' Comment.Single '\n\t\t' Text 'but_dot' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkButton' Name.Class '.' Punctuation 'with_label' Name '(' Punctuation ' ' Text '"."' Literal.String ' ' Text ')' Punctuation '\n\t\t' Text 'but_dot' Name '.' Punctuation 'request_size' Name '(' Punctuation ' 64' Literal.Number.Float ',' Punctuation ' 64' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t' Text 'but_dot' Name '.' Punctuation 'signal_connect' Name '(' Punctuation ' ' Text '"clicked"' Literal.String ',' Punctuation ' ' Text 'self' Name ',' Punctuation ' ' Text "'.'" Literal.String.Char ' ' Text ')' Punctuation '\n\t\t' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'but_dot' Name ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 4' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n\n\t\t' Text '#C' Comment.Single '\n\t\t' Text 'var' Keyword ' ' Text 'but_c' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GtkButton' Name.Class '.' Punctuation 'with_label' Name '(' Punctuation ' ' Text '"C"' Literal.String ' ' Text ')' Punctuation '\n\t\t' Text 'but_c' Name '.' Punctuation 'request_size' Name '(' Punctuation ' 64' Literal.Number.Float ',' Punctuation ' 64' Literal.Number.Float ' ' Text ')' Punctuation '\n\t\t' Text 'but_c' Name '.' Punctuation 'signal_connect' Name '(' Punctuation '"clicked"' Literal.String ',' Punctuation ' ' Text 'self' Name ',' Punctuation ' ' Text "'C'" Literal.String.Char ')' Punctuation '\n\t\t' Text 'container' Name '.' Punctuation 'attach' Name '(' Punctuation ' ' Text 'but_c' Name ',' Punctuation ' 2' Literal.Number.Float ',' Punctuation ' 4' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n\n\t\t' Text 'win' Name '.' Punctuation 'show_all' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text '# context tests' Comment.Single '\n' Text 'var' Keyword ' ' Text 'context' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorContext' Name.Class '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'+'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 3' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'*'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'var' Keyword ' ' Text 'r' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'r' Name ' ' Text '==' Operator ' ' Text '"30.00"' Literal.String ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'r' Name '\n\n' Text 'context' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorContext' Name.Class '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 4' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'switch_to_decimals' Name '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'*'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 3' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'r' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'r' Name ' ' Text '==' Operator ' ' Text '"42.30"' Literal.String ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'r' Name '\n\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'+'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'r' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'r' Name ' ' Text '==' Operator ' ' Text '"53.30"' Literal.String ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'r' Name '\n\n' Text 'context' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorContext' Name.Class '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 4' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'switch_to_decimals' Name '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 3' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'/'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 3' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'r' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'r' Name ' ' Text '==' Operator ' ' Text '"14.10"' Literal.String ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'r' Name '\n\n' Text '#test multiple decimals' Comment.Single '\n' Text 'context' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorContext' Name.Class '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 5' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 0' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'switch_to_decimals' Name '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 2' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 3' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'+'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'r' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision' Name '(' Punctuation ' 3' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'r' Name ' ' Text '==' Operator ' ' Text '"51.123"' Literal.String ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'r' Name '\n\n' Text "#test 'C' button" Comment.Single '\n' Text 'context' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorContext' Name.Class '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 0' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'+'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_digit' Name '(' Punctuation ' 0' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'='" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'context' Name '.' Punctuation 'push_op' Name '(' Punctuation ' ' Text "'C'" Literal.String.Char ' ' Text ')' Punctuation '\n' Text 'r' Name ' ' Text '=' Operator ' ' Text 'context' Name '.' Punctuation 'result' Name '.' Punctuation 'to_precision' Name '(' Punctuation ' 1' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'r' Name ' ' Text '==' Operator ' ' Text '"0.0"' Literal.String ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'r' Name '\n\n' Text '# graphical application' Comment.Single '\n\n' Text 'if' Keyword ' ' Text '"NIT_TESTING"' Literal.String '.' Punctuation 'environ' Name ' ' Text '!=' Operator ' ' Text '"true"' Literal.String ' ' Text 'then' Keyword '\n\t' Text 'var' Keyword ' ' Text 'app' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CalculatorGui' Name.Class '\n\t' Text 'run_gtk' Name '\n' Text 'end' Keyword '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Matthieu Lucas ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# This sample has been implemented to show you how simple is it to play ' Comment.Single '\n' Text '# with native callbacks (C) through an high level with NIT program.' Comment.Single '\n\n' Text 'module' Keyword ' ' Text 'callback_chimpanze' Name '\n' Text 'import' Keyword ' ' Text 'callback_monkey' Name '\n\n' Text 'class' Keyword ' ' Text 'Chimpanze' Name.Class '\n\t' Text 'super' Keyword ' ' Text 'MonkeyActionCallable' Name.Class '\n\n\t' Text 'fun' Keyword ' ' Text 'create' Name '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'monkey' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Monkey' Name.Class '\n\t\t' Text 'print' Name ' ' Text '"Hum, I\'m sleeping ..."' Literal.String '\n\t\t' Text '# Invoking method which will take some time to compute, and ' Comment.Single '\n\t\t' Text '# will be back in wokeUp method with information.' Comment.Single '\n\t\t' Text '# - Callback method defined in MonkeyActionCallable Interface' Comment.Single '\n\t\t' Text 'monkey' Name '.' Punctuation 'wokeUpAction' Name '(' Punctuation 'self' Name ',' Punctuation ' ' Text '"Hey, I\'m awake."' Literal.String ')' Punctuation '\n\t' Text 'end' Keyword '\n\n\t' Text '# Inherit callback method, defined by MonkeyActionCallable interface' Comment.Single '\n\t' Text '# - Back of wokeUpAction method ' Comment.Single '\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'wokeUp' Name '(' Punctuation ' ' Text 'sender' Name ':' Punctuation 'Monkey' Name.Class ',' Punctuation ' ' Text 'message' Name ':' Punctuation 'Object' Name.Class ' ' Text ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'print' Name ' ' Text 'message' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'm' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Chimpanze' Name.Class '\n' Text 'm' Name '.' Punctuation 'create' Name '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Matthieu Lucas ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# This sample has been implemented to show you how simple is it to play ' Comment.Single '\n' Text '# with native callbacks (C) through an high level with NIT program.' Comment.Single '\n\n' Text 'module' Keyword ' ' Text 'callback_monkey' Name '\n\n' Text 'in' Keyword ' ' Text '"C header"' Literal.String ' ' Text '`{\n\t#include \n\t#include \n\n\ttypedef struct { \n\t\tint id;\n\t\tint age;\n\t} CMonkey;\n\n\ttypedef struct {\n\t\tMonkeyActionCallable toCall;\n\t\tObject message;\n\t} MonkeyAction;\n`}' Text '\n\n' Text 'in' Keyword ' ' Text '"C body"' Literal.String ' ' Text '`{\n\t// Method which reproduce a callback answer\n\t// Please note that a function pointer is only used to reproduce the callback\n\tvoid cbMonkey(CMonkey *mkey, void callbackFunc(CMonkey*, MonkeyAction*), MonkeyAction *data)\n\t{\n\t\tsleep(2);\n\t\tcallbackFunc( mkey, data );\n\t}\n\n\t// Back of background treatment, will be redirected to callback function\n\tvoid nit_monkey_callback_func( CMonkey *mkey, MonkeyAction *data )\n\t{\n\t\t// To call a your method, the signature must be written like this :\n\t\t// _...\n\t\tMonkeyActionCallable_wokeUp( data->toCall, mkey, data->message );\n\t}\n`}' Text '\n\n' Text '# Implementable interface to get callback in defined methods' Comment.Single '\n' Text 'interface' Keyword ' ' Text 'MonkeyActionCallable' Name.Class '\n\t' Text 'fun' Keyword ' ' Text 'wokeUp' Name '(' Punctuation ' ' Text 'sender' Name ':' Punctuation 'Monkey' Name.Class ',' Punctuation ' ' Text 'message' Name ':' Punctuation ' ' Text 'Object' Name.Class ')' Punctuation ' ' Text 'is' Keyword ' ' Text 'abstract' Keyword '\n' Text 'end' Keyword '\n\n' Text '# Defining my object type Monkey, which is, in a low level, a pointer to a C struct (CMonkey)' Comment.Single '\n' Text 'extern' Keyword ' ' Text 'class' Keyword ' ' Text 'Monkey' Name.Class ' ' Text '`{ CMonkey * `}' Text '\n\t\n\t' Text 'new' Keyword ' ' Text '`{\n\t\tCMonkey *monkey = malloc( sizeof(CMonkey) );\n\t\tmonkey->age = 10;\n\t\tmonkey->id = 1;\n\t\treturn monkey;\n\t`}' Text '\n\t\n\t' Text '# Object method which will get a callback in wokeUp method, defined in MonkeyActionCallable interface' Comment.Single '\n\t' Text '# Must be defined as Nit/C method because of C call inside' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'wokeUpAction' Name '(' Punctuation ' ' Text 'toCall' Name ':' Punctuation ' ' Text 'MonkeyActionCallable' Name.Class ',' Punctuation ' ' Text 'message' Name ':' Punctuation ' ' Text 'Object' Name.Class ' ' Text ')' Punctuation ' ' Text 'is' Keyword ' ' Text 'extern' Keyword ' ' Text 'import' Keyword ' ' Text 'MonkeyActionCallable' Name.Class '.' Punctuation 'wokeUp' Name ' ' Text '`{\n\n\t\t// Allocating memory to keep reference of received parameters :\n\t\t// - Object receiver\n\t\t// - Message \n\t\tMonkeyAction *data = malloc( sizeof(MonkeyAction) );\n\n\t\t// Incrementing reference counter to prevent from releasing\n\t\tMonkeyActionCallable_incr_ref( toCall );\n\t\tObject_incr_ref( message );\n\t\t\n\t\tdata->toCall = toCall;\n\t\tdata->message = message;\n\t\t\n\t\t// Calling method which reproduce a callback by passing :\n\t\t// - Receiver\n\t\t// - Function pointer to object return method\n\t\t// - Datas\n\t\tcbMonkey( recv, &nit_monkey_callback_func, data );\n\t`}' Text '\n' Text 'end' Keyword '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Implementation of circular lists' Comment.Single '\n' Text '# This example shows the usage of generics and somewhat a specialisation of collections.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'circular_list' Name '\n\n' Text '# Sequences of elements implemented with a double-linked circular list' Comment.Single '\n' Text 'class' Keyword ' ' Text 'CircularList' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\t' Text '# Like standard Array or LinkedList, CircularList is a Sequence.' Comment.Single '\n\t' Text 'super' Keyword ' ' Text 'Sequence' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\n\t' Text '# The first node of the list if any' Comment.Single '\n\t' Text '# The special case of an empty list is handled by a null node' Comment.Single '\n\t' Text 'private' Keyword ' ' Text 'var' Keyword ' ' Text 'node' Name ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'CLNode' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'iterator' Name ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text 'new' Keyword ' ' Text 'CircularListIterator' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '(' Punctuation 'self' Name ')' Punctuation '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'first' Name ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'node' Name '.' Punctuation 'item' Name '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'push' Name '(' Punctuation 'e' Name ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'new_node' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CLNode' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '(' Punctuation 'e' Name ')' Punctuation '\n\t\t' Text 'var' Keyword ' ' Text 'n' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'node' Name '\n\t\t' Text 'if' Keyword ' ' Text 'n' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword '\n\t\t\t' Text '# the first node' Comment.Single '\n\t\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'new_node' Name '\n\t\t' Text 'else' Keyword '\n\t\t\t' Text '# not the first one, so attach nodes correctly.' Comment.Single '\n\t\t\t' Text 'var' Keyword ' ' Text 'old_last_node' Name ' ' Text '=' Operator ' ' Text 'n' Name '.' Punctuation 'prev' Name '\n\t\t\t' Text 'new_node' Name '.' Punctuation 'next' Name ' ' Text '=' Operator ' ' Text 'n' Name '\n\t\t\t' Text 'new_node' Name '.' Punctuation 'prev' Name ' ' Text '=' Operator ' ' Text 'old_last_node' Name '\n\t\t\t' Text 'old_last_node' Name '.' Punctuation 'next' Name ' ' Text '=' Operator ' ' Text 'new_node' Name '\n\t\t\t' Text 'n' Name '.' Punctuation 'prev' Name ' ' Text '=' Operator ' ' Text 'new_node' Name '\n\t\t' Text 'end' Keyword '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'pop' Name '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'n' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'node' Name '\n\t\t' Text 'assert' Keyword ' ' Text 'n' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'prev' Name ' ' Text '=' Operator ' ' Text 'n' Name '.' Punctuation 'prev' Name '\n\t\t' Text 'if' Keyword ' ' Text 'prev' Name ' ' Text '==' Operator ' ' Text 'n' Name ' ' Text 'then' Keyword '\n\t\t\t' Text '# the only node' Comment.Single '\n\t\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text 'n' Name '.' Punctuation 'item' Name '\n\t\t' Text 'end' Keyword '\n\t\t' Text '# not the only one do detach nodes correctly.' Comment.Single '\n\t\t' Text 'var' Keyword ' ' Text 'prev_prev' Name ' ' Text '=' Operator ' ' Text 'prev' Name '.' Punctuation 'prev' Name '\n\t\t' Text 'n' Name '.' Punctuation 'prev' Name ' ' Text '=' Operator ' ' Text 'prev_prev' Name '\n\t\t' Text 'prev_prev' Name '.' Punctuation 'next' Name ' ' Text '=' Operator ' ' Text 'n' Name '\n\t\t' Text 'return' Keyword ' ' Text 'prev' Name '.' Punctuation 'item' Name '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'unshift' Name '(' Punctuation 'e' Name ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text '# Circularity has benefits.' Comment.Single '\n\t\t' Text 'push' Name '(' Punctuation 'e' Name ')' Punctuation '\n\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'node' Name '.' Punctuation 'prev' Name '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'shift' Name '\n\t' Text 'do' Keyword '\n\t\t' Text '# Circularity has benefits.' Comment.Single '\n\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'node' Name '.' Punctuation 'next' Name '\n\t\t' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'pop' Name '\n\t' Text 'end' Keyword '\n\n\t' Text '# Move the first at the last position, the second at the first, etc.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'rotate' Name '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'n' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'node' Name '\n\t\t' Text 'if' Keyword ' ' Text 'n' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'return' Keyword '\n\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'n' Name '.' Punctuation 'next' Name '\n\t' Text 'end' Keyword '\n\n\t' Text '# Sort the list using the Josephus algorithm.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'josephus' Name '(' Punctuation 'step' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'res' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CircularList' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\t\t' Text 'while' Keyword ' ' Text 'not' Keyword ' ' Text 'self' Name '.' Punctuation 'is_empty' Name ' ' Text 'do' Keyword '\n\t\t\t' Text "# count 'step'" Comment.Single '\n\t\t\t' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text '[1' Literal.Number.Float '..' Punctuation 'step' Name '[' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'rotate' Name '\n\t\t\t' Text '# kill' Comment.Single '\n\t\t\t' Text 'var' Keyword ' ' Text 'x' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'shift' Name '\n\t\t\t' Text 'res' Name '.' Punctuation 'add' Name '(' Punctuation 'x' Name ')' Punctuation '\n\t\t' Text 'end' Keyword '\n\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'res' Name '.' Punctuation 'node' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text '# Nodes of a CircularList' Comment.Single '\n' Text 'private' Keyword ' ' Text 'class' Keyword ' ' Text 'CLNode' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\t' Text '# The current item' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'item' Name ':' Punctuation ' ' Text 'E' Name.Class '\n\n\t' Text '# The next item in the circular list.' Comment.Single '\n\t' Text '# Because of circularity, there is always a next;' Comment.Single '\n\t' Text '# so by default let it be self' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'next' Name ':' Punctuation ' ' Text 'CLNode' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation ' ' Text '=' Operator ' ' Text 'self' Keyword '\n\n\t' Text '# The previous item in the circular list.' Comment.Single '\n\t' Text '# Coherence between next and previous nodes has to be maintained by the' Comment.Single '\n\t' Text '# circular list.' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'prev' Name ':' Punctuation ' ' Text 'CLNode' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation ' ' Text '=' Operator ' ' Text 'self' Keyword '\n' Text 'end' Keyword '\n\n' Text '# An iterator of a CircularList.' Comment.Single '\n' Text 'private' Keyword ' ' Text 'class' Keyword ' ' Text 'CircularListIterator' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\t' Text 'super' Keyword ' ' Text 'IndexedIterator' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\n\t' Text 'redef' Keyword ' ' Text 'var' Keyword ' ' Text 'index' Name ':' Punctuation ' ' Text 'Int' Name.Class '\n\n\t' Text '# The current node pointed.' Comment.Single '\n\t' Text '# Is null if the list is empty.' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'node' Name ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'CLNode' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\n\t' Text '# The list iterated.' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'list' Name ':' Punctuation ' ' Text 'CircularList' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'is_ok' Name '\n\t' Text 'do' Keyword '\n\t\t' Text '# Empty lists are not OK.' Comment.Single '\n\t\t' Text '# Pointing again the first node is not OK.' Comment.Single '\n\t\t' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword ' ' Text 'and' Keyword ' ' Text '(' Punctuation 'self' Name '.' Punctuation 'index' Name ' ' Text '==' Operator ' 0' Literal.Number.Float ' ' Text 'or' Keyword ' ' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '!=' Operator ' ' Text 'self' Name '.' Punctuation 'list' Name '.' Punctuation 'node' Name ')' Punctuation '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'next' Name '\n\t' Text 'do' Keyword '\n\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'node' Name '.' Punctuation 'next' Name '\n\t\t' Text 'self' Name '.' Punctuation 'index' Name ' ' Text '+' Operator '=' Operator ' 1' Literal.Number.Float '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'item' Name ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'node' Name '.' Punctuation 'item' Name '\n\n\t' Text 'init' Keyword '(' Punctuation 'list' Name ':' Punctuation ' ' Text 'CircularList' Name.Class '[' Punctuation 'E' Name.Class ']' Punctuation ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'self' Name '.' Punctuation 'node' Name ' ' Text '=' Operator ' ' Text 'list' Name '.' Punctuation 'node' Name '\n\t\t' Text 'self' Name '.' Punctuation 'list' Name ' ' Text '=' Operator ' ' Text 'list' Name '\n\t\t' Text 'self' Name '.' Punctuation 'index' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'i' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CircularList' Name.Class '[' Punctuation 'Int' Name.Class ']' Punctuation '\n' Text 'i' Name '.' Punctuation 'add_all' Name '(' Punctuation '[1' Literal.Number.Float ',' Punctuation ' 2' Literal.Number.Float ',' Punctuation ' 3' Literal.Number.Float ',' Punctuation ' 4' Literal.Number.Float ',' Punctuation ' 5' Literal.Number.Float ',' Punctuation ' 6' Literal.Number.Float ',' Punctuation ' 7' Literal.Number.Float ']' Punctuation ')' Punctuation '\n' Text 'print' Name ' ' Text 'i' Name '.' Punctuation 'first' Name '\n' Text 'print' Name ' ' Text 'i' Name '.' Punctuation 'join' Name '(' Punctuation '":"' Literal.String ')' Punctuation '\n\n' Text 'i' Name '.' Punctuation 'push' Name '(8' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text 'i' Name '.' Punctuation 'shift' Name '\n' Text 'print' Name ' ' Text 'i' Name '.' Punctuation 'pop' Name '\n' Text 'i' Name '.' Punctuation 'unshift' Name '(0' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text 'i' Name '.' Punctuation 'join' Name '(' Punctuation '":"' Literal.String ')' Punctuation '\n\n' Text 'i' Name '.' Punctuation 'josephus' Name '(3' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text 'i' Name '.' Punctuation 'join' Name '(' Punctuation '":"' Literal.String ')' Punctuation '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# This module beef up the clock module by allowing a clock to be comparable.' Comment.Single '\n' Text '# It show the usage of class refinement' Comment.Single '\n' Text 'module' Keyword ' ' Text 'clock_more' Name '\n\n' Text 'import' Keyword ' ' Text 'clock' Name '\n\n' Text 'redef' Keyword ' ' Text 'class' Keyword ' ' Text 'Clock' Name.Class '\n\t' Text '# Clock are now comparable' Comment.Single '\n\t' Text 'super' Keyword ' ' Text 'Comparable' Name.Class '\n\n\t' Text '# Comparaison of a clock make only sense with an other clock' Comment.Single '\n\t' Text 'redef' Keyword ' ' Text 'type' Keyword ' ' Text 'OTHER' Name.Class ':' Punctuation ' ' Text 'Clock' Name.Class '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text '<' Operator '(' Punctuation 'o' Name ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text '# Note: < is the only abstract method of Comparable.' Comment.Single '\n\t\t' Text '# All other operators and methods rely on < and ==.' Comment.Single '\n\t\t' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '<' Operator ' ' Text 'o' Name '.' Punctuation 'total_minutes' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'c1' Literal.Number.Float ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Clock' Name.Class '(8' Literal.Number.Float ',' Punctuation ' 12' Literal.Number.Float ')' Punctuation '\n' Text 'var' Keyword ' ' Text 'c2' Literal.Number.Float ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Clock' Name.Class '(8' Literal.Number.Float ',' Punctuation ' 13' Literal.Number.Float ')' Punctuation '\n' Text 'var' Keyword ' ' Text 'c3' Literal.Number.Float ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Clock' Name.Class '(9' Literal.Number.Float ',' Punctuation ' 13' Literal.Number.Float ')' Punctuation '\n\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}<{' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '<' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}<={' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '<=' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}>{' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '>' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}>={' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '>=' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}<=>{' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '<=' Operator '>' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '},{' Literal.String 'c2' Literal.Number.Float '}? max={' Literal.String 'c1' Literal.Number.Float '.' Punctuation 'max' Name '(' Punctuation 'c2' Literal.Number.Float ')' Punctuation '} min={' Literal.String 'c1' Literal.Number.Float '.' Punctuation 'min' Name '(' Punctuation 'c2' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}.is_between({' Literal.String 'c2' Literal.Number.Float '}, {' Literal.String 'c3' Literal.Number.Float '})? {' Literal.String 'c1' Literal.Number.Float '.' Punctuation 'is_between' Name '(' Punctuation 'c2' Literal.Number.Float ',' Punctuation ' ' Text 'c3' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c2' Literal.Number.Float '}.is_between({' Literal.String 'c1' Literal.Number.Float '}, {' Literal.String 'c3' Literal.Number.Float '})? {' Literal.String 'c2' Literal.Number.Float '.' Punctuation 'is_between' Name '(' Punctuation 'c1' Literal.Number.Float ',' Punctuation ' ' Text 'c3' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n\n' Text 'print' Name ' ' Text '"-"' Literal.String '\n\n' Text 'c1' Literal.Number.Float '.' Punctuation 'minutes' Name ' ' Text '+' Operator '=' Operator ' 1' Literal.Number.Float '\n\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}<{' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '<' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}<={' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '<=' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}>{' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '>' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}>={' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '>=' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}<=>{' Literal.String 'c2' Literal.Number.Float '}? {' Literal.String 'c1' Literal.Number.Float '<=' Operator '>' Operator 'c2' Literal.Number.Float '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '},{' Literal.String 'c2' Literal.Number.Float '}? max={' Literal.String 'c1' Literal.Number.Float '.' Punctuation 'max' Name '(' Punctuation 'c2' Literal.Number.Float ')' Punctuation '} min={' Literal.String 'c1' Literal.Number.Float '.' Punctuation 'min' Name '(' Punctuation 'c2' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c1' Literal.Number.Float '}.is_between({' Literal.String 'c2' Literal.Number.Float '}, {' Literal.String 'c3' Literal.Number.Float '})? {' Literal.String 'c1' Literal.Number.Float '.' Punctuation 'is_between' Name '(' Punctuation 'c2' Literal.Number.Float ',' Punctuation ' ' Text 'c3' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n' Text 'print' Name ' ' Text '"{' Literal.String 'c2' Literal.Number.Float '}.is_between({' Literal.String 'c1' Literal.Number.Float '}, {' Literal.String 'c3' Literal.Number.Float '})? {' Literal.String 'c2' Literal.Number.Float '.' Punctuation 'is_between' Name '(' Punctuation 'c1' Literal.Number.Float ',' Punctuation ' ' Text 'c3' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# This module provide a simple wall clock.' Comment.Single '\n' Text '# It is an example of getters and setters.' Comment.Single '\n' Text '# A beefed-up module is available in clock_more' Comment.Single '\n' Text 'module' Keyword ' ' Text 'clock' Name '\n\n' Text '# A simple wall clock with 60 minutes and 12 hours.' Comment.Single '\n' Text 'class' Keyword ' ' Text 'Clock' Name.Class '\n\t' Text '# total number of minutes from 0 to 719' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'total_minutes' Name ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text '# Note: only the read acces is public, the write access is private.' Comment.Single '\n\n\t' Text '# number of minutes in the current hour (from 0 to 59)' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'minutes' Name ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '%' Operator ' 60' Literal.Number.Float '\n\t\n\t' Text '# set the number of minutes in the current hour.' Comment.Single '\n\t' Text '# if m < 0 or m >= 60, the hour will be changed accordinlgy' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'minutes' Name '=' Operator '(' Punctuation 'm' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'hours' Name ' ' Text '*' Operator ' 60' Literal.Number.Float ' ' Text '+' Operator ' ' Text 'm' Name '\n\n\t' Text '# number of hours (from 0 to 11)' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'hours' Name ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '/' Operator ' 60' Literal.Number.Float '\n\n\t' Text '# set the number of hours' Comment.Single '\n\t' Text '# the minutes will not be updated' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'hours' Name '=' Operator '(' Punctuation 'h' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '=' Operator ' ' Text 'h' Name ' ' Text '*' Operator ' 60' Literal.Number.Float ' ' Text '+' Operator ' ' Text 'minutes' Name '\n\n\t' Text '# the position of the hour arrow in the [0..60[ interval' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'hour_pos' Name ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text 'total_minutes' Name ' ' Text '/' Operator ' 12' Literal.Number.Float '\n\n\t' Text '# replace the arrow of hours (from 0 to 59).' Comment.Single '\n\t' Text '# the hours and the minutes will be updated.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'hour_pos' Name '=' Operator '(' Punctuation 'h' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '=' Operator ' ' Text 'h' Name ' ' Text '*' Operator ' 12' Literal.Number.Float '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'to_s' Name ' ' Text 'do' Keyword ' ' Text 'return' Keyword ' ' Text '"{' Literal.String 'hours' Name '}:{' Literal.String 'minutes' Name '}"' Literal.String '\n\n\t' Text 'fun' Keyword ' ' Text 'reset' Name '(' Punctuation 'hours' Name ',' Punctuation ' ' Text 'minutes' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '=' Operator ' ' Text 'hours' Name '*60' Literal.Number.Float ' ' Text '+' Operator ' ' Text 'minutes' Name '\n\n\t' Text 'init' Keyword '(' Punctuation 'hours' Name ',' Punctuation ' ' Text 'minutes' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'reset' Name '(' Punctuation 'hours' Name ',' Punctuation ' ' Text 'minutes' Name ')' Punctuation '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text '==' Operator '(' Punctuation 'o' Name ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text '# Note: o is a nullable Object, a type test is required' Comment.Single '\n\t\t' Text '# Thanks to adaptive typing, there is no downcast' Comment.Single '\n\t\t' Text '# i.e. the code is safe!' Comment.Single '\n\t\t' Text 'return' Keyword ' ' Text 'o' Name ' ' Text 'isa' Keyword ' ' Text 'Clock' Name.Class ' ' Text 'and' Keyword ' ' Text 'self' Name '.' Punctuation 'total_minutes' Name ' ' Text '==' Operator ' ' Text 'o' Name '.' Punctuation 'total_minutes' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'c' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Clock' Name.Class '(10' Literal.Number.Float ',50' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text '"It\'s {' Literal.String 'c' Name '} o\'clock."' Literal.String '\n\n' Text 'c' Name '.' Punctuation 'minutes' Name ' ' Text '+' Operator '=' Operator ' 22' Literal.Number.Float '\n' Text 'print' Name ' ' Text '"Now it\'s {' Literal.String 'c' Name '} o\'clock."' Literal.String '\n\n' Text 'print' Name ' ' Text '"The short arrow in on the {' Literal.String 'c' Name '.' Punctuation 'hour_pos' Name '/5' Literal.Number.Float '} and the long arrow in on the {' Literal.String 'c' Name '.' Punctuation 'minutes' Name '/5' Literal.Number.Float '}."' Literal.String '\n\n' Text 'c' Name '.' Punctuation 'hours' Name ' ' Text '-' Operator '=' Operator ' 2' Literal.Number.Float '\n' Text 'print' Name ' ' Text '"Now it\'s {' Literal.String 'c' Name '} o\'clock."' Literal.String '\n\n' Text 'var' Keyword ' ' Text 'c2' Literal.Number.Float ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Clock' Name.Class '(9' Literal.Number.Float ',' Punctuation ' 11' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text '"It\'s {' Literal.String 'c2' Literal.Number.Float '} on the second clock."' Literal.String '\n' Text 'print' Name ' ' Text '"The two clocks are synchronized: {' Literal.String 'c' Name ' ' Text '==' Operator ' ' Text 'c2' Literal.Number.Float '}."' Literal.String '\n' Text 'c2' Literal.Number.Float '.' Punctuation 'minutes' Name ' ' Text '+' Operator '=' Operator ' 1' Literal.Number.Float '\n' Text 'print' Name ' ' Text '"It\'s now {' Literal.String 'c2' Literal.Number.Float '} on the second clock."' Literal.String '\n' Text 'print' Name ' ' Text '"The two clocks are synchronized: {' Literal.String 'c' Name ' ' Text '==' Operator ' ' Text 'c2' Literal.Number.Float '}."' Literal.String '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Matthieu Lucas ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Sample of the Curl module.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'curl_http' Name '\n\n' Text 'import' Keyword ' ' Text 'curl' Name '\n\n' Text '# Small class to represent an Http Fetcher' Comment.Single '\n' Text 'class' Keyword ' ' Text 'MyHttpFetcher' Name.Class '\n\t' Text 'super' Keyword ' ' Text 'CurlCallbacks' Name.Class '\n\n\t' Text 'var' Keyword ' ' Text 'curl' Name ':' Punctuation ' ' Text 'Curl' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'our_body' Name ':' Punctuation ' ' Text 'String' Name.Class ' ' Text '=' Operator ' ' Text '""' Literal.String '\n\n\t' Text 'init' Keyword '(' Punctuation 'curl' Name ':' Punctuation ' ' Text 'Curl' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'curl' Name ' ' Text '=' Operator ' ' Text 'curl' Name '\n\n\t' Text '# Release curl object' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'destroy' Name ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'curl' Name '.' Punctuation 'destroy' Name '\n\n\t' Text '# Header callback' Comment.Single '\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'header_callback' Name '(' Punctuation 'line' Name ':' Punctuation ' ' Text 'String' Name.Class ')' Punctuation ' ' Text 'do' Keyword '\n\t\t' Text '# We keep this callback silent for testing purposes' Comment.Single '\n\t\t' Text '#if not line.has_prefix("Date:") then print "Header_callback : {line}"' Comment.Single '\n\t' Text 'end' Keyword '\n\n\t' Text '# Body callback' Comment.Single '\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'body_callback' Name '(' Punctuation 'line' Name ':' Punctuation ' ' Text 'String' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'self' Name '.' Punctuation 'our_body' Name ' ' Text '=' Operator ' ' Text '"{' Literal.String 'self' Name '.' Punctuation 'our_body' Name '}{' Literal.String 'line' Name '}"' Literal.String '\n\n\t' Text '# Stream callback - Cf : No one is registered' Comment.Single '\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'stream_callback' Name '(' Punctuation 'buffer' Name ':' Punctuation ' ' Text 'String' Name.Class ',' Punctuation ' ' Text 'size' Name ':' Punctuation ' ' Text 'Int' Name.Class ',' Punctuation ' ' Text 'count' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ' ' Text 'do' Keyword ' ' Text 'print' Name ' ' Text '"Stream_callback : {' Literal.String 'buffer' Name '} - {' Literal.String 'size' Name '} - {' Literal.String 'count' Name '}"' Literal.String '\n' Text 'end' Keyword '\n\n\n' Text '# Program' Comment.Single '\n' Text 'if' Keyword ' ' Text 'args' Name '.' Punctuation 'length' Name ' ' Text '<' Operator ' 2' Literal.Number.Float ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Usage: curl_http "' Literal.String '\n' Text 'else' Keyword '\n\t' Text 'var' Keyword ' ' Text 'curl' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Curl' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'url' Name ' ' Text '=' Operator ' ' Text 'args' Name '[1' Literal.Number.Float ']' Punctuation '\n\t' Text 'var' Keyword ' ' Text 'request' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CurlHTTPRequest' Name.Class '(' Punctuation 'url' Name ',' Punctuation ' ' Text 'curl' Name ')' Punctuation '\n\n\t' Text '# HTTP Get Request' Comment.Single '\n\t' Text 'if' Keyword ' ' Text 'args' Name '[0' Literal.Number.Float ']' Punctuation ' ' Text '==' Operator ' ' Text '"GET"' Literal.String ' ' Text 'then' Keyword '\n\t\t' Text 'request' Name '.' Punctuation 'verbose' Name ' ' Text '=' Operator ' ' Text 'false' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'getResponse' Name ' ' Text '=' Operator ' ' Text 'request' Name '.' Punctuation 'execute' Name '\n\n\t\t' Text 'if' Keyword ' ' Text 'getResponse' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseSuccess' Name.Class ' ' Text 'then' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '"Status code : {' Literal.String 'getResponse' Name '.' Punctuation 'status_code' Name '}"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Body : {' Literal.String 'getResponse' Name '.' Punctuation 'body_str' Name '}"' Literal.String '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'getResponse' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseFailed' Name.Class ' ' Text 'then' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '"Error code : {' Literal.String 'getResponse' Name '.' Punctuation 'error_code' Name '}"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Error msg : {' Literal.String 'getResponse' Name '.' Punctuation 'error_msg' Name '}"' Literal.String '\n\t\t' Text 'end' Keyword '\n\n\t' Text '# HTTP Post Request' Comment.Single '\n\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'args' Name '[0' Literal.Number.Float ']' Punctuation ' ' Text '==' Operator ' ' Text '"POST"' Literal.String ' ' Text 'then' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'myHttpFetcher' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'MyHttpFetcher' Name.Class '(' Punctuation 'curl' Name ')' Punctuation '\n\t\t' Text 'request' Name '.' Punctuation 'delegate' Name ' ' Text '=' Operator ' ' Text 'myHttpFetcher' Name '\n\n\t\t' Text 'var' Keyword ' ' Text 'postDatas' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'HeaderMap' Name.Class '\n\t\t' Text 'postDatas' Name '[' Punctuation '"Bugs Bunny"' Literal.String ']' Punctuation ' ' Text '=' Operator ' ' Text '"Daffy Duck"' Literal.String '\n\t\t' Text 'postDatas' Name '[' Punctuation '"Batman"' Literal.String ']' Punctuation ' ' Text '=' Operator ' ' Text '"Robin likes special characters @#ùà!è§\'(\\"é&://,;<>∞~*"' Literal.String '\n\t\t' Text 'postDatas' Name '[' Punctuation '"Batman"' Literal.String ']' Punctuation ' ' Text '=' Operator ' ' Text '"Yes you can set multiple identical keys, but APACHE will consider only once, the last one"' Literal.String '\n\t\t' Text 'request' Name '.' Punctuation 'datas' Name ' ' Text '=' Operator ' ' Text 'postDatas' Name '\n\t\t' Text 'request' Name '.' Punctuation 'verbose' Name ' ' Text '=' Operator ' ' Text 'false' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'postResponse' Name ' ' Text '=' Operator ' ' Text 'request' Name '.' Punctuation 'execute' Name '\n\n\t\t' Text 'print' Name ' ' Text '"Our body from the callback : {' Literal.String 'myHttpFetcher' Name '.' Punctuation 'our_body' Name '}"' Literal.String '\n\n\t\t' Text 'if' Keyword ' ' Text 'postResponse' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseSuccess' Name.Class ' ' Text 'then' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '"*** Answer ***"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Status code : {' Literal.String 'postResponse' Name '.' Punctuation 'status_code' Name '}"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Body should be empty, because we decided to manage callbacks : {' Literal.String 'postResponse' Name '.' Punctuation 'body_str' Name '.' Punctuation 'length' Name '}"' Literal.String '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'postResponse' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseFailed' Name.Class ' ' Text 'then' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '"Error code : {' Literal.String 'postResponse' Name '.' Punctuation 'error_code' Name '}"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Error msg : {' Literal.String 'postResponse' Name '.' Punctuation 'error_msg' Name '}"' Literal.String '\n\t\t' Text 'end' Keyword '\n\n\t' Text '# HTTP Get to file Request' Comment.Single '\n\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'args' Name '[0' Literal.Number.Float ']' Punctuation ' ' Text '==' Operator ' ' Text '"GET_FILE"' Literal.String ' ' Text 'then' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'headers' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'HeaderMap' Name.Class '\n\t\t' Text 'headers' Name '[' Punctuation '"Accept"' Literal.String ']' Punctuation ' ' Text '=' Operator ' ' Text '"Moo"' Literal.String '\n\t\t' Text 'request' Name '.' Punctuation 'headers' Name ' ' Text '=' Operator ' ' Text 'headers' Name '\n\t\t' Text 'request' Name '.' Punctuation 'verbose' Name ' ' Text '=' Operator ' ' Text 'false' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'downloadResponse' Name ' ' Text '=' Operator ' ' Text 'request' Name '.' Punctuation 'download_to_file' Name '(' Punctuation 'null' Name ')' Punctuation '\n\n\t\t' Text 'if' Keyword ' ' Text 'downloadResponse' Name ' ' Text 'isa' Keyword ' ' Text 'CurlFileResponseSuccess' Name.Class ' ' Text 'then' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '"*** Answer ***"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Status code : {' Literal.String 'downloadResponse' Name '.' Punctuation 'status_code' Name '}"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Size downloaded : {' Literal.String 'downloadResponse' Name '.' Punctuation 'size_download' Name '}"' Literal.String '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'downloadResponse' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseFailed' Name.Class ' ' Text 'then' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '"Error code : {' Literal.String 'downloadResponse' Name '.' Punctuation 'error_code' Name '}"' Literal.String '\n\t\t\t' Text 'print' Name ' ' Text '"Error msg : {' Literal.String 'downloadResponse' Name '.' Punctuation 'error_msg' Name '}"' Literal.String '\n\t\t' Text 'end' Keyword '\n\t' Text '# Program logic' Comment.Single '\n\t' Text 'else' Keyword '\n\t\t' Text 'print' Name ' ' Text '"Usage : Method[POST, GET, GET_FILE]"' Literal.String '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Matthieu Lucas ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Mail sender sample using the Curl module' Comment.Single '\n' Text 'module' Keyword ' ' Text 'curl_mail' Name '\n\n' Text 'import' Keyword ' ' Text 'curl' Name '\n\n' Text 'var' Keyword ' ' Text 'curl' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Curl' Name.Class '\n' Text 'var' Keyword ' ' Text 'mail_request' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'CurlMailRequest' Name.Class '(' Punctuation 'curl' Name ')' Punctuation '\n\n' Text '# Networks' Comment.Single '\n' Text 'var' Keyword ' ' Text 'response' Name ' ' Text '=' Operator ' ' Text 'mail_request' Name '.' Punctuation 'set_outgoing_server' Name '(' Punctuation '"smtps://smtp.example.org:465"' Literal.String ',' Punctuation ' ' Text '"user@example.org"' Literal.String ',' Punctuation ' ' Text '"mypassword"' Literal.String ')' Punctuation '\n' Text 'if' Keyword ' ' Text 'response' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseFailed' Name.Class ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Error code : {' Literal.String 'response' Name '.' Punctuation 'error_code' Name '}"' Literal.String '\n\t' Text 'print' Name ' ' Text '"Error msg : {' Literal.String 'response' Name '.' Punctuation 'error_msg' Name '}"' Literal.String '\n' Text 'end' Keyword '\n\n' Text '# Headers' Comment.Single '\n' Text 'mail_request' Name '.' Punctuation 'from' Name ' ' Text '=' Operator ' ' Text '"Billy Bob"' Literal.String '\n' Text 'mail_request' Name '.' Punctuation 'to' Name ' ' Text '=' Operator ' ' Text '[' Punctuation '"user@example.org"' Literal.String ']' Punctuation '\n' Text 'mail_request' Name '.' Punctuation 'cc' Name ' ' Text '=' Operator ' ' Text '[' Punctuation '"bob@example.org"' Literal.String ']' Punctuation '\n' Text 'mail_request' Name '.' Punctuation 'bcc' Name ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\n' Text 'var' Keyword ' ' Text 'headers_body' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'HeaderMap' Name.Class '\n' Text 'headers_body' Name '[' Punctuation '"Content-Type:"' Literal.String ']' Punctuation ' ' Text '=' Operator ' ' Text '"text/html; charset=\\"UTF-8\\""' Literal.String '\n' Text 'headers_body' Name '[' Punctuation '"Content-Transfer-Encoding:"' Literal.String ']' Punctuation ' ' Text '=' Operator ' ' Text '"quoted-printable"' Literal.String '\n' Text 'mail_request' Name '.' Punctuation 'headers_body' Name ' ' Text '=' Operator ' ' Text 'headers_body' Name '\n\n' Text '# Content' Comment.Single '\n' Text 'mail_request' Name '.' Punctuation 'body' Name ' ' Text '=' Operator ' ' Text '"

Here you can write HTML stuff.

"' Literal.String '\n' Text 'mail_request' Name '.' Punctuation 'subject' Name ' ' Text '=' Operator ' ' Text '"Hello From My Nit Program"' Literal.String '\n\n' Text '# Others' Comment.Single '\n' Text 'mail_request' Name '.' Punctuation 'verbose' Name ' ' Text '=' Operator ' ' Text 'false' Keyword '\n\n' Text '# Send mail' Comment.Single '\n' Text 'response' Name ' ' Text '=' Operator ' ' Text 'mail_request' Name '.' Punctuation 'execute' Name '\n' Text 'if' Keyword ' ' Text 'response' Name ' ' Text 'isa' Keyword ' ' Text 'CurlResponseFailed' Name.Class ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Error code : {' Literal.String 'response' Name '.' Punctuation 'error_code' Name '}"' Literal.String '\n\t' Text 'print' Name ' ' Text '"Error msg : {' Literal.String 'response' Name '.' Punctuation 'error_msg' Name '}"' Literal.String '\n' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'response' Name ' ' Text 'isa' Keyword ' ' Text 'CurlMailResponseSuccess' Name.Class ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Mail Sent"' Literal.String '\n' Text 'else' Keyword '\n\t' Text 'print' Name ' ' Text '"Unknown Curl Response type"' Literal.String '\n' Text 'end' Keyword '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2012-2013 Alexis Laferrière ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Draws an arithmetic operation to the terminal' Comment.Single '\n' Text 'module' Keyword ' ' Text 'draw_operation' Name '\n\n' Text 'redef' Keyword ' ' Text 'enum' Keyword ' ' Text 'Int' Name.Class '\n\t' Text 'fun' Keyword ' ' Text 'n_chars' Name ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text '`{\n\t\tint c;\n\t\tif ( abs(recv) >= 10 )\n\t\t\tc = 1+(int)log10f( (float)abs(recv) );\n\t\telse\n\t\t\tc = 1;\n\t\tif ( recv < 0 ) c ++;\n\t\treturn c;\n\t`}' Text '\n' Text 'end' Keyword '\n\n' Text 'redef' Keyword ' ' Text 'enum' Keyword ' ' Text 'Char' Name.Class '\n\t' Text 'fun' Keyword ' ' Text 'as_operator' Name '(' Punctuation 'a' Name ',' Punctuation ' ' Text 'b' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text 'do' Keyword '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'+'" Literal.String.Char ' ' Text 'then' Keyword ' ' Text 'return' Keyword ' ' Text 'a' Name ' ' Text '+' Operator ' ' Text 'b' Name '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'-'" Literal.String.Char ' ' Text 'then' Keyword ' ' Text 'return' Keyword ' ' Text 'a' Name ' ' Text '-' Operator ' ' Text 'b' Name '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'*'" Literal.String.Char ' ' Text 'then' Keyword ' ' Text 'return' Keyword ' ' Text 'a' Name ' ' Text '*' Operator ' ' Text 'b' Name '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'/'" Literal.String.Char ' ' Text 'then' Keyword ' ' Text 'return' Keyword ' ' Text 'a' Name ' ' Text '/' Operator ' ' Text 'b' Name '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'%'" Literal.String.Char ' ' Text 'then' Keyword ' ' Text 'return' Keyword ' ' Text 'a' Name ' ' Text '%' Operator ' ' Text 'b' Name '\n\t\t' Text 'abort' Keyword '\n\t' Text 'end' Keyword '\n\n\t' Text 'fun' Keyword ' ' Text 'override_dispc' Name ':' Punctuation ' ' Text 'Bool' Name.Class '\n\t' Text 'do' Keyword '\n\t\t' Text 'return' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'+'" Literal.String.Char ' ' Text 'or' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'-'" Literal.String.Char ' ' Text 'or' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'*'" Literal.String.Char ' ' Text 'or' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'/'" Literal.String.Char ' ' Text 'or' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'%'" Literal.String.Char '\n\t' Text 'end' Keyword '\n\n\t' Text 'fun' Keyword ' ' Text 'lines' Name '(' Punctuation 's' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation ':' Punctuation ' ' Text 'Array' Name.Class '[' Punctuation 'Line' Name.Class ']' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'+'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '/2' Literal.Number.Float ',1' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '-2' Literal.Number.Float ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'-'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'*'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'var' Keyword ' ' Text 'lines' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'Line' Name.Class ']' Punctuation '\n\t\t\t' Text 'for' Keyword ' ' Text 'y' Name ' ' Text 'in' Keyword ' ' Text '[1' Literal.Number.Float '..' Punctuation 's' Name '-1' Literal.Number.Float '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t\t' Text 'lines' Name '.' Punctuation 'add' Name '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(1' Literal.Number.Float ',' Punctuation 'y' Name ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name '-2' Literal.Number.Float ')' Punctuation ' ' Text ')' Punctuation '\n\t\t\t' Text 'end' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text 'lines' Name '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'/'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' ' Text '-1' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation ' ' Text 's' Name ' ' Text ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'%'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'var' Keyword ' ' Text 'q4' Literal.Number.Float ' ' Text '=' Operator ' ' Text 's' Name '/4' Literal.Number.Float '\n\t\t\t' Text 'var' Keyword ' ' Text 'lines' Name ' ' Text '=' Operator ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation '-1' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t\t' Text 'for' Keyword ' ' Text 'l' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'q4' Literal.Number.Float '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t\t' Text 'lines' Name '.' Punctuation 'append' Name '(' Punctuation '[' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 'l' Name ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 'q4' Literal.Number.Float ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float '-' Operator 'l' Name ')' Punctuation ',' Punctuation ' ' Text '-1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 'q4' Literal.Number.Float ')' Punctuation ' ' Text ']' Punctuation ')' Punctuation '\n\t\t\t' Text 'end' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text 'lines' Name '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'1'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '/2' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '/2' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation '-1' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'2'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'3'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'4'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'5'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'6'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'7'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'var' Keyword ' ' Text 'tl' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation '\n\t\t\t' Text 'var' Keyword ' ' Text 'tr' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'tl' Name ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'tr' Name ',' Punctuation '-1' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'8'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'9'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '/2' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'else' Keyword ' ' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '==' Operator ' ' Text "'0'" Literal.String.Char ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '[' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation 'new' Keyword ' ' Text 'P' Name.Class '(' Punctuation 's' Name '-1' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation '\n\t\t\t\t' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',' Punctuation 's' Name '-1' Literal.Number.Float ')' Punctuation ',1' Literal.Number.Float ',0' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'Line' Name.Class '(' Punctuation ' ' Text 'new' Keyword ' ' Text 'P' Name.Class '(0' Literal.Number.Float ',0' Literal.Number.Float ')' Punctuation ',' Punctuation ' 0' Literal.Number.Float ',1' Literal.Number.Float ',' Punctuation 's' Name ')' Punctuation ']' Punctuation '\n\t\t' Text 'end' Keyword '\n\t\t' Text 'return' Keyword ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'Line' Name.Class ']' Punctuation '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'class' Keyword ' ' Text 'P' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'x' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'y' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class '\n' Text 'end' Keyword '\n\n' Text 'redef' Keyword ' ' Text 'class' Keyword ' ' Text 'String' Name.Class '\n\t' Text '# hack is to support a bug in the evaluation software' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'draw' Name '(' Punctuation 'dispc' Name ':' Punctuation ' ' Text 'Char' Name.Class ',' Punctuation ' ' Text 'size' Name ',' Punctuation ' ' Text 'gap' Name ':' Punctuation ' ' Text 'Int' Name.Class ',' Punctuation ' ' Text 'hack' Name ':' Punctuation ' ' Text 'Bool' Name.Class ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'w' Name ' ' Text '=' Operator ' ' Text 'size' Name ' ' Text '*' Operator ' ' Text 'length' Name ' ' Text '+' Operator '(' Punctuation 'length' Name '-1' Literal.Number.Float ')' Punctuation '*' Operator 'gap' Name '\n\t\t' Text 'var' Keyword ' ' Text 'h' Name ' ' Text '=' Operator ' ' Text 'size' Name '\n\t\t' Text 'var' Keyword ' ' Text 'map' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'Array' Name.Class '[' Punctuation 'Char' Name.Class ']' Punctuation ']' Punctuation '\n\t\t' Text 'for' Keyword ' ' Text 'x' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'w' Name '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t' Text 'map' Name '[' Punctuation 'x' Name ']' Punctuation ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'Char' Name.Class ']' Punctuation '.' Punctuation 'filled_with' Name '(' Punctuation ' ' Text "' '" Literal.String.Char ',' Punctuation ' ' Text 'h' Name ' ' Text ')' Punctuation '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text 'var' Keyword ' ' Text 'ci' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t\t' Text 'for' Keyword ' ' Text 'c' Name ' ' Text 'in' Keyword ' ' Text 'self' Name '.' Punctuation 'chars' Name ' ' Text 'do' Keyword '\n\t\t\t' Text 'var' Keyword ' ' Text 'local_dispc' Name '\n\t\t\t' Text 'if' Keyword ' ' Text 'c' Name '.' Punctuation 'override_dispc' Name ' ' Text 'then' Keyword '\n\t\t\t\t' Text 'local_dispc' Name ' ' Text '=' Operator ' ' Text 'c' Name '\n\t\t\t' Text 'else' Keyword '\n\t\t\t\t' Text 'local_dispc' Name ' ' Text '=' Operator ' ' Text 'dispc' Name '\n\t\t\t' Text 'end' Keyword '\n\n\t\t\t' Text 'var' Keyword ' ' Text 'lines' Name ' ' Text '=' Operator ' ' Text 'c' Name '.' Punctuation 'lines' Name '(' Punctuation ' ' Text 'size' Name ' ' Text ')' Punctuation '\n\t\t\t' Text 'for' Keyword ' ' Text 'line' Name ' ' Text 'in' Keyword ' ' Text 'lines' Name ' ' Text 'do' Keyword '\n\t\t\t\t' Text 'var' Keyword ' ' Text 'x' Name ' ' Text '=' Operator ' ' Text 'line' Name '.' Punctuation 'o' Name '.' Punctuation 'x' Name '+' Operator 'ci' Name '*' Operator 'size' Name '\n\t\t\t\t\t' Text 'x' Name ' ' Text '+' Operator '=' Operator ' ' Text 'ci' Name '*' Operator 'gap' Name '\n\t\t\t\t' Text 'var' Keyword ' ' Text 'y' Name ' ' Text '=' Operator ' ' Text 'line' Name '.' Punctuation 'o' Name '.' Punctuation 'y' Name '\n\t\t\t\t' Text 'for' Keyword ' ' Text 's' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'line' Name '.' Punctuation 'len' Name '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t\t\t' Text 'assert' Keyword ' ' Text 'map' Name '.' Punctuation 'length' Name ' ' Text '>' Operator ' ' Text 'x' Name ' ' Text 'and' Keyword ' ' Text 'map' Name '[' Punctuation 'x' Name ']' Punctuation '.' Punctuation 'length' Name ' ' Text '>' Operator ' ' Text 'y' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"setting {' Literal.String 'x' Name '},{' Literal.String 'y' Name '} as {' Literal.String 'local_dispc' Name '}"' Literal.String '\n\t\t\t\t\t' Text 'map' Name '[' Punctuation 'x' Name ']' Punctuation '[' Punctuation 'y' Name ']' Punctuation ' ' Text '=' Operator ' ' Text 'local_dispc' Name '\n\t\t\t\t\t' Text 'x' Name ' ' Text '+' Operator '=' Operator ' ' Text 'line' Name '.' Punctuation 'step_x' Name '\n\t\t\t\t\t' Text 'y' Name ' ' Text '+' Operator '=' Operator ' ' Text 'line' Name '.' Punctuation 'step_y' Name '\n\t\t\t\t' Text 'end' Keyword '\n\t\t\t' Text 'end' Keyword '\n\n\t\t\t' Text 'ci' Name ' ' Text '+' Operator '=' Operator ' 1' Literal.Number.Float '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text 'if' Keyword ' ' Text 'hack' Name ' ' Text 'then' Keyword '\n\t\t\t' Text 'for' Keyword ' ' Text 'c' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'size' Name '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t\t' Text 'map' Name '[' Punctuation 'c' Name ']' Punctuation '[0' Literal.Number.Float ']' Punctuation ' ' Text '=' Operator ' ' Text 'map' Name '[' Punctuation 'map' Name '.' Punctuation 'length' Name '-' Operator 'size' Name '+' Operator 'c' Name ']' Punctuation '[0' Literal.Number.Float ']' Punctuation '\n\t\t\t\t' Text 'map' Name '[' Punctuation 'map' Name '.' Punctuation 'length' Name '-' Operator 'size' Name '+' Operator 'c' Name ']' Punctuation '[0' Literal.Number.Float ']' Punctuation ' ' Text '=' Operator ' ' Text "' '" Literal.String.Char '\n\t\t\t' Text 'end' Keyword '\n\t\t' Text 'end' Keyword '\n\n\t\t' Text 'for' Keyword ' ' Text 'y' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'h' Name '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t' Text 'for' Keyword ' ' Text 'x' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'w' Name '[' Punctuation ' ' Text 'do' Keyword '\n\t\t\t\t' Text 'printn' Name ' ' Text 'map' Name '[' Punctuation 'x' Name ']' Punctuation '[' Punctuation 'y' Name ']' Punctuation '\n\t\t\t' Text 'end' Keyword '\n\t\t\t' Text 'print' Name ' ' Text '""' Literal.String '\n\t\t' Text 'end' Keyword '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'class' Keyword ' ' Text 'Line' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'o' Name ' ' Text ':' Punctuation ' ' Text 'P' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'step_x' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'step_y' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text 'var' Keyword ' ' Text 'len' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'a' Name '\n' Text 'var' Keyword ' ' Text 'b' Name '\n' Text 'var' Keyword ' ' Text 'op_char' Name '\n' Text 'var' Keyword ' ' Text 'disp_char' Name '\n' Text 'var' Keyword ' ' Text 'disp_size' Name '\n' Text 'var' Keyword ' ' Text 'disp_gap' Name '\n\n' Text 'if' Keyword ' ' Text '"NIT_TESTING"' Literal.String '.' Punctuation 'environ' Name ' ' Text '==' Operator ' ' Text '"true"' Literal.String ' ' Text 'then' Keyword '\n\t' Text 'a' Name ' ' Text '=' Operator ' 567' Literal.Number.Float '\n\t' Text 'b' Name ' ' Text '=' Operator ' 13' Literal.Number.Float '\n\t' Text 'op_char' Name ' ' Text '=' Operator ' ' Text "'*'" Literal.String.Char '\n\t' Text 'disp_char' Name ' ' Text '=' Operator ' ' Text "'O'" Literal.String.Char '\n\t' Text 'disp_size' Name ' ' Text '=' Operator ' 8' Literal.Number.Float '\n\t' Text 'disp_gap' Name ' ' Text '=' Operator ' 1' Literal.Number.Float '\n' Text 'else' Keyword '\n\t' Text 'printn' Name ' ' Text '"Left operand: "' Literal.String '\n\t' Text 'a' Name ' ' Text '=' Operator ' ' Text 'gets' Name '.' Punctuation 'to_i' Name '\n\n\t' Text 'printn' Name ' ' Text '"Right operand: "' Literal.String '\n\t' Text 'b' Name ' ' Text '=' Operator ' ' Text 'gets' Name '.' Punctuation 'to_i' Name '\n\n\t' Text 'printn' Name ' ' Text '"Operator (+, -, *, /, %): "' Literal.String '\n\t' Text 'op_char' Name ' ' Text '=' Operator ' ' Text 'gets' Name '.' Punctuation 'chars' Name '[0' Literal.Number.Float ']' Punctuation '\n\n\t' Text 'printn' Name ' ' Text '"Char to display: "' Literal.String '\n\t' Text 'disp_char' Name ' ' Text '=' Operator ' ' Text 'gets' Name '.' Punctuation 'chars' Name '[0' Literal.Number.Float ']' Punctuation '\n\n\t' Text 'printn' Name ' ' Text '"Size of text: "' Literal.String '\n\t' Text 'disp_size' Name ' ' Text '=' Operator ' ' Text 'gets' Name '.' Punctuation 'to_i' Name '\n\n\t' Text 'printn' Name ' ' Text '"Space between digits: "' Literal.String '\n\t' Text 'disp_gap' Name ' ' Text '=' Operator ' ' Text 'gets' Name '.' Punctuation 'to_i' Name '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'result' Name ' ' Text '=' Operator ' ' Text 'op_char' Name '.' Punctuation 'as_operator' Name '(' Punctuation ' ' Text 'a' Name ',' Punctuation ' ' Text 'b' Name ' ' Text ')' Punctuation '\n\n' Text 'var' Keyword ' ' Text 'len_a' Name ' ' Text '=' Operator ' ' Text 'a' Name '.' Punctuation 'n_chars' Name '\n' Text 'var' Keyword ' ' Text 'len_b' Name ' ' Text '=' Operator ' ' Text 'b' Name '.' Punctuation 'n_chars' Name '\n' Text 'var' Keyword ' ' Text 'len_res' Name ' ' Text '=' Operator ' ' Text 'result' Name '.' Punctuation 'n_chars' Name '\n' Text 'var' Keyword ' ' Text 'max_len' Name ' ' Text '=' Operator ' ' Text 'len_a' Name '.' Punctuation 'max' Name '(' Punctuation ' ' Text 'len_b' Name '.' Punctuation 'max' Name '(' Punctuation ' ' Text 'len_res' Name ' ' Text ')' Punctuation ' ' Text ')' Punctuation ' ' Text '+' Operator ' 1' Literal.Number.Float '\n\n' Text '# draw first line' Comment.Single '\n' Text 'var' Keyword ' ' Text 'd' Name ' ' Text '=' Operator ' ' Text 'max_len' Name ' ' Text '-' Operator ' ' Text 'len_a' Name '\n' Text 'var' Keyword ' ' Text 'line_a' Name ' ' Text '=' Operator ' ' Text '""' Literal.String '\n' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'd' Name '[' Punctuation ' ' Text 'do' Keyword ' ' Text 'line_a' Name ' ' Text '+' Operator '=' Operator ' ' Text '" "' Literal.String '\n' Text 'line_a' Name ' ' Text '+' Operator '=' Operator ' ' Text 'a' Name '.' Punctuation 'to_s' Name '\n' Text 'line_a' Name '.' Punctuation 'draw' Name '(' Punctuation ' ' Text 'disp_char' Name ',' Punctuation ' ' Text 'disp_size' Name ',' Punctuation ' ' Text 'disp_gap' Name ',' Punctuation ' ' Text 'false' Keyword ' ' Text ')' Punctuation '\n\n' Text 'print' Name ' ' Text '""' Literal.String '\n' Text '# draw second line' Comment.Single '\n' Text 'd' Name ' ' Text '=' Operator ' ' Text 'max_len' Name ' ' Text '-' Operator ' ' Text 'len_b' Name '-1' Literal.Number.Float '\n' Text 'var' Keyword ' ' Text 'line_b' Name ' ' Text '=' Operator ' ' Text 'op_char' Name '.' Punctuation 'to_s' Name '\n' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'd' Name '[' Punctuation ' ' Text 'do' Keyword ' ' Text 'line_b' Name ' ' Text '+' Operator '=' Operator ' ' Text '" "' Literal.String '\n' Text 'line_b' Name ' ' Text '+' Operator '=' Operator ' ' Text 'b' Name '.' Punctuation 'to_s' Name '\n' Text 'line_b' Name '.' Punctuation 'draw' Name '(' Punctuation ' ' Text 'disp_char' Name ',' Punctuation ' ' Text 'disp_size' Name ',' Punctuation ' ' Text 'disp_gap' Name ',' Punctuation ' ' Text 'false' Keyword ' ' Text ')' Punctuation '\n\n' Text '# draw -----' Comment.Single '\n' Text 'print' Name ' ' Text '""' Literal.String '\n' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'disp_size' Name '*' Operator 'max_len' Name '+' Operator '(' Punctuation 'max_len' Name '-1' Literal.Number.Float ')' Punctuation '*' Operator 'disp_gap' Name ']' Punctuation ' ' Text 'do' Keyword '\n\t' Text 'printn' Name ' ' Text '"_"' Literal.String '\n' Text 'end' Keyword '\n' Text 'print' Name ' ' Text '""' Literal.String '\n' Text 'print' Name ' ' Text '""' Literal.String '\n\n' Text '# draw result' Comment.Single '\n' Text 'd' Name ' ' Text '=' Operator ' ' Text 'max_len' Name ' ' Text '-' Operator ' ' Text 'len_res' Name '\n' Text 'var' Keyword ' ' Text 'line_res' Name ' ' Text '=' Operator ' ' Text '""' Literal.String '\n' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation 'd' Name '[' Punctuation ' ' Text 'do' Keyword ' ' Text 'line_res' Name ' ' Text '+' Operator '=' Operator ' ' Text '" "' Literal.String '\n' Text 'line_res' Name ' ' Text '+' Operator '=' Operator ' ' Text 'result' Name '.' Punctuation 'to_s' Name '\n' Text 'line_res' Name '.' Punctuation 'draw' Name '(' Punctuation ' ' Text 'disp_char' Name ',' Punctuation ' ' Text 'disp_size' Name ',' Punctuation ' ' Text 'disp_gap' Name ',' Punctuation ' ' Text 'false' Keyword ' ' Text ')' Punctuation '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Alexis Laferrière ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Example using the privileges module to drop privileges from root' Comment.Single '\n' Text 'module' Keyword ' ' Text 'drop_privileges' Name '\n\n' Text 'import' Keyword ' ' Text 'privileges' Name '\n\n' Text '# basic command line options' Comment.Single '\n' Text 'var' Keyword ' ' Text 'opts' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'OptionContext' Name.Class '\n' Text 'var' Keyword ' ' Text 'opt_ug' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'OptionUserAndGroup' Name.Class '.' Punctuation 'for_dropping_privileges' Name '\n' Text 'opt_ug' Name '.' Punctuation 'mandatory' Name ' ' Text '=' Operator ' ' Text 'true' Keyword '\n' Text 'opts' Name '.' Punctuation 'add_option' Name '(' Punctuation 'opt_ug' Name ')' Punctuation '\n\n' Text '# parse and check command line options' Comment.Single '\n' Text 'opts' Name '.' Punctuation 'parse' Name '(' Punctuation 'args' Name ')' Punctuation '\n' Text 'if' Keyword ' ' Text 'not' Keyword ' ' Text 'opts' Name '.' Punctuation 'errors' Name '.' Punctuation 'is_empty' Name ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text 'opts' Name '.' Punctuation 'errors' Name '\n\t' Text 'print' Name ' ' Text '"Usage: drop_privileges [options]"' Literal.String '\n\t' Text 'opts' Name '.' Punctuation 'usage' Name '\n\t' Text 'exit' Name ' 1' Literal.Number.Float '\n' Text 'end' Keyword '\n\n' Text '# original user' Comment.Single '\n' Text 'print' Name ' ' Text '"before {' Literal.String 'sys' Name '.' Punctuation 'uid' Name '}:{' Literal.String 'sys' Name '.' Punctuation 'gid' Name '}"' Literal.String '\n\n' Text '# make the switch' Comment.Single '\n' Text 'var' Keyword ' ' Text 'user_group' Name ' ' Text '=' Operator ' ' Text 'opt_ug' Name '.' Punctuation 'value' Name '\n' Text 'assert' Keyword ' ' Text 'user_group' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword '\n' Text 'user_group' Name '.' Punctuation 'drop_privileges' Name '\n\n' Text '# final user' Comment.Single '\n' Text 'print' Name ' ' Text '"after {' Literal.String 'sys' Name '.' Punctuation 'uid' Name '}:{' Literal.String 'sys' Name '.' Punctuation 'egid' Name '}"' Literal.String '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2012-2013 Alexis Laferrière ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# This module illustrates some uses of the FFI, specifically' Comment.Single '\n' Text '# how to use extern methods. Which means to implement a Nit method in C.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'extern_methods' Name '\n\n' Text 'redef' Keyword ' ' Text 'enum' Keyword ' ' Text 'Int' Name.Class '\n\t' Text "# Returns self'th fibonnaci number" Comment.Single '\n\t' Text '# implemented here in C for optimization purposes' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'fib' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text 'import' Keyword ' ' Text 'fib' Name ' ' Text '`{\n\t\tif ( recv < 2 )\n\t\t\treturn recv;\n\t\telse\n\t\t\treturn Int_fib( recv-1 ) + Int_fib( recv-2 );\n\t`}' Text '\n\n\t' Text '# System call to sleep for "self" seconds' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'sleep' Name ' ' Text '`{\n\t\tsleep( recv );\n\t`}' Text '\n\n\t' Text '# Return atan2l( self, x ) from libmath' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'atan_with' Name '(' Punctuation ' ' Text 'x' Name ' ' Text ':' Punctuation ' ' Text 'Int' Name.Class ' ' Text ')' Punctuation ' ' Text ':' Punctuation ' ' Text 'Float' Name.Class ' ' Text '`{\n\t\treturn atan2( recv, x );\n\t`}' Text '\n\n\t' Text '# This method callback to Nit methods from C code' Comment.Single '\n\t' Text '# It will use from C code:' Comment.Single '\n\t' Text '# * the local fib method' Comment.Single '\n\t' Text '# * the + operator, a method of Int' Comment.Single '\n\t' Text '# * to_s, a method of all objects' Comment.Single '\n\t' Text '# * String.to_cstring, a method of String to return an equivalent char*' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'foo' Name ' ' Text 'import' Keyword ' ' Text 'fib' Name ',' Punctuation ' ' Text '+' Operator ',' Punctuation ' ' Text 'to_s' Name ',' Punctuation ' ' Text 'String' Name.Class '.' Punctuation 'to_cstring' Name ' ' Text '`{\n\t\tlong recv_fib = Int_fib( recv );\n\t\tlong recv_plus_fib = Int__plus( recv, recv_fib );\n\n\t\tString nit_string = Int_to_s( recv_plus_fib );\n\t\tchar *c_string = String_to_cstring( nit_string );\n\n\t\tprintf( "from C: self + fib(self) = %s\\n", c_string );\n\t`}' Text '\n\n\t' Text '# Equivalent to foo but written in pure Nit' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'bar' Name ' ' Text 'do' Keyword ' ' Text 'print' Name ' ' Text '"from Nit: self + fib(self) = {' Literal.String 'self' Name '+' Operator 'self' Name '.' Punctuation 'fib' Name '}"' Literal.String '\n' Text 'end' Keyword '\n\n' Text 'print' Name ' 12' Literal.Number.Float '.' Punctuation 'fib' Name '\n\n' Text 'print' Name ' ' Text '"sleeping 1 second..."' Literal.String '\n' Text '1' Literal.Number.Integer '.' Punctuation 'sleep' Name '\n\n' Text 'print' Name ' 100' Literal.Number.Float '.' Punctuation 'atan_with' Name '(' Punctuation ' 200' Literal.Number.Float ' ' Text ')' Punctuation '\n' Text '8' Literal.Number.Integer '.' Punctuation 'foo' Name '\n' Text '8' Literal.Number.Integer '.' Punctuation 'bar' Name '\n\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2004-2008 Jean Privat ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# A simple exemple of refinement where a method is added to the integer class.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'fibonacci' Name '\n\n' Text 'redef' Keyword ' ' Text 'class' Keyword ' ' Text 'Int' Name.Class '\n\t' Text '# Calculate the self-th element of the fibonacci sequence.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'fibonacci' Name ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text 'do' Keyword '\n\t\t' Text 'if' Keyword ' ' Text 'self' Keyword ' ' Text '<' Operator ' 2' Literal.Number.Float ' ' Text 'then' Keyword '\n\t\t\t' Text 'return' Keyword ' 1' Literal.Number.Float '\n\t\t' Text 'else' Keyword '\n\t\t\t' Text 'return' Keyword ' ' Text '(' Punctuation 'self' Name '-2' Literal.Number.Float ')' Punctuation '.' Punctuation 'fibonacci' Name ' ' Text '+' Operator ' ' Text '(' Punctuation 'self' Name '-1' Literal.Number.Float ')' Punctuation '.' Punctuation 'fibonacci' Name '\n\t\t' Text 'end' Keyword '\n\t' Text 'end' Keyword ' \n' Text 'end' Keyword '\n\n' Text '# Print usage and exit.' Comment.Single '\n' Text 'fun' Keyword ' ' Text 'usage' Name '\n' Text 'do' Keyword '\n\t' Text 'print' Name ' ' Text '"Usage: fibonnaci "' Literal.String ' \n\t' Text 'exit' Name ' 0' Literal.Number.Float ' \n' Text 'end' Keyword '\n\n' Text '# Main part' Comment.Single '\n' Text 'if' Keyword ' ' Text 'args' Name '.' Punctuation 'length' Name ' ' Text '!=' Operator ' 1' Literal.Number.Float ' ' Text 'then' Keyword '\n\t' Text 'usage' Name '\n' Text 'end' Keyword '\n' Text 'print' Name ' ' Text 'args' Name '.' Punctuation 'first' Name '.' Punctuation 'to_i' Name '.' Punctuation 'fibonacci' Name '\n' Text 'print' Name ' ' Text '"hello world"' Literal.String '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text 'import' Keyword ' ' Text 'html' Name '\n\n' Text 'class' Keyword ' ' Text 'NitHomepage' Name.Class '\n\t' Text 'super' Keyword ' ' Text 'HTMLPage' Name.Class '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'head' Name ' ' Text 'do' Keyword '\n\t\t' Text 'add' Name '(' Punctuation '"meta"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"charset"' Literal.String ',' Punctuation ' ' Text '"utf-8"' Literal.String ')' Punctuation '\n\t\t' Text 'add' Name '(' Punctuation '"title"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Nit"' Literal.String ')' Punctuation '\n\t\t' Text 'add' Name '(' Punctuation '"link"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"rel"' Literal.String ',' Punctuation ' ' Text '"icon"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"http://nitlanguage.org/favicon.ico"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"type"' Literal.String ',' Punctuation ' ' Text '"image/x-icon"' Literal.String ')' Punctuation '\n\t\t' Text 'add' Name '(' Punctuation '"link"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"rel"' Literal.String ',' Punctuation ' ' Text '"stylesheet"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"http://nitlanguage.org/style.css"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"type"' Literal.String ',' Punctuation ' ' Text '"text/css"' Literal.String ')' Punctuation '\n\t\t' Text 'add' Name '(' Punctuation '"link"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"rel"' Literal.String ',' Punctuation ' ' Text '"stylesheet"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"http://nitlanguage.org/local.css"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"type"' Literal.String ',' Punctuation ' ' Text '"text/css"' Literal.String ')' Punctuation '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'body' Name ' ' Text 'do' Keyword '\n\t\t' Text 'open' Name '(' Punctuation '"article"' Literal.String ')' Punctuation '.' Punctuation 'add_class' Name '(' Punctuation '"page"' Literal.String ')' Punctuation '\n\t\t\t' Text 'open' Name '(' Punctuation '"section"' Literal.String ')' Punctuation '.' Punctuation 'add_class' Name '(' Punctuation '"pageheader"' Literal.String ')' Punctuation '\n\t\t\t\t' Text 'add_html' Name '(' Punctuation '"theNitProgramming Language"' Literal.String ')' Punctuation '\n\t\t\t\t' Text 'open' Name '(' Punctuation '"header"' Literal.String ')' Punctuation '.' Punctuation 'add_class' Name '(' Punctuation '"header"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'open' Name '(' Punctuation '"div"' Literal.String ')' Punctuation '.' Punctuation 'add_class' Name '(' Punctuation '"topsubtitle"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"A Fun Language for Serious Programming"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'close' Name '(' Punctuation '"div"' Literal.String ')' Punctuation '\n\t\t\t\t' Text 'close' Name '(' Punctuation '"header"' Literal.String ')' Punctuation '\n\t\t\t' Text 'close' Name '(' Punctuation '"section"' Literal.String ')' Punctuation '\n\n\t\t\t' Text 'open' Name '(' Punctuation '"div"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"id"' Literal.String ',' Punctuation ' ' Text '"pagebody"' Literal.String ')' Punctuation '\n\t\t\t\t' Text 'open' Name '(' Punctuation '"section"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"id"' Literal.String ',' Punctuation ' ' Text '"content"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"h1"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"# What is Nit?"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Nit is an object-oriented programming language. The goal of Nit is to propose a robust statically typed programming language where structure is not a pain."' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"So, what does the famous hello world program look like, in Nit?"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add_html' Name '(' Punctuation '"
print \'Hello, World!\'
"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"h1"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"# Feature Highlights"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"h2"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Usability"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Nit\'s goal is to be usable by real programmers for real projects"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'open' Name '(' Punctuation '"ul"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'open' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"a"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"http://en.wikipedia.org/wiki/KISS_principle"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"KISS principle"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'close' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Script-like language without verbosity nor cryptic statements"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Painless static types: static typing should help programmers"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Efficient development, efficient execution, efficient evolution."' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'close' Name '(' Punctuation '"ul"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"h2"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Robustness"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Nit will help you to write bug-free programs"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'open' Name '(' Punctuation '"ul"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Strong static typing"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"No more NullPointerException"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'close' Name '(' Punctuation '"ul"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"h2"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Object-Oriented"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Nit\'s guideline is to follow the most powerful OO principles"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'open' Name '(' Punctuation '"ul"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'open' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"a"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"./everything_is_an_object/"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Everything is an object"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'close' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'open' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"a"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"./multiple_inheritance/"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Multiple inheritance"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'close' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'open' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"a"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"./refinement/"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Open classes"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'close' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'open' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'add' Name '(' Punctuation '"a"' Literal.String ')' Punctuation '.' Punctuation 'attr' Name '(' Punctuation '"href"' Literal.String ',' Punctuation ' ' Text '"./virtual_types/"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Virtual types"' Literal.String ')' Punctuation '\n\t\t\t\t\t\t' Text 'close' Name '(' Punctuation '"li"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'close' Name '(' Punctuation '"ul"' Literal.String ')' Punctuation '\n\n\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"h1"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"# Getting Started"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Get Nit from its Git repository:"' Literal.String ')' Punctuation '\n\n\t\t\t\t\t' Text 'add_html' Name '(' Punctuation '"
$ git clone http://nitlanguage.org/nit.git
"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Build the compiler (may be long):"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add_html' Name '(' Punctuation '"
$ cd nit\\n"' Literal.String
')'           Punctuation
'\n\t\t\t\t\t' Text
'add_html'    Name
'('           Punctuation
'"$ make
"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Compile a program:"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add_html' Name '(' Punctuation '"
$ bin/nitc examples/hello_world.nit
"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add' Name '(' Punctuation '"p"' Literal.String ')' Punctuation '.' Punctuation 'text' Name '(' Punctuation '"Execute the program:"' Literal.String ')' Punctuation '\n\t\t\t\t\t' Text 'add_html' Name '(' Punctuation '"
$ ./hello_world
"' Literal.String ')' Punctuation '\n\t\t\t\t' Text 'close' Name '(' Punctuation '"section"' Literal.String ')' Punctuation '\n\t\t\t' Text 'close' Name '(' Punctuation '"div"' Literal.String ')' Punctuation '\n\t\t' Text 'close' Name '(' Punctuation '"article"' Literal.String ')' Punctuation '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'page' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'NitHomepage' Name.Class '\n' Text 'page' Name '.' Punctuation 'write_to' Name ' ' Text 'stdout' Name '\n' Text 'page' Name '.' Punctuation 'write_to_file' Name '(' Punctuation '"nit.html"' Literal.String ')' Punctuation '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# An example that defines and uses stacks of integers.' Comment.Single '\n' Text '# The implementation is done with a simple linked list.' Comment.Single '\n' Text '# It features: free constructors, nullable types and some adaptive typing.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'int_stack' Name '\n\n' Text '# A stack of integer implemented by a simple linked list.' Comment.Single '\n' Text '# Note that this is only a toy class since a real linked list will gain to use' Comment.Single '\n' Text '# generics and extends interfaces, like Collection, from the standard library.' Comment.Single '\n' Text 'class' Keyword ' ' Text 'IntStack' Name.Class '\n\t' Text '# The head node of the list.' Comment.Single '\n\t' Text '# Null means that the stack is empty.' Comment.Single '\n\t' Text 'private' Keyword ' ' Text 'var' Keyword ' ' Text 'head' Name ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'ISNode' Name.Class ' ' Text '=' Operator ' ' Text 'null' Keyword '\n\n\t' Text '# Add a new integer in the stack.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'push' Name '(' Punctuation 'val' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'self' Name '.' Punctuation 'head' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'ISNode' Name.Class '(' Punctuation 'val' Name ',' Punctuation ' ' Text 'self' Name '.' Punctuation 'head' Name ')' Punctuation '\n\t' Text 'end' Keyword '\n\n\t' Text '# Remove and return the last pushed integer.' Comment.Single '\n\t' Text '# Return null if the stack is empty.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'pop' Name ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'Int' Name.Class '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'head' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'head' Name '\n\t\t' Text 'if' Keyword ' ' Text 'head' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'return' Keyword ' ' Text 'null' Keyword '\n\t\t' Text '# Note: the followings are statically safe because of the' Comment.Single '\n\t\t' Text "# previous 'if'." Comment.Single '\n\t\t' Text 'var' Keyword ' ' Text 'val' Name ' ' Text '=' Operator ' ' Text 'head' Name '.' Punctuation 'val' Name '\n\t\t' Text 'self' Name '.' Punctuation 'head' Name ' ' Text '=' Operator ' ' Text 'head' Name '.' Punctuation 'next' Name '\n\t\t' Text 'return' Keyword ' ' Text 'val' Name '\n\t' Text 'end' Keyword '\n\n\t' Text '# Return the sum of all integers of the stack.' Comment.Single '\n\t' Text '# Return 0 if the stack is empty.' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'sumall' Name ':' Punctuation ' ' Text 'Int' Name.Class '\n\t' Text 'do' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'sum' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t\t' Text 'var' Keyword ' ' Text 'cur' Name ' ' Text '=' Operator ' ' Text 'self' Name '.' Punctuation 'head' Name '\n\t\t' Text 'while' Keyword ' ' Text 'cur' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword ' ' Text 'do' Keyword '\n\t\t\t' Text '# Note: the followings are statically safe because of' Comment.Single '\n\t\t\t' Text "# the condition of the 'while'." Comment.Single '\n\t\t\t' Text 'sum' Name ' ' Text '+' Operator '=' Operator ' ' Text 'cur' Name '.' Punctuation 'val' Name '\n\t\t\t' Text 'cur' Name ' ' Text '=' Operator ' ' Text 'cur' Name '.' Punctuation 'next' Name '\n\t\t' Text 'end' Keyword '\n\t\t' Text 'return' Keyword ' ' Text 'sum' Name '\n\t' Text 'end' Keyword '\n\n\t' Text '# Note: Because all attributes have a default value, a free constructor' Comment.Single '\n\t' Text '# "init()" is implicitly defined.' Comment.Single '\n' Text 'end' Keyword '\n\n' Text '# A node of a IntStack' Comment.Single '\n' Text 'private' Keyword ' ' Text 'class' Keyword ' ' Text 'ISNode' Name.Class '\n\t' Text '# The integer value stored in the node.' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'val' Name ':' Punctuation ' ' Text 'Int' Name.Class '\n\n\t' Text '# The next node, if any.' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'next' Name ':' Punctuation ' ' Text 'nullable' Keyword ' ' Text 'ISNode' Name.Class '\n\n\t' Text '# Note: A free constructor "init(val: Int, next: nullable ISNode)" is' Comment.Single '\n\t' Text '# implicitly defined.' Comment.Single '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'l' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'IntStack' Name.Class '\n' Text 'l' Name '.' Punctuation 'push' Name '(1' Literal.Number.Float ')' Punctuation '\n' Text 'l' Name '.' Punctuation 'push' Name '(2' Literal.Number.Float ')' Punctuation '\n' Text 'l' Name '.' Punctuation 'push' Name '(3' Literal.Number.Float ')' Punctuation '\n\n' Text 'print' Name ' ' Text 'l' Name '.' Punctuation 'sumall' Name '\n\n' Text "# Note: the 'for' control structure cannot be used on IntStack in its current state." Comment.Single '\n' Text '# It requires a more advanced topic.' Comment.Single '\n' Text "# However, why not using the 'loop' control structure?" Comment.Single '\n' Text 'loop' Keyword '\n\t' Text 'var' Keyword ' ' Text 'i' Name ' ' Text '=' Operator ' ' Text 'l' Name '.' Punctuation 'pop' Name '\n\t' Text 'if' Keyword ' ' Text 'i' Name ' ' Text '==' Operator ' ' Text 'null' Keyword ' ' Text 'then' Keyword ' ' Text 'break' Keyword '\n\t' Text "# The following is statically safe because of the previous 'if'." Comment.Single '\n\t' Text 'print' Name ' ' Text 'i' Name ' ' Text '*' Operator ' 10' Literal.Number.Float '\n' Text 'end' Keyword '\n\n' Text "# Note: 'or else' is used to give an alternative of a null expression." Comment.Single '\n' Text 'l' Name '.' Punctuation 'push' Name '(5' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text 'l' Name '.' Punctuation 'pop' Name ' ' Text 'or' Keyword ' ' Text 'else' Keyword ' 0' Literal.Number.Float ' ' Text '# l.pop gives 5, so print 5' Comment.Single '\n' Text 'print' Name ' ' Text 'l' Name '.' Punctuation 'pop' Name ' ' Text 'or' Keyword ' ' Text 'else' Keyword ' 0' Literal.Number.Float ' ' Text '# l.pop gives null, so print the alternative: 0' Comment.Single '\n\n\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2014 Alexis Laferrière ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Basic example of OpenGL ES 2.0 usage from the book OpenGL ES 2.0 Programming Guide.' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Code reference:' Comment.Single '\n' Text '# https://code.google.com/p/opengles-book-samples/source/browse/trunk/LinuxX11/Chapter_2/Hello_Triangle/Hello_Triangle.c ' Comment.Single '\n' Text 'module' Keyword ' ' Text 'opengles2_hello_triangle' Name '\n\n' Text 'import' Keyword ' ' Text 'glesv2' Name '\n' Text 'import' Keyword ' ' Text 'egl' Name '\n' Text 'import' Keyword ' ' Text 'mnit_linux' Name ' ' Text '# for sdl' Comment.Single '\n' Text 'import' Keyword ' ' Text 'x11' Literal.Number.Float '\n\n' Text 'if' Keyword ' ' Text '"NIT_TESTING"' Literal.String '.' Punctuation 'environ' Name ' ' Text '==' Operator ' ' Text '"true"' Literal.String ' ' Text 'then' Keyword ' ' Text 'exit' Name '(0' Literal.Number.Float ')' Punctuation '\n\n' Text 'var' Keyword ' ' Text 'window_width' Name ' ' Text '=' Operator ' 800' Literal.Number.Float '\n' Text 'var' Keyword ' ' Text 'window_height' Name ' ' Text '=' Operator ' 600' Literal.Number.Float '\n\n' Text '#' Comment.Single '\n' Text '## SDL' Comment.Single '\n' Text '#' Comment.Single '\n' Text 'var' Keyword ' ' Text 'sdl_display' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'SDLDisplay' Name.Class '(' Punctuation 'window_width' Name ',' Punctuation ' ' Text 'window_height' Name ')' Punctuation '\n' Text 'var' Keyword ' ' Text 'sdl_wm_info' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'SDLSystemWindowManagerInfo' Name.Class '\n' Text 'var' Keyword ' ' Text 'x11' Literal.Number.Float '_window_handle' Name.Variable.Instance ' ' Text '=' Operator ' ' Text 'sdl_wm_info' Name '.' Punctuation 'x11' Literal.Number.Float '_window_handle' Name.Variable.Instance '\n\n' Text '#' Comment.Single '\n' Text '## X11' Comment.Single '\n' Text '#' Comment.Single '\n' Text 'var' Keyword ' ' Text 'x_display' Name ' ' Text '=' Operator ' ' Text 'x_open_default_display' Name '\n' Text 'assert' Keyword ' ' Text 'x_display' Name ' ' Text '!=' Operator ' 0' Literal.Number.Float ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"x11 fail"' Literal.String '\n\n' Text '#' Comment.Single '\n' Text '## EGL' Comment.Single '\n' Text '#' Comment.Single '\n' Text 'var' Keyword ' ' Text 'egl_display' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'EGLDisplay' Name.Class '(' Punctuation 'x_display' Name ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'egl_display' Name '.' Punctuation 'is_valid' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"EGL display is not valid"' Literal.String '\n' Text 'egl_display' Name '.' Punctuation 'initialize' Name '\n\n' Text 'print' Name ' ' Text '"EGL version: {' Literal.String 'egl_display' Name '.' Punctuation 'version' Name '}"' Literal.String '\n' Text 'print' Name ' ' Text '"EGL vendor: {' Literal.String 'egl_display' Name '.' Punctuation 'vendor' Name '}"' Literal.String '\n' Text 'print' Name ' ' Text '"EGL extensions: {' Literal.String 'egl_display' Name '.' Punctuation 'extensions' Name '.' Punctuation 'join' Name '(' Punctuation '", "' Literal.String ')' Punctuation '}"' Literal.String '\n' Text 'print' Name ' ' Text '"EGL client APIs: {' Literal.String 'egl_display' Name '.' Punctuation 'client_apis' Name '.' Punctuation 'join' Name '(' Punctuation '", "' Literal.String ')' Punctuation '}"' Literal.String '\n\n' Text 'assert' Keyword ' ' Text 'egl_display' Name '.' Punctuation 'is_valid' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'egl_display' Name '.' Punctuation 'error' Name '\n\n' Text 'var' Keyword ' ' Text 'config_chooser' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'EGLConfigChooser' Name.Class '\n' Text '#config_chooser.surface_type_egl' Comment.Single '\n' Text 'config_chooser' Name '.' Punctuation 'blue_size' Name ' ' Text '=' Operator ' 8' Literal.Number.Float '\n' Text 'config_chooser' Name '.' Punctuation 'green_size' Name ' ' Text '=' Operator ' 8' Literal.Number.Float '\n' Text 'config_chooser' Name '.' Punctuation 'red_size' Name ' ' Text '=' Operator ' 8' Literal.Number.Float '\n' Text '#config_chooser.alpha_size = 8' Comment.Single '\n' Text '#config_chooser.depth_size = 8' Comment.Single '\n' Text '#config_chooser.stencil_size = 8' Comment.Single '\n' Text '#config_chooser.sample_buffers = 1' Comment.Single '\n' Text 'config_chooser' Name '.' Punctuation 'close' Name '\n\n' Text 'var' Keyword ' ' Text 'configs' Name ' ' Text '=' Operator ' ' Text 'config_chooser' Name '.' Punctuation 'choose' Name '(' Punctuation 'egl_display' Name ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'configs' Name ' ' Text '!=' Operator ' ' Text 'null' Keyword ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"choosing config failed: {' Literal.String 'egl_display' Name '.' Punctuation 'error' Name '}"' Literal.String '\n' Text 'assert' Keyword ' ' Text 'not' Keyword ' ' Text 'configs' Name '.' Punctuation 'is_empty' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"no EGL config"' Literal.String '\n\n' Text 'print' Name ' ' Text '"{' Literal.String 'configs' Name '.' Punctuation 'length' Name '} EGL configs available"' Literal.String '\n' Text 'for' Keyword ' ' Text 'config' Name ' ' Text 'in' Keyword ' ' Text 'configs' Name ' ' Text 'do' Keyword '\n\t' Text 'var' Keyword ' ' Text 'attribs' Name ' ' Text '=' Operator ' ' Text 'config' Name '.' Punctuation 'attribs' Name '(' Punctuation 'egl_display' Name ')' Punctuation '\n\t' Text 'print' Name ' ' Text '"* caveats: {' Literal.String 'attribs' Name '.' Punctuation 'caveat' Name '}"' Literal.String '\n\t' Text 'print' Name ' ' Text '" conformant to: {' Literal.String 'attribs' Name '.' Punctuation 'conformant' Name '}"' Literal.String '\n\t' Text 'print' Name ' ' Text '" size of RGBA: {' Literal.String 'attribs' Name '.' Punctuation 'red_size' Name '} {' Literal.String 'attribs' Name '.' Punctuation 'green_size' Name '} {' Literal.String 'attribs' Name '.' Punctuation 'blue_size' Name '} {' Literal.String 'attribs' Name '.' Punctuation 'alpha_size' Name '}"' Literal.String '\n\t' Text 'print' Name ' ' Text '" buffer, depth, stencil: {' Literal.String 'attribs' Name '.' Punctuation 'buffer_size' Name '} {' Literal.String 'attribs' Name '.' Punctuation 'depth_size' Name '} {' Literal.String 'attribs' Name '.' Punctuation 'stencil_size' Name '}"' Literal.String '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'config' Name ' ' Text '=' Operator ' ' Text 'configs' Name '.' Punctuation 'first' Name '\n\n' Text 'var' Keyword ' ' Text 'format' Name ' ' Text '=' Operator ' ' Text 'config' Name '.' Punctuation 'attribs' Name '(' Punctuation 'egl_display' Name ')' Punctuation '.' Punctuation 'native_visual_id' Name '\n\n' Text '# TODO android part' Comment.Single '\n' Text '# Opengles1Display_midway_init(recv, format);' Comment.Single '\n\n' Text 'var' Keyword ' ' Text 'surface' Name ' ' Text '=' Operator ' ' Text 'egl_display' Name '.' Punctuation 'create_window_surface' Name '(' Punctuation 'config' Name ',' Punctuation ' ' Text 'x11' Literal.Number.Float '_window_handle' Name.Variable.Instance ',' Punctuation ' ' Text '[0' Literal.Number.Float ']' Punctuation ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'surface' Name '.' Punctuation 'is_ok' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'egl_display' Name '.' Punctuation 'error' Name '\n\n' Text 'var' Keyword ' ' Text 'context' Name ' ' Text '=' Operator ' ' Text 'egl_display' Name '.' Punctuation 'create_context' Name '(' Punctuation 'config' Name ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'context' Name '.' Punctuation 'is_ok' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text 'egl_display' Name '.' Punctuation 'error' Name '\n\n' Text 'var' Keyword ' ' Text 'make_current_res' Name ' ' Text '=' Operator ' ' Text 'egl_display' Name '.' Punctuation 'make_current' Name '(' Punctuation 'surface' Name ',' Punctuation ' ' Text 'surface' Name ',' Punctuation ' ' Text 'context' Name ')' Punctuation '\n' Text 'assert' Keyword ' ' Text 'make_current_res' Name '\n\n' Text 'var' Keyword ' ' Text 'width' Name ' ' Text '=' Operator ' ' Text 'surface' Name '.' Punctuation 'attribs' Name '(' Punctuation 'egl_display' Name ')' Punctuation '.' Punctuation 'width' Name '\n' Text 'var' Keyword ' ' Text 'height' Name ' ' Text '=' Operator ' ' Text 'surface' Name '.' Punctuation 'attribs' Name '(' Punctuation 'egl_display' Name ')' Punctuation '.' Punctuation 'height' Name '\n' Text 'print' Name ' ' Text '"Width: {' Literal.String 'width' Name '}"' Literal.String '\n' Text 'print' Name ' ' Text '"Height: {' Literal.String 'height' Name '}"' Literal.String '\n\n' Text 'assert' Keyword ' ' Text 'egl_bind_opengl_es_api' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"eglBingAPI failed: {' Literal.String 'egl_display' Name '.' Punctuation 'error' Name '}"' Literal.String '\n\n' Text '#' Comment.Single '\n' Text '## GLESv2' Comment.Single '\n' Text '#' Comment.Single '\n\n' Text 'print' Name ' ' Text '"Can compile shaders? {' Literal.String 'gl_shader_compiler' Name '}"' Literal.String '\n' Text 'assert_no_gl_error' Name '\n\n' Text 'assert' Keyword ' ' Text 'gl_shader_compiler' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"Cannot compile shaders"' Literal.String '\n\n' Text '# gl program' Comment.Single '\n' Text 'print' Name ' ' Text 'gl_error' Name '.' Punctuation 'to_s' Name '\n' Text 'var' Keyword ' ' Text 'program' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GLProgram' Name.Class '\n' Text 'if' Keyword ' ' Text 'not' Keyword ' ' Text 'program' Name '.' Punctuation 'is_ok' Name ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Program is not ok: {' Literal.String 'gl_error' Name '.' Punctuation 'to_s' Name '}\\nLog:"' Literal.String '\n\t' Text 'print' Name ' ' Text 'program' Name '.' Punctuation 'info_log' Name '\n\t' Text 'abort' Keyword '\n' Text 'end' Keyword '\n' Text 'assert_no_gl_error' Name '\n\n' Text '# vertex shader' Comment.Single '\n' Text 'var' Keyword ' ' Text 'vertex_shader' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'GLVertexShader' Name.Class '\n' Text 'assert' Keyword ' ' Text 'vertex_shader' Name '.' Punctuation 'is_ok' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"Vertex shader is not ok: {' Literal.String 'gl_error' Name '}"' Literal.String '\n' Text 'vertex_shader' Name '.' Punctuation 'source' Name ' ' Text '=' Operator ' ' Text '"""\nattribute vec4 vPosition; \nvoid main() \n{ \n gl_Position = vPosition; \n} """\nvertex_shader.compile\nassert vertex_shader.is_compiled else print "Vertex shader compilation failed with: {vertex_shader.info_log} {program.info_log}"\nassert_no_gl_error\n\n# fragment shader\nvar fragment_shader = new GLFragmentShader\nassert fragment_shader.is_ok else print "Fragment shader is not ok: {gl_error}"\nfragment_shader.source = """\nprecision mediump float;\nvoid main()\n{\n\tgl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n}\n"""' Literal.String '\n' Text 'fragment_shader' Name '.' Punctuation 'compile' Name '\n' Text 'assert' Keyword ' ' Text 'fragment_shader' Name '.' Punctuation 'is_compiled' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"Fragment shader compilation failed with: {' Literal.String 'fragment_shader' Name '.' Punctuation 'info_log' Name '}"' Literal.String '\n' Text 'assert_no_gl_error' Name '\n\n' Text 'program' Name '.' Punctuation 'attach_shader' Name ' ' Text 'vertex_shader' Name '\n' Text 'program' Name '.' Punctuation 'attach_shader' Name ' ' Text 'fragment_shader' Name '\n' Text 'program' Name '.' Punctuation 'bind_attrib_location' Name '(0' Literal.Number.Float ',' Punctuation ' ' Text '"vPosition"' Literal.String ')' Punctuation '\n' Text 'program' Name '.' Punctuation 'link' Name '\n' Text 'assert' Keyword ' ' Text 'program' Name '.' Punctuation 'is_linked' Name ' ' Text 'else' Keyword ' ' Text 'print' Name ' ' Text '"Linking failed: {' Literal.String 'program' Name '.' Punctuation 'info_log' Name '}"' Literal.String '\n' Text 'assert_no_gl_error' Name '\n\n' Text '# draw!' Comment.Single '\n' Text 'var' Keyword ' ' Text 'vertices' Name ' ' Text '=' Operator ' ' Text '[0' Literal.Number.Float '.0' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.0' Literal.Number.Float ',' Punctuation ' ' Text '-0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' ' Text '-0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.0' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' ' Text '-0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.0' Literal.Number.Float ']' Punctuation '\n' Text 'var' Keyword ' ' Text 'vertex_array' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'VertexArray' Name.Class '(0' Literal.Number.Float ',' Punctuation ' 3' Literal.Number.Float ',' Punctuation ' ' Text 'vertices' Name ')' Punctuation '\n' Text 'vertex_array' Name '.' Punctuation 'attrib_pointer' Name '\n' Text 'gl_clear_color' Name '(0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.0' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float '.5' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float '.0' Literal.Number.Float ')' Punctuation '\n' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text '[0' Literal.Number.Float '..' Punctuation '10000' Literal.Number.Integer '[' Punctuation ' ' Text 'do' Keyword '\n\t' Text 'printn' Name ' ' Text '"."' Literal.String '\n\t' Text 'assert_no_gl_error' Name '\n\t' Text 'gl_viewport' Name '(0' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float ',' Punctuation ' ' Text 'width' Name ',' Punctuation ' ' Text 'height' Name ')' Punctuation '\n\t' Text 'gl_clear_color_buffer' Name '\n\t' Text 'program' Name '.' Punctuation 'use' Name '\n\t' Text 'vertex_array' Name '.' Punctuation 'enable' Name '\n\t' Text 'vertex_array' Name '.' Punctuation 'draw_arrays_triangles' Name '\n\t' Text 'egl_display' Name '.' Punctuation 'swap_buffers' Name '(' Punctuation 'surface' Name ')' Punctuation '\n' Text 'end' Keyword '\n\n' Text '# delete' Comment.Single '\n' Text 'program' Name '.' Punctuation 'delete' Name '\n' Text 'vertex_shader' Name '.' Punctuation 'delete' Name '\n' Text 'fragment_shader' Name '.' Punctuation 'delete' Name '\n\n' Text '#' Comment.Single '\n' Text '## EGL' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# close' Comment.Single '\n' Text 'egl_display' Name '.' Punctuation 'make_current' Name '(' Punctuation 'new' Keyword ' ' Text 'EGLSurface' Name.Class '.' Punctuation 'none' Name ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'EGLSurface' Name.Class '.' Punctuation 'none' Name ',' Punctuation ' ' Text 'new' Keyword ' ' Text 'EGLContext' Name.Class '.' Punctuation 'none' Name ')' Punctuation '\n' Text 'egl_display' Name '.' Punctuation 'destroy_context' Name '(' Punctuation 'context' Name ')' Punctuation '\n' Text 'egl_display' Name '.' Punctuation 'destroy_surface' Name '(' Punctuation 'surface' Name ')' Punctuation '\n\n' Text '#' Comment.Single '\n' Text '## SDL' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# close' Comment.Single '\n' Text 'sdl_display' Name '.' Punctuation 'destroy' Name '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2004-2008 Jean Privat ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# How to print arguments of the command line.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'print_arguments' Name '\n\n' Text 'for' Keyword ' ' Text 'a' Name ' ' Text 'in' Keyword ' ' Text 'args' Name ' ' Text 'do' Keyword '\n\t' Text 'print' Name ' ' Text 'a' Name '\n' Text 'end' Keyword '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2004-2008 Jean Privat ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# A procedural program (without explicit class definition).' Comment.Single '\n' Text '# This program manipulates arrays of integers.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'procedural_array' Name '\n\n' Text "# The sum of the elements of `a'." Comment.Single '\n' Text "# Uses a 'for' control structure." Comment.Single '\n' Text 'fun' Keyword ' ' Text 'array_sum' Name '(' Punctuation 'a' Name ':' Punctuation ' ' Text 'Array' Name.Class '[' Punctuation 'Int' Name.Class ']' Punctuation ')' Punctuation ':' Punctuation ' ' Text 'Int' Name.Class '\n' Text 'do' Keyword '\n\t' Text 'var' Keyword ' ' Text 'sum' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t' Text 'for' Keyword ' ' Text 'i' Name ' ' Text 'in' Keyword ' ' Text 'a' Name ' ' Text 'do' Keyword '\n\t\t' Text 'sum' Name ' ' Text '=' Operator ' ' Text 'sum' Name ' ' Text '+' Operator ' ' Text 'i' Name '\n\t' Text 'end' Keyword '\n\t' Text 'return' Keyword ' ' Text 'sum' Name '\n' Text 'end' Keyword '\n\n' Text "# The sum of the elements of `a' (alternative version)." Comment.Single '\n' Text "# Uses a 'while' control structure." Comment.Single '\n' Text 'fun' Keyword ' ' Text 'array_sum_alt' Name '(' Punctuation 'a' Name ':' Punctuation ' ' Text 'Array' Name.Class '[' Punctuation 'Int' Name.Class ']' Punctuation ')' Punctuation ':' Punctuation ' ' Text 'Int' Name.Class '\n' Text 'do' Keyword '\n\t' Text 'var' Keyword ' ' Text 'sum' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t' Text 'var' Keyword ' ' Text 'i' Name ' ' Text '=' Operator ' 0' Literal.Number.Float '\n\t' Text 'while' Keyword ' ' Text 'i' Name ' ' Text '<' Operator ' ' Text 'a' Name '.' Punctuation 'length' Name ' ' Text 'do' Keyword '\n\t\t' Text 'sum' Name ' ' Text '=' Operator ' ' Text 'sum' Name ' ' Text '+' Operator ' ' Text 'a' Name '[' Punctuation 'i' Name ']' Punctuation '\n\t\t' Text 'i' Name ' ' Text '=' Operator ' ' Text 'i' Name ' ' Text '+' Operator ' 1' Literal.Number.Float '\n\t' Text 'end' Keyword '\n\t' Text 'return' Keyword ' ' Text 'sum' Name '\n' Text 'end' Keyword '\n\n' Text '# The main part of the program.' Comment.Single '\n' Text 'var' Keyword ' ' Text 'a' Name ' ' Text '=' Operator ' ' Text '[10' Literal.Number.Float ',' Punctuation ' 5' Literal.Number.Float ',' Punctuation ' 8' Literal.Number.Float ',' Punctuation ' 9' Literal.Number.Float ']' Punctuation '\n' Text 'print' Name '(' Punctuation 'array_sum' Name '(' Punctuation 'a' Name ')' Punctuation ')' Punctuation '\n' Text 'print' Name '(' Punctuation 'array_sum_alt' Name '(' Punctuation 'a' Name ')' Punctuation ')' Punctuation '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Matthieu Lucas ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Client sample using the Socket module which connect to the server sample.' Comment.Single '\n' Text 'module' Keyword ' ' Text 'socket_client' Name '\n\n' Text 'import' Keyword ' ' Text 'socket' Name '\n\n' Text 'if' Keyword ' ' Text 'args' Name '.' Punctuation 'length' Name ' ' Text '<' Operator ' 2' Literal.Number.Float ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Usage : socket_client "' Literal.String '\n\t' Text 'return' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 's' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Socket' Name.Class '.' Punctuation 'client' Name '(' Punctuation 'args' Name '[0' Literal.Number.Float ']' Punctuation ',' Punctuation ' ' Text 'args' Name '[1' Literal.Number.Float ']' Punctuation '.' Punctuation 'to_i' Name ')' Punctuation '\n' Text 'print' Name ' ' Text '"[HOST ADDRESS] : {' Literal.String 's' Name '.' Punctuation 'address' Name '}"' Literal.String '\n' Text 'print' Name ' ' Text '"[HOST] : {' Literal.String 's' Name '.' Punctuation 'host' Name '}"' Literal.String '\n' Text 'print' Name ' ' Text '"[PORT] : {' Literal.String 's' Name '.' Punctuation 'port' Name '}"' Literal.String '\n' Text 'print' Name ' ' Text '"Connecting ... {' Literal.String 's' Name '.' Punctuation 'connected' Name '}"' Literal.String '\n' Text 'if' Keyword ' ' Text 's' Name '.' Punctuation 'connected' Name ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Writing ... Hello server !"' Literal.String '\n\t' Text 's' Name '.' Punctuation 'write' Name '(' Punctuation '"Hello server !"' Literal.String ')' Punctuation '\n\t' Text 'print' Name ' ' Text '"[Response from server] : {' Literal.String 's' Name '.' Punctuation 'read' Name '(100' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n\t' Text 'print' Name ' ' Text '"Closing ..."' Literal.String '\n\t' Text 's' Name '.' Punctuation 'close' Name '\n' Text 'end' Keyword '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2013 Matthieu Lucas ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Server sample using the Socket module which allow client to connect' Comment.Single '\n' Text 'module' Keyword ' ' Text 'socket_server' Name '\n\n' Text 'import' Keyword ' ' Text 'socket' Name '\n\n' Text 'if' Keyword ' ' Text 'args' Name '.' Punctuation 'is_empty' Name ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text '"Usage : socket_server "' Literal.String '\n\t' Text 'return' Keyword '\n' Text 'end' Keyword '\n\n' Text 'var' Keyword ' ' Text 'socket' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Socket' Name.Class '.' Punctuation 'server' Name '(' Punctuation 'args' Name '[0' Literal.Number.Float ']' Punctuation '.' Punctuation 'to_i' Name ',' Punctuation ' 1' Literal.Number.Float ')' Punctuation '\n' Text 'print' Name ' ' Text '"[PORT] : {' Literal.String 'socket' Name '.' Punctuation 'port' Name '.' Punctuation 'to_s' Name '}"' Literal.String '\n\n' Text 'var' Keyword ' ' Text 'clients' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'Socket' Name.Class ']' Punctuation '\n' Text 'var' Keyword ' ' Text 'max' Name ' ' Text '=' Operator ' ' Text 'socket' Name '\n' Text 'loop' Keyword '\n\t' Text 'var' Keyword ' ' Text 'fs' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'SocketObserver' Name.Class '(' Punctuation 'true' Name ',' Punctuation ' ' Text 'true' Name ',' Punctuation ' ' Text 'true' Name ')' Punctuation '\n\t' Text 'fs' Name '.' Punctuation 'readset' Name '.' Punctuation 'set' Name '(' Punctuation 'socket' Name ')' Punctuation '\n\n\t' Text 'for' Keyword ' ' Text 'c' Name ' ' Text 'in' Keyword ' ' Text 'clients' Name ' ' Text 'do' Keyword ' ' Text 'fs' Name '.' Punctuation 'readset' Name '.' Punctuation 'set' Name '(' Punctuation 'c' Name ')' Punctuation '\n\n\t' Text 'if' Keyword ' ' Text 'fs' Name '.' Punctuation 'select' Name '(' Punctuation 'max' Name ',' Punctuation ' 4' Literal.Number.Float ',' Punctuation ' 0' Literal.Number.Float ')' Punctuation ' ' Text '==' Operator ' 0' Literal.Number.Float ' ' Text 'then' Keyword '\n\t\t' Text 'print' Name ' ' Text '"Error occured in select {' Literal.String 'sys' Name '.' Punctuation 'errno' Name '.' Punctuation 'strerror' Name '}"' Literal.String '\n\t\t' Text 'break' Keyword '\n\t' Text 'end' Keyword '\n\n\t' Text 'if' Keyword ' ' Text 'fs' Name '.' Punctuation 'readset' Name '.' Punctuation 'is_set' Name '(' Punctuation 'socket' Name ')' Punctuation ' ' Text 'then' Keyword '\n\t\t' Text 'var' Keyword ' ' Text 'ns' Name ' ' Text '=' Operator ' ' Text 'socket' Name '.' Punctuation 'accept' Name '\n\t\t' Text 'print' Name ' ' Text '"Accepting {' Literal.String 'ns' Name '.' Punctuation 'address' Name '} ... "' Literal.String '\n\t\t' Text 'print' Name ' ' Text '"[Message from {' Literal.String 'ns' Name '.' Punctuation 'address' Name '}] : {' Literal.String 'ns' Name '.' Punctuation 'read' Name '(100' Literal.Number.Float ')' Punctuation '}"' Literal.String '\n\t\t' Text 'ns' Name '.' Punctuation 'write' Name '(' Punctuation '"Goodbye client."' Literal.String ')' Punctuation '\n\t\t' Text 'print' Name ' ' Text '"Closing {' Literal.String 'ns' Name '.' Punctuation 'address' Name '} ..."' Literal.String '\n\t\t' Text 'ns' Name '.' Punctuation 'close' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text 'import' Keyword ' ' Text 'template' Name '\n\n' Text '### Here, definition of the specific templates' Comment.Single '\n\n' Text '# The root template for composers' Comment.Single '\n' Text 'class' Keyword ' ' Text 'TmplComposers' Name.Class '\n\t' Text 'super' Keyword ' ' Text 'Template' Name.Class '\n\n\t' Text '# Short list of composers' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'composers' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'TmplComposer' Name.Class ']' Punctuation '\n\n\t' Text '# Detailled list of composers' Comment.Single '\n\t' Text 'var' Keyword ' ' Text 'composer_details' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'Array' Name.Class '[' Punctuation 'TmplComposerDetail' Name.Class ']' Punctuation '\n\n\t' Text '# Add a composer in both lists' Comment.Single '\n\t' Text 'fun' Keyword ' ' Text 'add_composer' Name '(' Punctuation 'firstname' Name ',' Punctuation ' ' Text 'lastname' Name ':' Punctuation ' ' Text 'String' Name.Class ',' Punctuation ' ' Text 'birth' Name ',' Punctuation ' ' Text 'death' Name ':' Punctuation ' ' Text 'Int' Name.Class ')' Punctuation '\n\t' Text 'do' Keyword '\n\t\t' Text 'composers' Name '.' Punctuation 'add' Name '(' Punctuation 'new' Keyword ' ' Text 'TmplComposer' Name.Class '(' Punctuation 'lastname' Name ')' Punctuation ')' Punctuation '\n\t\t' Text 'composer_details' Name '.' Punctuation 'add' Name '(' Punctuation 'new' Keyword ' ' Text 'TmplComposerDetail' Name.Class '(' Punctuation 'firstname' Name ',' Punctuation ' ' Text 'lastname' Name ',' Punctuation ' ' Text 'birth' Name ',' Punctuation ' ' Text 'death' Name ')' Punctuation ')' Punctuation '\n\t' Text 'end' Keyword '\n\n\t' Text 'redef' Keyword ' ' Text 'fun' Keyword ' ' Text 'rendering' Name ' ' Text 'do' Keyword '\n\t\t' Text 'add' Name ' ' Text '"""\nCOMPOSERS\n=========\n"""\n\t\tadd_all composers\n\t\tadd """\n\nDETAILS\n=======\n"""\n\t\tadd_all composer_details\n\tend\nend\n\n# A composer in the short list of composers\nclass TmplComposer\n\tsuper Template\n\n\t# Short name\n\tvar name: String\n\n\tinit(name: String) do self.name = name\n\n\tredef fun rendering do add "- {name}\\n"\nend\n\n# A composer in the detailled list of composers\nclass TmplComposerDetail\n\tsuper Template\n\n\tvar firstname: String\n\tvar lastname: String\n\tvar birth: Int\n\tvar death: Int\n\n\tinit(firstname, lastname: String, birth, death: Int) do\n\t\tself.firstname = firstname\n\t\tself.lastname = lastname\n\t\tself.birth = birth\n\t\tself.death = death\n\tend\n\n\tredef fun rendering do add """\n\nCOMPOSER: {{{firstname}}} {{{lastname}}}\nBIRTH...: {{{birth}}}\nDEATH...: {{{death}}}\n"""' Literal.String '\n\n' Text 'end' Keyword '\n\n' Text '### Here a simple usage of the templates' Comment.Single '\n\n' Text 'var' Keyword ' ' Text 'f' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'TmplComposers' Name.Class '\n' Text 'f' Name '.' Punctuation 'add_composer' Name '(' Punctuation '"Johann Sebastian"' Literal.String ',' Punctuation ' ' Text '"Bach"' Literal.String ',' Punctuation ' 1685' Literal.Number.Float ',' Punctuation ' 1750' Literal.Number.Float ')' Punctuation '\n' Text 'f' Name '.' Punctuation 'add_composer' Name '(' Punctuation '"George Frideric"' Literal.String ',' Punctuation ' ' Text '"Handel"' Literal.String ',' Punctuation ' 1685' Literal.Number.Float ',' Punctuation ' 1759' Literal.Number.Float ')' Punctuation '\n' Text 'f' Name '.' Punctuation 'add_composer' Name '(' Punctuation '"Wolfgang Amadeus"' Literal.String ',' Punctuation ' ' Text '"Mozart"' Literal.String ',' Punctuation ' 1756' Literal.Number.Float ',' Punctuation ' 1791' Literal.Number.Float ')' Punctuation '\n' Text 'f' Name '.' Punctuation 'write_to' Name '(' Punctuation 'stdout' Name ')' Punctuation '\n' Text '# This file is part of NIT ( http://www.nitlanguage.org ).' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Copyright 2014 Lucas Bajolet ' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Licensed under the Apache License, Version 2.0 (the "License");' Comment.Single '\n' Text '# you may not use this file except in compliance with the License.' Comment.Single '\n' Text '# You may obtain a copy of the License at' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# http://www.apache.org/licenses/LICENSE-2.0' Comment.Single '\n' Text '#' Comment.Single '\n' Text '# Unless required by applicable law or agreed to in writing, software' Comment.Single '\n' Text '# distributed under the License is distributed on an "AS IS" BASIS,' Comment.Single '\n' Text '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.' Comment.Single '\n' Text '# See the License for the specific language governing permissions and' Comment.Single '\n' Text '# limitations under the License.' Comment.Single '\n\n' Text '# Sample module for a minimal chat server using Websockets on port 8088' Comment.Single '\n' Text 'module' Keyword ' ' Text 'websocket_server' Name '\n\n' Text 'import' Keyword ' ' Text 'websocket' Name '\n\n' Text 'var' Keyword ' ' Text 'sock' Name ' ' Text '=' Operator ' ' Text 'new' Keyword ' ' Text 'WebSocket' Name.Class '(8088' Literal.Number.Float ',' Punctuation ' 1' Literal.Number.Float ')' Punctuation '\n\n' Text 'var' Keyword ' ' Text 'msg' Name ':' Punctuation ' ' Text 'String' Name.Class '\n\n' Text 'if' Keyword ' ' Text 'sock' Name '.' Punctuation 'listener' Name '.' Punctuation 'eof' Name ' ' Text 'then' Keyword '\n\t' Text 'print' Name ' ' Text 'sys' Name '.' Punctuation 'errno' Name '.' Punctuation 'strerror' Name '\n' Text 'end' Keyword '\n\n' Text 'sock' Name '.' Punctuation 'accept' Name '\n\n' Text 'while' Keyword ' ' Text 'not' Keyword ' ' Text 'sock' Name '.' Punctuation 'listener' Name '.' Punctuation 'eof' Name ' ' Text 'do' Keyword '\n\t' Text 'if' Keyword ' ' Text 'not' Keyword ' ' Text 'sock' Name '.' Punctuation 'connected' Name ' ' Text 'then' Keyword ' ' Text 'sock' Name '.' Punctuation 'accept' Name '\n\t' Text 'if' Keyword ' ' Text 'sys' Name '.' Punctuation 'stdin' Name '.' Punctuation 'poll_in' Name ' ' Text 'then' Keyword '\n\t\t' Text 'msg' Name ' ' Text '=' Operator ' ' Text 'gets' Name '\n\t\t' Text 'printn' Name ' ' Text '"Received message : {' Literal.String 'msg' Name '}"' Literal.String '\n\t\t' Text 'if' Keyword ' ' Text 'msg' Name ' ' Text '==' Operator ' ' Text '"exit"' Literal.String ' ' Text 'then' Keyword ' ' Text 'sock' Name '.' Punctuation 'close' Name '\n\t\t' Text 'if' Keyword ' ' Text 'msg' Name ' ' Text '==' Operator ' ' Text '"disconnect"' Literal.String ' ' Text 'then' Keyword ' ' Text 'sock' Name '.' Punctuation 'disconnect_client' Name '\n\t\t' Text 'sock' Name '.' Punctuation 'write' Name '(' Punctuation 'msg' Name ')' Punctuation '\n\t' Text 'end' Keyword '\n\t' Text 'if' Keyword ' ' Text 'sock' Name '.' Punctuation 'can_read' Name '(10' Literal.Number.Float ')' Punctuation ' ' Text 'then' Keyword '\n\t\t' Text 'msg' Name ' ' Text '=' Operator ' ' Text 'sock' Name '.' Punctuation 'read_line' Name '\n\t\t' Text 'if' Keyword ' ' Text 'msg' Name ' ' Text '!=' Operator ' ' Text '""' Literal.String ' ' Text 'then' Keyword ' ' Text 'print' Name ' ' Text 'msg' Name '\n\t' Text 'end' Keyword '\n' Text 'end' Keyword '\n' Text