sisc.compiler
Class Compiler

java.lang.Object
  extended by sisc.util.Util
      extended by sisc.compiler.CompilerConstants
          extended by sisc.compiler.Compiler
All Implemented Interfaces:
Version

public class Compiler
extends CompilerConstants

Compiler - Compiles regularized Scheme s-expressions into an AST of SISC Expression objects. From v1.9 on, the Compiler expects analyzed s-expressions which have been annotated with various information about the code including free variables, lexically referenced variables, etc. The default compile() entrypoint will call the Analyzer implicitly unless instructed not to, so one may still pass fully-expanded but unanalyzed Scheme code. The format for the annotations may change in the future, but is currently: (program (referenced-var-list ...) (set-var-list ...) (free-var-list ...) ) TODO: Make output a valid Scheme program by moving #t into the body (#%lambda #t (lexically-referenced-vars ...) ) (#%letrec #t )


Field Summary
 
Fields inherited from class sisc.compiler.CompilerConstants
_IF, APPLICATION, BEGIN, DEFINE, LAMBDA, LETREC, MAKEANNOTATION, PROGRAM, QUOTE, REALTAIL, SET, SYNTACTIC_TOKEN_COUNT, SYNTACTIC_TOKENS, UNKNOWN
 
Fields inherited from class sisc.util.Util
BACKQUOTE, bundles, caseSensitive, EMPTYLIST, EMPTYVEC, EOF, ERRORK, EVAL, EXPSC, EXPTOP, FALSE, FCONT, FIVE, JEXCEPTION, LOCATION, maxFloatPrecision, MESSAGE, minFloatPrecision, NAME, OTHER, PARENT, permitInterrupts, QUOTESYM, REPORT, SETBANG, SISC, SISC_SPECIFIC, SISCB, SOURCE_COLUMN, SOURCE_FILE, SOURCE_LINE, SYMENV, THIS, TOPLEVEL, TRUE, UNQUOTE, UNQUOTE_SPLICING, VOID, ZV
 
Fields inherited from interface sisc.util.Version
VERSION
 
Constructor Summary
Compiler()
           
 
Method Summary
static void addSpecialForms(SymbolicEnvironment menv)
           
static Expression application(Interpreter r, Expression rator, Expression[] rands, int context, Pair annotation, SymbolicEnvironment env)
           
protected  Expression compile(Interpreter r, Expression v, Pair sets, sisc.compiler.Compiler.ReferenceFactory rf, int context, SymbolicEnvironment env, Pair an)
           
 Expression compile(Interpreter r, Expression v, SymbolicEnvironment env)
           
 Expression compileApp(Interpreter r, Pair expr, Pair sets, sisc.compiler.Compiler.ReferenceFactory rf, int context, SymbolicEnvironment env, Pair an)
           
 Expression compileLetrec(Interpreter r, Symbol[] formals, Symbol[] lexicals, Expression[] rands, Expression body, Pair sets, sisc.compiler.Compiler.ReferenceFactory rf, SymbolicEnvironment env, int context)
           
 int[] findBoxes(Symbol[] formals, Pair sets)
           
static int getExpType(SymbolicEnvironment env, Value s)
           
static void main(java.lang.String[] args)
           
static Expression makeFillRib(Interpreter r, Expression lastRand, Expression rand, int pos, Expression nxp, boolean immediate)
           
protected  int[][] resolveCopies(sisc.compiler.Compiler.ReferenceFactory rf, Symbol[] lexicals)
           
 
Methods inherited from class sisc.util.Util
annotated, annotatedAppEval, append, argCheck, argsToSymbols, assq, bininport, bininstream, binoutport, binoutstream, box, character, charinport, charinreader, charoutport, charoutwriter, charsetFromString, chr, cont, currentClassLoader, env, error, error, error, error, error, error, error, expr, getDefaultCharacterSet, immutablePair, immutableVector, inport, javaExceptionToString, javaWrap, justify, length, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, list, list, list, list, list, makeURL, mapcar, memq, nlib, num, outport, pair, pairToExpressions, pairToExpVect, pairToValues, proc, read, registerBundle, reverse, reverseInPlace, simpleErrorToString, sourceAnnotations, str, string, sym, symbol, symval, truePair, truth, truth, typeError, typeError, updateName, url, url, url, valArrayToList, valArrayToList, valArrayToVec, vec, warn, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Compiler

public Compiler()
Method Detail

addSpecialForms

public static void addSpecialForms(SymbolicEnvironment menv)

compile

protected Expression compile(Interpreter r,
                             Expression v,
                             Pair sets,
                             sisc.compiler.Compiler.ReferenceFactory rf,
                             int context,
                             SymbolicEnvironment env,
                             Pair an)
                      throws ContinuationException
Throws:
ContinuationException

compile

public Expression compile(Interpreter r,
                          Expression v,
                          SymbolicEnvironment env)
                   throws ContinuationException
Throws:
ContinuationException

getExpType

public static final int getExpType(SymbolicEnvironment env,
                                   Value s)

resolveCopies

protected int[][] resolveCopies(sisc.compiler.Compiler.ReferenceFactory rf,
                                Symbol[] lexicals)

findBoxes

public int[] findBoxes(Symbol[] formals,
                       Pair sets)

compileApp

public Expression compileApp(Interpreter r,
                             Pair expr,
                             Pair sets,
                             sisc.compiler.Compiler.ReferenceFactory rf,
                             int context,
                             SymbolicEnvironment env,
                             Pair an)
                      throws ContinuationException
Throws:
ContinuationException

makeFillRib

public static final Expression makeFillRib(Interpreter r,
                                           Expression lastRand,
                                           Expression rand,
                                           int pos,
                                           Expression nxp,
                                           boolean immediate)

compileLetrec

public Expression compileLetrec(Interpreter r,
                                Symbol[] formals,
                                Symbol[] lexicals,
                                Expression[] rands,
                                Expression body,
                                Pair sets,
                                sisc.compiler.Compiler.ReferenceFactory rf,
                                SymbolicEnvironment env,
                                int context)
                         throws ContinuationException
Throws:
ContinuationException

application

public static final Expression application(Interpreter r,
                                           Expression rator,
                                           Expression[] rands,
                                           int context,
                                           Pair annotation,
                                           SymbolicEnvironment env)
                                    throws ContinuationException
Throws:
ContinuationException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception