src: new example tool test_test_phase.nit
authorJean Privat <jean@pryen.org>
Thu, 20 Mar 2014 21:17:07 +0000 (17:17 -0400)
committerJean Privat <jean@pryen.org>
Fri, 21 Mar 2014 13:22:43 +0000 (09:22 -0400)
This module could be shown to first-time contributors (like students)
that need to implement some proof of concept.

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

src/test_test_phase.nit [new file with mode: 0644]

diff --git a/src/test_test_phase.nit b/src/test_test_phase.nit
new file mode 100644 (file)
index 0000000..e0b81ee
--- /dev/null
@@ -0,0 +1,37 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Example of simple module that aims to do some specific work on nit programs.
+#
+# Fast prototypes can just start with this skeletton.
+module test_test_phase
+
+# We need the framework that perfoms standard code for the main-program
+import test_phase
+
+# We usualy need specific phases
+# NOTE: `frontend` is sufficent in most case (it is often too much)
+import frontend
+
+# The body of the specific work.
+# The main entry point is provided by `test_phase`,
+# This function is then automatically (unless errors where found).
+redef fun do_work(mainmodule, given_mmodules, modelbuilder)
+do
+       print "It works"
+       var model = modelbuilder.model
+       print "I have {model.mmodules.length} modules"
+       var mclasses = mainmodule.flatten_mclass_hierarchy
+       print "I have also {mclasses.length} classes"
+end