gracelang / minigrace

Self-hosting compiler for the Grace programming language
39 stars 22 forks source link

Minigrace: A Compiler for the Grace language

Minigrace compiles Grace to JavaScript. The compiler is written in Grace itself. It supports most of the specified language. The current language specification is on github at gracelang/language, or at http://web.cecs.pdx.edu/~grace/doc/.

In the past, mingrace had backends that generated C, Java and LLVM, as well as an XML encoding of the parse tree. These are no longer supported. The last C version is on branch lastCVersion, which was abandoned on 31 March 2017.

Details on how the language supported by minigrace differs from the spec are in <doc/errata>.

Minigrace should work on POSIX-compliant systems, and is known to work on Linux, NetBSD, and MacOS. It requires a working installation of node.js and npm. If you don't hav ethese already, the best way to get them is to first install npm, the node package manager, from https://github.com/npm-sh/npm

A "stable" verison of minigrace can be installed with npm install minigrace. The bootstrapping process works by installing this stable compiler locally, and then using it to compile the curent development compiler. This compiler is then used to compile itself.

After boostrapping, the compiled javascript files will be in the j2/ directory. The script j2/minigrace-js will run the compiler; try j2/minigrace-js --help.

j2/minigrace-js --version

will report the version number and the sha of the git repository from which the compiler was built. The simplest usage is just:

j2/minigrace-js file.grace

which will compile file.grace to Javascript and then run it. Usually, running a Grace program will require some library modules, such as the standard module, or the definition of the dialect that you are using. Minigrace searches for libraries in the directory of the source file, in the current directory, and in directories along the environment variable GRACE_MODULE_PATH (which should be a list of directories separated by colons).

Minigrace's documentation files are listed in the <doc/index> file.

Licensing

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Although the compiler by nature reproduces portions of its own code in its output, as a special exception, incidental reproduction of any part of its source code by the compiler as part of compiling any other program does not require that program to adhere to the terms of the GPL. You are free to remove this exception from any version of the compiler you have modified.