A compiler API for the SunScript language. Forked from https://github.com/JoshuaMKW/ssc
Find a file
arookas 909a5bbf38 Moved image to top
Also reworded the extensions paragraph.
2016-02-22 19:05:24 -05:00
frontend Added full data/symbol table information to results 2016-02-13 18:32:53 -05:00
lib Removed arookas library files 2016-02-12 22:40:06 -05:00
sbdump Updated arookas library 2016-02-12 22:53:18 -05:00
ssc Force parentheses for conditional statements 2016-02-22 16:35:03 -05:00
stdlib Added remaining builtins 2016-02-19 14:14:50 -05:00
.gitignore Removed testing shit 2016-02-19 14:05:39 -05:00
extensions.md Fixed: typo 2016-02-13 23:02:16 -05:00
language.md Fixed: another minor typo 2016-02-16 04:35:52 -05:00
premake5.lua Minor cleanup 2016-02-19 14:04:40 -05:00
readme.md Moved image to top 2016-02-22 19:05:24 -05:00
sunscript.sublime-syntax Added ST3 syntax definition 2016-02-22 16:35:47 -05:00

ssc

SunScript ST3 syntax preview

Summary

ssc is a work-in-progress compiler for SunScript. It supports all of the byte-code functionality of Super Mario Sunshine's SPC interpreter. The compiler can compile to the SPC binary format (.sb files) used by Super Mario Sunshine, allowing for completely new and custom scripts.

This program utilizes the Grammatica library to generate an LL(k) parser using a grammar syntax file.

Usage

To use ssc, create an instance of the sunCompiler class. Use the sunCompiler.Compile method or any of its overloads to compile a script:

Parameter Description
name The name of the main script to compile. This is passed to the import resolver.
output The output stream into which the compiled binary file will be written.
binary The custom binary formatter to use for output. If not specified, the default SPC binary format will be used.
resolver An instance of the import resolver to use. If not specified, sunImportResolver.Default will be used.

ssc by default resolves imports by loading files on disk (see language.md for more information). To use a custom import resolver, create a new class inheriting from sunImportResolver and pass an instance of it to the sunCompiler.Compile method.

The result of compilation will be returned in a sunCompilerResults instance. Use the various properties on this type to gather the information of the compilation:

Property Description
Success Whether the script was compiled successfully. If not, the Error property will be non-null.
Error The fatal error which occured during compilation. If compilation was successful, this will be null.
CompileTime The time it took to compile, measured as a TimeSpan instance.
Data An array containing the data-table entries.
Symbols An array containing the symbol-table entries.

If the error is of the type sunSourceException, you can cast and retrieve the script name, line, and column of the error.

Compiling

Dependencies

There are several dependencies when building ssc. All dependencies must be placed in the lib-dir folder (see below), unless stated otherwise.

Dependency Notes
arookas library Preferably, the library should be built in the same configuration as ssc (e.g. debug, release).
Grammatica 1.6 Already included in the repository.

Note: A Java runtime compatible with JDK 1.5 is required for generating the Grammatica parser classes during compilation. For more information, see Grammatica's official installation documentation.

premake

This repository contains a premake5 configuration file. The script generates a solution with the following projects:

  • ssc, the base ssc API library
  • frontend, a basic command-line frontend
  • sbdump, a tool which dumps disassembly and other information on compiled SPC binaries

After setting up the dependencies, simply run the script through premake5 and build the resulting solution. There are also options which are able to be configured via the premake5 command line:

Option Description
lib-dir Sets the path to the dependencies. Defaults to the lib/ folder.
clean-functions Compiles only used functions.
clean-symbols Cleans symbol table of unused symbols.

Language

For more information on the SunScript language and its syntax, see language.md.

Extending the compiler

ssc is designed to be extensible, allowing for custom output formats and import resolvers. For more information on extending ssc, see extensions.md.