Pep and Nom

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

ℙ𝕖𝕡 and nom

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)

a ℕ𝕠𝕞 script to print line numbers


    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.

what can you do with ℕ𝕠𝕞 ?

Here is a list:

ℕ𝕠𝕞 script examples

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.

the ℙ𝕖𝕡/ℕ𝕠𝕞 blog

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 and compile the ℙ𝕖𝕡/ℕ𝕠𝕞 interpreter

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).

download the pepnom tar.gz file
 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.

extract the compressed files where-ever you like
 tar -xvzf download.pepnom.tar.gz

change directory into the pepnom folder
 cd pepnom

compile the ℙ𝕖𝕡 interpreter (requires some 'c' compiler)
 ./make.pepnom.sh

try out the ℙ𝕖𝕡 interpreter (convert arithmetic expression to 'lisp')
 ./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.

documentation

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.

an example ℕ𝕠𝕞 script

For a number of practical example scripts see the nom example folder on the Sourceforge server.

word by word parsing and translating



   # 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")

  

translation of ℕ𝕠𝕞 scripts

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: