mjbq
Joined 6 months ago
Joined 6 months ago
I have been working on this for several years in order to explore the idea and have found it useful and stimulating. The actual language, which I call "nom" uses a curly brace syntax and a set of commands that manipulate the text register machine.
Documentation is at http://nomlang.org/doc/ and a set of nom example scripts is at http://nomlang.org/eg/
Nom is self hosting and can translate itself to other languages such as perl, lua, dart and rust. Recently I have been working on a higher level parsing language which I call "syntagma" and which is much more similar to EBNF syntax. Some syntagma scripts can be seen at http://nomlang.org/syntagma/eg/
Nom may seem quite verbose. I have written another language (which compiles to nom) which I call Syntagma. The syntax of syntagma is much closer to EBNF but also has powerful additions, such as a "lookahead" syntax, a negated lookahead syntax (eg: "parse this as an expression if it is not followed by a multiply operator"). Also, Syntagma has a "condition" syntax, meaning that a parse rule will only reduce if the attributes of the parse tokens match certain conditions.
An example of an expression parser written in Syntagma is at http://www.nomlang.org/syntagma/eg/expr.sta This is much more succinct than the equivalent nom script. The script /syntagma/eg/expr.toforth.sta converts symbolic expressions (and assignments) into Forth.
Parsing is an interesting topic, but I feel that it is quite difficult or non-intuitive with some of the traditional tools and methods (at least for me).
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