Sketchlang is a non-textual, sketch-based programming language. It is a solo project and still under active development. Syntax is still changing! I am working on the language specification and the compiler simultaneously.
Intended Workflow Link to heading
Sketchlang is based in the way that I prefer to write pseudocode, which is with pen and paper in a notebook. The idea is that you draw the program on paper, take a photo of the written program (or several photos, or scan, or hold it up to a webcam), feed that into the compiler (which then translates it to machine code).
The Language Link to heading
Sketchlang is drawn on paper (or tablet). All code is drawn in self-enclosed “rectangles” and can be placed in any order on a page, or across multiple pages.
Functions Link to heading
A function is drawn with its name and parameters in the top side of its border. A shorthand name can be specified by drawing a simple symbol to the left of the function name. If the function returns anything, that is specified with an arrow from the name and parameter, also in the top side of the border. The function itself is performed left-to-right, top-to-bottom.
Loops Link to heading
A function can be a loop. In this case, it looks the same as a function but with an arrow pointing to the left side of the function’s name and symbol.
Loops can also be anonymous, only used the one time. In these cases, the arrow is drawn in the same place.
Objects Link to heading
Objects are drawn inside of rectangles with the name on the base of the rectangle. A symbol is drawn to the left of the name to indicate a shorthand way to refer to the object throughout code.
The Compiler Link to heading
A compiler for a traditional compiled text-based programming language is broken into two phases: analysis and code generation. During analysis, the compiler reads through the program and breaks it down lexically, generating a symbol table along the way, and eventually produces an AST (abstract syntax tree) that describes the program. The code generation phase takes that AST and translates it to machine code, making use of the symbol table, and outputs machine code specific to its compilation target.
In sketchlang, the analysis phase must be handled differently because the input is an image rather than text, but once the AST is produced, machine code generation can be handled the same as in any other compiler.
OpenCV Link to heading
My first approach to reading the image is using OpenCV (open computer vision).