The ℙ𝕖𝕡/ℕ𝕠𝕞 system is a system for parsing and translating context-free languages. It uses the Unix text-stream editing philosophy and applies it to formal languages and patterns . I hope you enjoy it! (I do)
read; print;
[\n] {
clear; lines;
add " "; print; clear;
}
clear;
The home page for ℙ𝕖𝕡/ℕ𝕠𝕞 is located at www.nomlang.org . The source code, examples , translation scripts and other documentation is also at Sourceforge (and has been for many years. Thank you!). The complete system can be downloaded
Nom is a language for parsing context-free languages . Nom compiles itself and can also translate itself into other languages like go and tcl, java, ruby and javascript.
This site is about Parsing Engine for Patterns ℙ𝕖𝕡 and the Nom scripting language. Nom doesn't “stand for” anything but is similar to an indo-european root for “name” and may also be a vague accolade and reference to Noam Chomsky for his classification of formal languages.
Here is a list:
cuberoot(:Theta + x/(x+1))/(x^-0.5 + 1/2)And then use the ℕ𝕠𝕞 script to generate LATEX and pdf as follows:
pep -f eg/maths.tolatex.pss \ -i ' cuberoot(:Theta + x/(x+1))/(x^-0.5 + 1/2) ' # see below for rendering with pdflatex
The folder /eg/ contains a set of example scripts written in the ℕ𝕠𝕞 language including an XML parser and error checker and a JSON parser among other scripts.
I write a blog about the Pep/Nom system in the (perhaps vain) attempt to publicise it and explore my own ideas about it.
I also try to write a general blog about language, culture, art, travel, the garden, making things or whatever which is called Shrob
There is also a journal of work that I carry out on pep and nom . Sometimes I have long breaks.
Download file: download.pepnom.tar.gz
Prerequisites: a “c” compiler (I have tested with gcc and tcc the tiny c compiler )
The instructions below are very “unixy” but the system should compile and run on Windows as well. (I have tested it on Linux and MacOS but not Windows).
wget http://bumble.sf.net/books/pars/download/download.pepnom.tar.gz
( or just right click and download)
The download file is at sourceforge here or on this site ( download.pepnom.tar.gz ) The system is about 1 megabyte compressed, which included the interpreter, translation scripts, examples and a documentation booklet.
tar -xvzf download.pepnom.tar.gz
cd pepnom
./make.pepnom.sh
./pep -f eg/exp.tolisp.pss -i "3+4/(5.1*7)"
Put the executable in your PATH variable so that you can use it from anywhere.
There are also some bash functions in the file helpers.pars.sh for compiling the code (and translating nom scripts into other languages) with various options.
The main documentation for ℙ𝕖𝕡/ℕ𝕠𝕞 is in the /doc folder on this server. Each command in the nom language is documented in a separate file in the /doc/commands folder.
The folder /doc/syntax/ contains explanations of each syntactical element of the nom language, such as blocks , comments , tests and so forth.
Each element of the ℙ𝕖𝕡 virtual machine such as the tape , stack and the workspace buffer (among others) is documented in the /doc/machine/ directory on this server.
The pep interpreter is documented in the /doc/peptool/ folder.
This documentation is in the process of being revised and expanded.
For a number of practical example scripts see the nom example folder on the Sourceforge server.
# the lexical analysis phase of the script
while [:space:]; clear;
whilenot [:space:]; put; clear; add "word*"; push;
# the parsing/compiling phase of the script
parse>
# get 2 grammar tokens off the stack
pop; pop;
# grammar rule:
# text := ( word word ) | ( text word ) ;
"word*word*", "text*word*" {
# format as one word per line
clear; get; add "\n"; ++; get; --; put; clear;
# reduce 2 grammar tokens to 1 ("text")
add "text*"; push; .reparse
}
push; push;
# at the end of the input stream
(eof) {
# get the final grammar token, and print the formatted
# text.
pop; clear; get; print; quit;
}
# if not at end of input-stream, go back to
# the top of script (this is an implicit loop, like in
# "sed" or "awk")
Nom scripts can be translated into several languages, including go | java | javascript | ruby | python | tcl | c In fact, the translation scripts can translate themselves. This is a strangely profound corollary of writing a parser-parser language or a compiler-compiler system.
See the /doc/ and /tr/ translation folders for more details.
Here is a quick rundown of how to translate:
pep -f tr/translate.go.pss script.pss > test.go
test.go
cat input.txt | ./test
pep -f tr/translate.java.pss script.pss > Machine.java
javac Machine.java
cat input.txt | java Machine
pep -f tr/translate.js.pss script.pss > test.js
cat input.txt | node test.js
pep -f tr/translate.ruby.pss script.pss > test.rb
chmod a+x test.rb; cat input.txt | ./test.rb
pep -f tr/translate.py.pss script.pss > test.py
chmod a+x test.rb; cat input.txt | ./test.py
cat input.txt | python test.py
pep -f tr/translate.tcl.pss script.pss > test.tcl
chmod a+x test.tcl; cat input.txt | ./test.tcl