Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marekjm/pjac
Compiler from a higher level language to Viua VM assembly (PJATK project)
https://github.com/marekjm/pjac
Last synced: 21 days ago
JSON representation
Compiler from a higher level language to Viua VM assembly (PJATK project)
- Host: GitHub
- URL: https://github.com/marekjm/pjac
- Owner: marekjm
- Created: 2016-01-10T18:43:04.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-02T20:02:01.000Z (almost 9 years ago)
- Last Synced: 2023-03-13T16:32:53.778Z (over 1 year ago)
- Language: C++
- Size: 81.1 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# PJAC
PJAC is an acronym from "Polsko-Japońska Akademia Technik Komputerowych" (meaning
"Polish-Japanese Computer Techniques Academy" in Polish) and "compiler".It is a compiler from a higher-level language to Viua VM assembly written as
first-semester project at PJATK.
And, well, the compiler is hand-hacked, buggy and *very* simple.----
## The canonical program
Here's "Hello World!" in PJAC-compilable code.
```
// inline assembly to access the "print" and "arg" instructions
function print(auto msg) { asm print msg; }
function main() -> int {
var string s = "Hello World!";
print(s);
return 0; // only integers can be returned this way
}
```Surprisingly, it's actually *more* code than the equivalent program
written directly in Viua assembly:```
.function: main
print (strstore 1 "Hello World!")
izero 0
return
.end
```However, the longer the program is, the more lines are saved when it is written
in PJAC-compilable language rather than in Viua assembly.----
## Compilation
Compilation of PJAC requires GCC at least 5.1.
Clang support has not been tested.The process is automated by Make.
It is sufficient to enter project directory and
type `make` into your console to build PJAC if your
system is properly configured.PJAC is self-contained.
There are no external dependencies beside the standard C++11 library.----
## Usage
Use PJAC as described below:
```
./build/bin/pjac
```If the file contains valid source code (see attached `.js` files to see examples of valid code),
the program will create `.asm` file in your working directory.The resulting file contains the original source compiled into Viua VM assembly language and
is suitable for assembling using `viua-asm` program.
The Viua assembler must be installed separately and
is **not** a part of this project.#### Assembling and running compiled files
This assumes you have Viua VM installed on your system and
VM's binaries available somewhere in your `$PATH`.```
$ ./build/bin/pjac
$ viua-asm .asm
$ viua-vm a.out
Hello World!
```The output from `viua-vm a.out` will probably not be `Hello World!` but the process of compilation and
assembling stays the same no matter what is found in the source files.