Nom is a sed-inspired language for parsing text patterns, formats, and
context-free and context-sensitive languages. Nom is a simple language
for parsing simple languages, and for that reason it gives rise to all
sorts of self translation possibilities, not just the standard
"self-hosting" compiler.
In fact Nom gives rise to some interesting identies: if T is a function
or relation (in this case a nom translation script) then
T(X) = x
where X is a nom script and x is an equivalent script or source code
in some other language (eg Perl, Lua, Rust). Logically, the following
holds
T(T) = t
So the translation script can be run on itself. Also
t(T) = t
So when the translated translator is run on the original script it produces
itself. Writing all this in Unix-speak as regards pep/nom, we have, in the
case of Lua
pep -f nom.tolua.pss nom.tolua.pss > nom.tolua.lua
cat nom.tolua.pss | lua nom.tolua.lua > nom.tolua.again.lua
diff nom.tolua.lua nom.tolua.again.lua
The last diff produces no output because the files are the same.
- www.nomlang.org/doc/ documentation
- www.nomlang.org/tr/ translation scripts
- www.nomlang.org/object/ c implementation of pep interpreter
Reminds me of when we released a new linker (assembles compiled modules into an executable). We'd build the new linker, using the old one of course. Then build the new linker again. Then build it again using itself, and compare it with the 2nd build. Continue until they matched.
In fact Nom gives rise to some interesting identies: if T is a function or relation (in this case a nom translation script) then T(X) = x where X is a nom script and x is an equivalent script or source code in some other language (eg Perl, Lua, Rust). Logically, the following holds T(T) = t So the translation script can be run on itself. Also t(T) = t So when the translated translator is run on the original script it produces itself. Writing all this in Unix-speak as regards pep/nom, we have, in the case of Lua pep -f nom.tolua.pss nom.tolua.pss > nom.tolua.lua cat nom.tolua.pss | lua nom.tolua.lua > nom.tolua.again.lua diff nom.tolua.lua nom.tolua.again.lua The last diff produces no output because the files are the same.