2015-12-07 01:27:47 -05:00
# ssc
2015-12-07 01:56:54 -05:00
## Summary
2015-12-07 01:27:47 -05:00
2015-12-09 09:47:12 -05:00
_ssc_ is a basic, work-in-progress compiler for SunScript. It supports all of the byte-code functionality of Super Mario Sunshine's SPC interpreter.
The compiler compiles to the SPC binary format (.sb files) used by Super Mario Sunshine.
2015-12-07 01:27:47 -05:00
2015-12-09 09:47:12 -05:00
This program utilizes the [Grammatica ](http://grammatica.percederberg.net/ ) library to generate an LL(k) parser using a grammar syntax file.
2015-12-07 01:27:47 -05:00
2015-12-07 01:56:54 -05:00
## Usage
2015-12-07 01:27:47 -05:00
2015-12-09 09:47:12 -05:00
To use _ssc_ , create an instance of the `sunCompiler` class.
2015-12-18 19:52:38 -05:00
Use the `sunCompiler.Compile` method or any of its overloads to compile a script:
2015-12-07 01:27:47 -05:00
2015-12-09 09:47:12 -05:00
|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.|
|`resolver` |An instance of the import resolver to use. If not specified, `sunImportResolver.Default` will be used.|
2015-12-07 01:27:47 -05:00
2015-12-28 12:34:19 -05:00
_ssc_ by default resolves imports by loading files on disk (see [language.md ](language.md ) for more information).
2015-12-09 09:48:53 -05:00
To use a custom import resolver, create a new class inheriting from `sunImportResolver` and pass an instance of it to the `sunCompiler.Compile` method.
2015-12-07 01:27:47 -05:00
2015-12-09 09:47:12 -05:00
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:
2015-12-07 01:27:47 -05:00
2015-12-09 09:47:12 -05:00
|Property|Description|
|--------|-----------|
2015-12-28 12:34:19 -05:00
|`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` .|
2015-12-09 09:47:12 -05:00
|`CompileTime` |The time it took to compile, measured as a `TimeSpan` instance.|
2015-12-10 17:16:56 -05:00
|`DataCount` |The total number of data-table entries created.|
2015-12-09 09:47:12 -05:00
|`SymbolCount` |The total number of symbols (builtins, functions, and variables) created.|
|`BuiltinCount` |The total number of builtin symbols created.|
|`FunctionCount` |The total number of function symbols created.|
|`VariableCount` |The total number of global-scope variable symbols created.|
2015-12-07 01:27:47 -05:00
2015-12-13 00:57:21 -05:00
If the error is of the type `sunSourceException` , you can cast and retrieve the script name, line, and column of the error.
2015-12-07 01:27:47 -05:00
2015-12-12 18:04:49 -05:00
## Compiling
2015-12-28 12:34:19 -05:00
This repository contains a [premake5 ](https://premake.github.io/ ) [configuration file ](premake5.lua ).
2015-12-12 18:04:49 -05:00
The script generates a solution with the following projects:
- **ssc**, the base _ssc_ API library
2016-01-09 20:08:37 -05:00
- **frontend**, a basic command-line frontend
2015-12-30 22:29:02 -05:00
- **sbdump**, a tool which dumps disassembly and other information on compiled SPC binaries
2015-12-12 18:04:49 -05:00
Simply run the script through premake5 and build the resulting solution.
2016-02-02 01:38:04 -05:00
There are also compile-time options which are able to be configured via the premake5 command line:
2015-12-28 12:34:19 -05:00
|Option|Description|
|------|-----------|
2016-02-01 14:23:24 -05:00
|clean-symbols|Cleans symbol table of unused symbols.|
2015-12-12 18:04:49 -05:00
2015-12-12 18:13:27 -05:00
_**Note:** A Java runtime compatible with JDK 1.5 is required for generating the Grammatica parser classes during compilation.
2015-12-13 22:45:13 -05:00
For more information, see Grammatica's official [installation documentation ](http://grammatica.percederberg.net/doc/release/install.html )._
2015-12-12 18:13:27 -05:00
2015-12-09 09:47:12 -05:00
## Language
2015-12-07 01:27:47 -05:00
2015-12-12 18:13:27 -05:00
For more information on the SunScript language and its syntax, see [language.md ](language.md ).