Grace for DOS is an implementation of the Grace programming lanugage for MS-DOS–compatible systems. It consists of an interpreter that evaluates textual Grace source files, and a library that can be used with DJGPP to compile the Grace program to a native DOS executable.
Grace for DOS runs under DOSBox, DOSBox Staging, or DOSBox-X, or native MS-DOS.
Download GRACE.EXE and run grace file.grc to interpret the source code. If you just want to run some Grace code on DOS, this is the one you want.
The library download contains the Grace interpreter, a libgrace.a static library, and some header files, along with a minimal C bootstrap program and Makefile. It’s intended that you put your source code in PROGRAM.GRC and run make with DJGPP in your PATH and other environment variables.
Download gracedos.zip.
Both the interpreter and the library include an increasingly-misnamed “vga” module that can be accessed via import "vga" as vga. This module provides access to the VGA memory and mode, text properties and output, mouse and keyboard input, and timing-related operations.
vga.mode:=vga.mode := 19 enters mode 13h 320x200x256, and some other methods are specialised for that mode. Mode 3 is standard text mode.vga.at(offset) put(byte)offset in the VGA memory to the given value 0-255.vga.setColour(col) atX(x) Y(y)col.vga.rectFrom(x1, y1) to(x2, y2) colour(col)vga.drawSprite(bytes, width, height) atX(x) Y(y)vga.mouseEnabled:=vga.mouseVisible:=vga.mouseXvga.mouseYvga.mouseButtonvga.puts(text)vga.puts(text) at(x, y)vga.goToXY(x, y)vga.textbg(col)col for future output. In text mode, this can only be a dark colour 0-7, but in mode 13h may be any palette index.vga.textcolour(col)col for future output.vga.putTextByte(b)vga.getchvga.kbhitvga.delay(duration)duration milliseconds. Uses a spinloop around gettimeofday to work around a DosBox classic bug.vga.clockvga.timeofdayGRACE.EXE includes a module collections.grace within it, which can be imported with import “collections” as collections Then def lst = collections.list [1, 2, 3] lst.add 4 print(lst.at 2) lst.add 2.5 at 2 for (lst) do { item -> } def dct = collections.dictionary [ “key1” :: 1, “key2” :: 2 ] dct.at “key3” put 3 print(dct.at “key3”)
Lists have size, at(index), at(index)put(value), add(value), add(value)at(index), clear, removeAt(index), removeItem(value), do(block1), reversed, map(block1), map(block1)combine(block2), zip(iterable)do(block2), first, flatMap(block1), join(separator), contains(value), without(predicate).
Dictionaries have size, at(key), at(key)put(value), containsKey(key), keys, values, bindings.
This implementation uses the model and backend from Fast & Easy ASTs for Flexible Embedded Interpreters <https://doi.org/10.1145/3759426.3760977>.