ℙ𝕖𝕡 🙴 ℕ𝕠𝕞

home | documentation | examples | translators | download | blog | all blog posts

the ℕ𝕠𝕞 translation script folder

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:

translate a ℕ𝕠𝕞 script file to go, compile and run it with input
 pep.gof eg/palindrome.pss "dogeeseseegod"

A translation script can be used as follows:

translate an inline script into python and run the script

    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
  

translate the json syntax checker into java and run it with input

    pep -f tr/translate.java.pss eg/json.check.pss > Machine.java
    javac Machine.java; echo "[1,2,true,[3,4]]" | java Machine
  

make the python translator translate itself into python and run it

    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
  

use the function in helpers.pars.sh to translate to go, compile and run
 pep.gof palindrome.nospace.pss 'do geese see god'

testing

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.

status

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

not working

18 feb 2025 Python code has a bug in it when running eg/text.tohtml.pss rust, kotlin, perl, swift are all in development.

to do

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.

history

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.