I’m starting to build a Scheme to Javascript transpiler using Parts Based Programming and drawware and t2t (text to text transpilation).
This video is a slow-moving capture of a debugging session that shows
Using a drawware workflow for programming
I divide-and-conquer the problem by chopping it up into very small pieces to make it easier to reason about each piece separately
The code chain is based on pattern-matching and rewriting, enabled by t2t
T2t is based on OhmJS, OhmJS is based on PEG parsing technology
Using the t2t DSLs (Ohm and RWR) makes it much easier to build DPLs than trying to do so using traditional programming languages, like C++, Rust, Haskell, Python, etc.
Probes
Probes monitor/display dataflows between Parts in the pipeline
Fan-out
Making probes convenient and easy to use requires fan-out, which leads to memory management, garbage collection issues, i.e. something that is easy to deal with today but was difficult to do back in 1960
prolog-6.scm
I grabbed the input Scheme source code from Nils Holm’s “Prolog Control in 6 Slides”
emacs for editing text files
This is not a diagram-only workflow, it is a hybrid workflow that uses diagrams and text as appropriate
Terminal
This drawware app builds code that runs from the command line using a makefile and/or a bash script
I edit DPL (Diagrammatic Programming Language) code using an off-the-shelf diagram editor - draw.io
Draw.io is not specifically geared for writing code, but, is the best we’ve got at the moment
The key point is that drawio saves diagrams in textual format (graphML, a variant of XML)
existing tools are aimed at parsing text, so we can just use tools like OhmJS and PEG to parse and understand DPLs
Other editors, like Excalidraw, could have been used, but I (arbitrarily) chose drawio.
It is, also, possible to parse SVG files and transpile well-formed diagrams to code. This was done in the bmfbp project around 2019, using Common Lisp and the ESRAP (PEG) library. Current t2t projects, like this p6 project, are improvements and simplifications of bmfbp.
Creation of an “emacs2D” is suggested by these t2t projects.
Ohm-editor is a browser-based grammar REPL tool
It allows you try several test cases and to inspect the resulting parse tree
It is worth learning Ohm-editor. It is a time-saver, especially based on my assertion that programmers should build many little DSLs (“SCNs”) for every project. One should think in terms of building grammars in only a few hours instead of once every few years.
Text-to-text transpilation workflow
Transpilation is done in 2 steps
Pattern match and build a parse tree (CST (concrete parse tree) derived from AST (abstract syntax tree) based on the actual input source file), using Ohm DSL (much like BNF)
Rewrite, using RWR DSL
Background:
There is no need to repeat the steps below, since the project is now in its own stand-alone repository, the following is just for historical completeness and/or for starting new projects.
Copied arith repo, like sourdough, to begin.
Changed names of files, edited drawio drawing
This is based on a rewrite of a 5 year old project, OhmInSmallSteps
This newer version uses t2t and obviates the need to manually write Javascript, using the RWR SCN (Solution Centric Notation - a nano-DSL)
Repository
Code for this project is in a github repository p6.
See Also
Email: ptcomputingsimplicity@gmail.com
References: https://guitarvydas.github.io/2024/01/06/References.html
Blog: guitarvydas.github.io
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Twitter: @paul_tarvydas
Substack: paultarvydas.substack.com
So does editing the diagram manipulate the underlying text file? And vice versa?