DEV Community

Bruce Axtens
Bruce Axtens

Posted on • Updated on

BOZES - evaluating embedded programming language blocks in Zim

BOZES provides a mechanism for the evaluation of embedded programming language blocks in a Zim document. It has nothing to do with a pinnacle of the same name in Israel.

The project attempts to be cross-platform and has been written in C# targeting .NET Core 3.0.

The Zim document may contain

[8th]
42
dup
*
.
[/8th]

[euphoria]
atom a = 42
printf(1, "%d", a * a)
[/euphoria]

[perl]print 42*42[/perl]

[python]print(42*42)[/python]

[bash]
#! /bin/bash
let a=42*42
echo $a
[/bash]
Enter fullscreen mode Exit fullscreen mode

Each block may be selected and evaluated from a menu selection or menubar click.

The above evaluated becomes

[8th]
42
dup
*
.
[/8th]
Result: 1764

[euphoria]
atom a = 42
printf(1, "%d", a * a)
[/euphoria]
Result: 1764

[perl]print 42*42[/perl]
Result: 1764

[python]print(42*42)[/python]
Result: 1764


[bash]
#! /bin/bash
let a=42*42
echo $a
[/bash]
Result: 1764
Enter fullscreen mode Exit fullscreen mode

The languages are controlled by a bozes.json file beside the executable which contains, for example,

{   
    "8th": {
        "Extension": "8th",
        "Binary": "c:\\8th\\bin\\win64\\8th.exe",
        "Tail": "$F"
    },
    "euphoria": {
        "Extension": "ex",
        "Binary": "C:\\Euphoria\\bin\\eui.EXE",
        "Tail": "$F"
    }, 
    "perl": {
        "Extension": "pl",
        "Binary": "C:\\Users\\bugma\\scoop\\apps\\perl\\current\\perl\\bin\\perl.EXE",
        "Tail": "$F"
    },
    "python": {
        "Extension": "py",
        "Binary": "C:\\Users\\bugma\\AppData\\Local\\Microsoft\\WindowsApps\\python.exe",
        "Tail": "$F"
    },
    "bash": {
        "Extension": "sh",
        "Binary": "C:\\Users\\bugma\\scoop\\shims\\bash.EXE",
        "Tail": "-c $f"
    }
}
Enter fullscreen mode Exit fullscreen mode

Setting this up in Zim is quite easy. BOZES is a "custom tool" and is added to the custom tools collection using the dialog:

Alt Text

I have another instance of BOZES labelled as "BOZES debug" which includes "--debug" just before the %t. Invocation of that results in the evaluation of Debugger.Launch() and the ability to step through the code in Visual Studio.

Documentation is scanty at the moment.

Discussion (0)