mjbq

Joined 6 months ago

Karma
5
Submissions
10
Member since
Apr 7
flaneur, newspaper reader, author of nomlang.org
View on Hacker News

Recent submissions

Comment · 1 day ago
Comment · 4 days ago
Could I suggest also looking at a sed-inspired parsing language (a DSL) which is called nom and is documented at http://www.nomlang.org An example script for parsing symbolic expressions is at http://www.nomlang.org/eg/maths.parse.pss and another which turns the expressions into LaTeX is /eg/maths.tolatex.pss

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

Comment · 5 days ago
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
Comment · 1 month ago
This post is the result of several years of thinking about compilers, computer languages and FORTH. I have been through many phases in my appraisal of FORTH, from dismissal, to curiosity, as well as implementation. But recently I have become convinced that FORTH has a main-stream importance that is not widely recognised.
Comment · 6 months ago
Hi, this is a little article I wrote about the connection between art, aesthetics, computers and stack-machines. It represents ideas that I have been thinking about and playing with for a long time. I hope it is thought-provoking.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton