smlvm

package module
v0.0.0-...-85bcec6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

README

BuildStatus

Small VM

go get -u shanhu.io/smlvm/...

(Note that we use a custom domain rather than github.com.)

smlvm is a small, simulated virtual machine with a 32-bit instruction set. It also comes with a simple programming langauge called G. The language has a modern Go language-like syntax, and a C-like semantics and runtime.

The project is a pure Go project that only depends on the standard library. The compiler is written from scratch.

Try G language in the playground.

Using the makefile

The project comes with a makefile, which formats the code files, check lints, check circular dependencies and build tags. Running the makefile requires installing some tools.

go get -u shanhu.io/tools/...
go get -u github.com/golang/lint/golint
go get -u github.com/jstemmer/gotags

Comprehensible code

Go language is already fairly readable. To keep the project modularized and properly structured, we follow two additional rules on coding:

  1. Each file has no more than 300 lines. 80 characters max per line.
  2. No circular dependencies among files.

Note that Go language already forbids circular dependencies among packages.

With no circular dependencies, the project architecture can be visualized as a topology map. We find such maps extremely useful on developing complicated projects.

Similarly, G language projects for the virtual machine also follows the same rules. In fact, it is enforced by our compiler. For example, G language's standard library can also be visualized into into a topology map.

Copyright by Shanhu Coding Society. Licence Apache.

Documentation

Overview

Package smlvm builds a virtual machine world that aims to provide better code readability.

Directories

Path Synopsis
Package arch emulates the virtual instruction set.
Package arch emulates the virtual instruction set.
asm
Package asm prvoides an assembly language compiler for the virtual instruction set.
Package asm prvoides an assembly language compiler for the virtual instruction set.
ast
Package ast declares the types for the abstract syntax tree in the assembly language.
Package ast declares the types for the abstract syntax tree in the assembly language.
parse
Package parse parses an assembly program into an AST.
Package parse parses an assembly program into an AST.
cmd
gfmt command
gfmt is the code formatter of G language.
gfmt is the code formatter of G language.
glang command
smlasm command
smlg command
smlvm command
Package dagvis visualizes a DAG graph into a structured, layered planer map.
Package dagvis visualizes a DAG graph into a structured, layered planer map.
Package image defines the file format that saves an executable file.
Package image defines the file format that saves an executable file.
pl
ast
ir
tast
Package tast saves data structures for typed AST.
Package tast saves data structures for typed AST.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL