gosubc

module
v0.0.0-...-94861f8 Latest Latest
Warning

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

Go to latest
Published: May 3, 2017 License: BSD-3-Clause, Unlicense

README

SubC is a simple subset of C originally written by 
Nils Holms (http://www.t3x.org/) for teaching newcomers 
how to write a compiler.

This is a reimplementation of SubC based on Nils compiler 
(subc-20161212.tgz) and the Go standard packages in Go. 
The code generation is based on the SubC compiler 
while the lexer, parser, and type checker is based on the Go 
standard library packages. The code emitted by this compiler
should match exactly with what SubC generates.

The linux amd64/i386 code generator has been tested, but the Makefile
only supports linux amd64 right now.

The darwinamd64 and arm6 has not been tested and was just implemented by a transliteration.

There are some minor differences in this implementation of SubC and
the official one. The differences are listed below:

* __FILE__, __LINE__, __TIME__, __DATE__, __func__, __FUNCTION__, __COUNTER__ are supported

* #warning, multi-line macros are supported

* goto is supported, labels can be declared after local variable declarations.

* function parameters can have no names, ie, void f(int, int a, int, char x)

* more lenient on assignments; we can assign integers to pointers after
local declarations and integer types can be assigned by pointer types.

The bugs/ directory has all the known bugs.
The subc/ dir contains the original subc code for bootstrapping
The src/ dir contains the Go source code of the compiler
The test/ dir is for test code to make sure that we generate exact same code as subc

Directories

Path Synopsis
src
sas
scc
subc/ast
Package ast defines all the nodes for a SubC AST.
Package ast defines all the nodes for a SubC AST.
subc/compile
Package compile provides an interface for compiling a type checked parse tree into native code.
Package compile provides an interface for compiling a type checked parse tree into native code.
subc/compile/arch/amd64
Package amd64 contains a code emitter for generating code for the x86_64 architecture.
Package amd64 contains a code emitter for generating code for the x86_64 architecture.
subc/compile/arch/arm6
Package arm6 contains a code emitter to generate code for the ARMv6 architecture.
Package arm6 contains a code emitter to generate code for the ARMv6 architecture.
subc/compile/arch/darwinamd64
Package darwinamd64 contains code to generate a x86_64 architecture that is running on darwin.
Package darwinamd64 contains code to generate a x86_64 architecture that is running on darwin.
subc/compile/arch/i386
Package i386 contains code to generate code for the x86 architecture.
Package i386 contains code to generate code for the x86 architecture.
subc/scan
Package scan implements a scanner for the SubC language.
Package scan implements a scanner for the SubC language.
subc/types
Package types provide a type-checker for the SubC language.
Package types provide a type-checker for the SubC language.

Jump to

Keyboard shortcuts

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