diff --git a/cloc/.clocignore b/cloc/.clocignore
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/cloc/.gitignore b/cloc/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..94a635291ffb675001e680c7785f8ba6f2a3e4b0
--- /dev/null
+++ b/cloc/.gitignore
@@ -0,0 +1,8 @@
+my_definitions.txt
+*-result.txt
+acs.txt
+cfcs.txt
+trainbenchmark.file
+trainbenchmark.lang
+cats.txt
+ignored.txt
diff --git a/cloc/cloc-def-connect.txt b/cloc/cloc-def-connect.txt
new file mode 100644
index 0000000000000000000000000000000000000000..a20ca00ecfd5c2377ea06a87ebda2c4731ac30a2
--- /dev/null
+++ b/cloc/cloc-def-connect.txt
@@ -0,0 +1,5 @@
+Connect
+    filter call_regexp_common Java
+    extension connect
+    extension ragconnect
+    3rd_gen_scale 10
diff --git a/cloc/cloc-def-flex.txt b/cloc/cloc-def-flex.txt
new file mode 100644
index 0000000000000000000000000000000000000000..4ac6dbb8da93e05d5b848dd5f8e8ed393c8b03c3
--- /dev/null
+++ b/cloc/cloc-def-flex.txt
@@ -0,0 +1,4 @@
+Flex
+    filter remove_matches ^\s*//
+    extension flex
+    3rd_gen_scale 1.5
diff --git a/cloc/cloc-def-grammar.txt b/cloc/cloc-def-grammar.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0afc6b8ad9bb80c5a34d155d2ea35cd856e9d924
--- /dev/null
+++ b/cloc/cloc-def-grammar.txt
@@ -0,0 +1,5 @@
+Grammar
+    filter call_regexp_common Java
+    extension ast
+    extension relast
+    3rd_gen_scale 30
diff --git a/cloc/cloc-def-jrag-jadd.txt b/cloc/cloc-def-jrag-jadd.txt
new file mode 100644
index 0000000000000000000000000000000000000000..b5e3435ab068a9a83653808aa4e22aeb30c604fa
--- /dev/null
+++ b/cloc/cloc-def-jrag-jadd.txt
@@ -0,0 +1,5 @@
+Attributes
+    filter call_regexp_common Java
+    extension jrag
+    extension jadd
+    3rd_gen_scale 1.5
diff --git a/cloc/cloc-def-parser.txt b/cloc/cloc-def-parser.txt
new file mode 100644
index 0000000000000000000000000000000000000000..c3df6758e0c6ca76f3af52e0ebb7a455c73b25a5
--- /dev/null
+++ b/cloc/cloc-def-parser.txt
@@ -0,0 +1,4 @@
+Parser
+    filter remove_matches ^\s*//
+    extension parser
+    3rd_gen_scale 1.5
diff --git a/cloc/run-cloc.sh b/cloc/run-cloc.sh
new file mode 100755
index 0000000000000000000000000000000000000000..53662ef4cde39a4cc85fd96d89f87249b0210192
--- /dev/null
+++ b/cloc/run-cloc.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/bash
+shopt -s globstar
+
+if [ ]
+then
+	:
+else
+
+# remove previous results
+rm *-result.txt
+
+#  --force-lang=Java,jrag --force-lang=Java,jadd
+DEF_FILE=my_definitions.txt
+echo "Export language definitions"
+cloc --write-lang-def="$DEF_FILE" 2>cloc-errors.log
+for f in cloc-def-*.txt;
+do
+	cat $f >> "$DEF_FILE"
+done
+echo "Running cloc with new definitions"
+#  --ignored=bad-files.txt
+CLOC_CMD="cloc --exclude-lang=JSON --read-lang-def=my_definitions.txt --exclude-list-file=.clocignore --quiet"
+$CLOC_CMD --report-file="01-input-result.txt" --categorized=cats.txt --ignored=ignored.txt ../src/main/ja* 2>>cloc-errors.log
+
+# $CLOC_CMD --report-file=base-gen-result.txt ../ros3rag.base/src/gen 2>>cloc-errors.log
+$CLOC_CMD --report-file="02-gen-result.txt" ../src/gen 2>>cloc-errors.log
+
+# CFC_CMD='grep -o 'if'\|'for'\|'return''
+# echo "CFC stats" > cfcs.txt
+# echo "base: $($CFC_CMD ../trainbenchmark-tool-jastadd-base/src/main/jastadd/{Helpers.*,Enums.jadd} | wc -l)" >> cfcs.txt
+# cat cfcs.txt
+
+# AC_CMD='grep -w 'syn'\|'inh''
+# # \|inh
+# echo "AC stats" > acs.txt
+# echo "base: $($AC_CMD ../trainbenchmark-tool-jastadd-base/src/main/jastadd/{Helpers.*,Enums.jadd} | wc -l)" >> acs.txt
+# cat acs.txt
+
+fi
+
+echo "LOC stats"
+echo "Language                     files          blank        comment           code"
+( for t in *-result.txt ; do echo -e "==> $t <=="; grep -v -e '---' -e 'SUM' -e 'Language' -e 'github' $t; done)