| java.lang.Object org.jatha.compile.LispCompiler
LispCompiler | public class LispCompiler (Code) | | LispCompiler has a compile() method that will
compile a LISP expression and return the SECD code
for that expression.
Example LISP read/eval/print loop:
expr = parser.read(stream);
code = compiler.compile(expr);
result = machine.eval(code);
result.print();
Macro compilation contributed by Jean-Pierre Gaillardon, April 2005
See Also: org.jatha.machine.SECDMachine See Also: org.jatha.machine.SECDop author: Micheal S. Hewett hewett@cs.stanford.edu |
Method Summary | |
public void | Register(LispPrimitive primitive) Use this function to register any new LISP primitives
that you create from Java code. | public void | Register(LispPrimitive primitive, LispPackage pkg) Use this function to register any new LISP primitives
that you create from Java code. | public void | Register(LispPrimitive primitive, String pkgName) Use this function to register any new LISP primitives
that you create from Java code. | public void | WarnAboutSpecials(boolean value) | public LispValue | compile(SECDMachine machine, LispValue expr, LispValue varValues) compile takes a LISP expression, a list of
global variables, and optionally an already-generated
list of code. | public LispValue | compile(LispValue expr, LispValue valueList, LispValue code) compile takes a LISP expression, a list of
global variables, and optionally an already-generated
list of code. | LispValue | compileAnd(SECDMachine machine, LispValue args, LispValue valueList, LispValue code) | LispValue | compileAndAux(LispValue dummyVar, LispValue args) | LispValue | compileApp(SECDMachine machine, LispValue args, LispValue valueList, LispValue code) | LispValue | compileAppConstant(SECDMachine machine, LispValue args, LispValue valueList, LispValue code) | public LispValue | compileArgsLeftToRight(LispValue args, LispValue valueList, LispValue code) | LispValue | compileAtom(SECDMachine machine, LispValue expr, LispValue valueList, LispValue code) | LispValue | compileBuiltin(SECDMachine machine, LispValue fn, LispValue args, LispValue valueList, LispValue code) | public LispValue | compileConstantArgsLeftToRight(SECDMachine machine, LispValue args, LispValue valueList, LispValue code) | LispValue | compileDefmacro(SECDMachine machine, LispValue name, LispValue argsAndBody, LispValue valueList, LispValue code) | LispValue | compileDefun(SECDMachine machine, LispValue name, LispValue argsAndBody, LispValue valueList, LispValue code) | LispValue | compileIf(SECDMachine machine, LispValue test, LispValue thenExpr, LispValue elseExpr, LispValue valueList, LispValue code) | LispValue | compileLambda(SECDMachine machine, LispValue body, LispValue valueList, LispValue code) | public LispValue | compileLet(SECDMachine machine, LispValue vars, LispValue values, LispValue valueList, LispValue body, LispValue code) | LispValue | compileList(SECDMachine machine, LispValue expr, LispValue valueList, LispValue code) | LispValue | compileOptimizedIf(SECDMachine machine, LispValue test, LispValue thenExpr, LispValue elseExpr, LispValue valueList, LispValue code) | LispValue | compileOr(SECDMachine machine, LispValue args, LispValue valueList, LispValue code) | LispValue | compileOrAux(LispValue dummyVar, LispValue args) | LispValue | compileProgn(LispValue body, LispValue valueList, LispValue code) | LispValue | compileSpecialBind(SECDMachine machine, LispValue vars, LispValue values, LispValue valueList, LispValue code) | LispValue | compileSpecialForm(SECDMachine machine, LispValue function, LispValue args, LispValue valueList, LispValue code) | LispValue | compileSpecialUnbind(SECDMachine machine, LispValue vars, LispValue code) | LispValue | compileUserDefinedFunction(SECDMachine machine, LispValue fn, LispValue args, LispValue valueList, LispValue code) | public Stack | getLegalBlocks() | public Stack | getLegalTags() | public Map | getRegisteredDos() | public LispValue | indexAndAttribute(LispValue e, LispValue l) Looks up the symbol in a list of lists.
Returns a dotted pair.
- first element is the attribute of the found symbol
it can be "&rest" or NIL for no attribute (or if symbol has not been found)
- second element is the index of the list in which it is found and
the index in that list. | public int | indexInList(LispValue e, LispValue l, LispValue[] attribute) Looks up the symbol in a list
Parameters: e - a Symbol Parameters: l - a list Parameters: attribute - The attribute of the found symbol is assigned to attribute[0]. | public void | init() Initializes the compiler by registering
the LISP primitive functions so that the
compiler can recognize them. | public static boolean | isBuiltinFunction(LispValue code) Send in either code or a symbol with a function value.
Returns true only if the first element of the code list
is :PRIMITIVE.
Parameters: code - a LISP list. | public boolean | isLegalTag(LispValue tag) | public boolean | isMacroCode(LispValue code) | public LispValue | quoteList(LispValue l) Returns the input list with quotes added before every
top-level expression. | public boolean | specialFormP(LispValue fn) | public LispValue | valuesFromLetBindings(LispValue varValueList) | public LispValue | varsFromLetBindings(LispValue varValueList) |
DEBUG | static boolean DEBUG(Code) | | |
WarnAboutSpecialsP | boolean WarnAboutSpecialsP(Code) | | |
Register | public void Register(LispPrimitive primitive)(Code) | | Use this function to register any new LISP primitives
that you create from Java code. The compiler will
then recognize them and compile them appropriately.
Example:
compiler.Register(new RevAppendPrimitive());
See Also: LispPrimitive Parameters: primitive - |
Register | public void Register(LispPrimitive primitive, LispPackage pkg)(Code) | | Use this function to register any new LISP primitives
that you create from Java code. The compiler will
then recognize them and compile them appropriately.
This version of the constructor accepts a package in which
to intern the symbol.
Example:
compiler.Register(new RevAppendPrimitive());
See Also: LispPrimitive Parameters: primitive - |
Register | public void Register(LispPrimitive primitive, String pkgName)(Code) | | Use this function to register any new LISP primitives
that you create from Java code. The compiler will
then recognize them and compile them appropriately.
This version of the constructor accepts a package in which
to intern the symbol.
Example:
compiler.Register(new RevAppendPrimitive());
See Also: LispPrimitive Parameters: primitive - |
WarnAboutSpecials | public void WarnAboutSpecials(boolean value)(Code) | | |
compile | public LispValue compile(SECDMachine machine, LispValue expr, LispValue varValues) throws CompilerException(Code) | | compile takes a LISP expression, a list of
global variables, and optionally an already-generated
list of code. It returns compiled code in a list.
See Also: LispCompiler Parameters: expr - expression to compile Parameters: varValues - global or local variable list. LispValue - generated code |
compile | public LispValue compile(LispValue expr, LispValue valueList, LispValue code) throws CompilerException(Code) | | compile takes a LISP expression, a list of
global variables, and optionally an already-generated
list of code. It returns compiled code in a list.
See Also: LispCompiler Parameters: expr - expression to compile Parameters: valueList - global variable list. Parameters: code - [optional] LispValue - generated code |
getRegisteredDos | public Map getRegisteredDos()(Code) | | |
indexAndAttribute | public LispValue indexAndAttribute(LispValue e, LispValue l)(Code) | | Looks up the symbol in a list of lists.
Returns a dotted pair.
- first element is the attribute of the found symbol
it can be "&rest" or NIL for no attribute (or if symbol has not been found)
- second element is the index of the list in which it is found and
the index in that list. Both indexes start from 1. The &rest keyword eventually
present in the list is not taken into account for index count.
index is NIL if not found.
Examples:
indexAndAttribute(b, ((a b c) (d e f)) = (NIL. (1 . 2))
indexAndAttribute(f, ((a b c) (d e f)) = (NIL.(2 . 3))
indexAndAttribute(z, ((a b c) (d e f)) = (NIL. NIL)
indexAndAttribute(l, ((a &rest l) (d e f)) = (&rest .(1 . 2))
Parameters: e - a Symbol Parameters: l - a list of lists either (NIL.NIL), if not found, or a dotted pair; first is the attribute for symbol, second is a Cons of 2 LispIntegers\(a . b) indicating list number (a) and index into that list (b) |
indexInList | public int indexInList(LispValue e, LispValue l, LispValue[] attribute)(Code) | | Looks up the symbol in a list
Parameters: e - a Symbol Parameters: l - a list Parameters: attribute - The attribute of the found symbol is assigned to attribute[0]. It can be NIL or &rest the index in list of found symbol (it start from 1) or 0 if symbol has not been found in list |
isBuiltinFunction | public static boolean isBuiltinFunction(LispValue code)(Code) | | Send in either code or a symbol with a function value.
Returns true only if the first element of the code list
is :PRIMITIVE.
Parameters: code - a LISP list. true if the code indicates a built-in function |
isMacroCode | public boolean isMacroCode(LispValue code)(Code) | | Parameters: code - a Lisp list true if code is code for a macro (the first element is :MACRO) |
quoteList | public LispValue quoteList(LispValue l)(Code) | | Returns the input list with quotes added before every
top-level expression.
|
|
|