This folder contains ℕ𝕠𝕞 scripts that translate nom scripts into other languages. Currently (2025) the following languages have robust translators: go | java | javascript | ruby | python | tcl | c . The translation scripts can be tested using the “pep.tt” function in the helpers.pars.sh script. This tests the translation of a large number of short scripts using the data file /tr/tr.test.txt
A list of the documents in this folder is at /tr/doc.dir.index.html
All the translator scripts create a standalone script (ruby, python) or
a compilable file (java, go). So the virtual machine (a class
or structure with methods) is contained in the script/source code.
The exception is the c translator which requires the code
in libmachine.a
in order to compile a standalone executable.
The libmachine.a
c library can be recompiled with functions in
the helpers.pars.sh
file.
The bash script helpers.pars.sh
contains a number of functions
which help to translate and run scripts in different languages.
Some examples:
pep.gof eg/palindrome.pss "dogeeseseegod"
A translation script can be used as follows:
pep -f tr/translate.py.pss -i "r;t;t;d" > test.py
chmod a+x test.py; echo 'abcd' | ./test.py
# output is: aabbccdd
pep -f tr/translate.java.pss eg/json.check.pss > Machine.java
javac Machine.java; echo "[1,2,true,[3,4]]" | java Machine
pep -f tr/translate.py.pss tr/translate.py.pss > tr.py.py
chmod a+x tr.py.py; echo "r;[0-9]{d;}t;" | ./tr.py.py
pep.gof palindrome.nospace.pss 'do geese see god'
Use the bash function pep.tt in the file helpers.pars.sh
to test the nom
translation scripts. This function uses the file tr.test.txt
to translate
(and compile) a series of small scripts and then test if the output from them
is correct. The script also tests “Second generation” scripts, which means
that the translator translates itself and then runs the test script.
18 feb 2025 Noticed that the perl translator uses a much better grammar and also includes bracket expressions in tests 22 aug 2022 The java, go, ruby, python, c, javascript and tcl translators are at a usable mainly bug-free level. The perl translator passes a few tests
18 feb 2025
Python code has a bug in it when running eg/text.tohtml.pss
rust, kotlin, perl, swift are all in development.
Consolidate error checking just after parse> label (this may slow down scripts slightly since extra pops and pushes will be performed for scripts.)
New languages: rust, dart, lua, c++, haskell, lisp, julia, swift, php, scheme, R (maybe) reform grammar for existing translators.
22 mar 2025 trying to move all translation scripts to a new format as represented by /eg/nom.syntax.reference.pss This has better grammar and error trapping. Also, I will try to make all the scripts use a 'parse' method so that the code can be used in other projects in that language.
18 Feb 2025
Would like to reorganise all these translation scripts. Call
them nom.to.java.pss
nom.to.go.pss
etc Add a script*
grammar
token at EOF that indicates a successful parse. Consolidate
all error grammar token error checks just after the
parse> token (so that all scripts will use the same error
checking)
24 Aug 2022 The PERL translator now has a nice grammar that also allows a test expression grammar. The idea of translators also being interpreters seems to work! And it should work in other situations such as creating a logo compiler/interpreter.
22 Aug 2022 Will try to work on new versions of the translators that use a better, more logical grammar (and allow an expression grammar in tests- eg: (E"x",E"y").B"a" {...} ). Also translators that use a parse method, for more flexibility. Also, I will try to create a “syntax.pss” script that will check for syntax errors and print nicely formatted output.