java.lang.Object
java.lang.Thread
coneforest.psylla.runtime.Interpreter
- All Implemented Interfaces:
PsyContext,PsyObject,Runnable
The Psylla language interpreter.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITYFields inherited from interface coneforest.psylla.core.PsyContext
PSY_BEGIN, PSY_CLEARDICTSTACK, PSY_CLEARSTACK, PSY_CLEARTOMARK, PSY_COPY, PSY_COUNTDICTSTACK, PSY_COUNTEXECSTACK, PSY_COUNTSTACK, PSY_COUNTTOMARK, PSY_CURRENTCONTEXT, PSY_CURRENTDICT, PSY_DEF, PSY_DICTSTACK, PSY_DUP, PSY_EDITLINE, PSY_END, PSY_EXCH, PSY_EXEC, PSY_EXECSTACK, PSY_EXECUTIVE, PSY_EXIT, PSY_FOR, PSY_FORK, PSY_HALT, PSY_IF, PSY_IFELSE, PSY_INDEX, PSY_JOIN, PSY_LOAD, PSY_LOOP, PSY_NAMESPACE, PSY_POP, PSY_PRETTYPRINT, PSY_PRINT, PSY_QUIT, PSY_REPEAT, PSY_REQUIRE, PSY_ROLL, PSY_SAY, PSY_SLEEP, PSY_STACK, PSY_STOP, PSY_STOPPED, PSY_STORE, PSY_TOKENS, PSY_WARN, PSY_WHERE, PSY_YIELDFields inherited from interface coneforest.psylla.core.PsyObject
PSY_CLONE, PSY_EQ, PSY_HASHCODE, PSY_INSTANCEOF, PSY_NE, PSY_TONAME, PSY_TOSTRING, PSY_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbanner()Returns the Psylla banner.Returns the interpreter’s class loader.Returns the current dictionary (the topmost on the dictionary stack).intReturns the topmost execution level at the loop stack or-1if the loop stack is empty.Returns the current namespace.intReturns the topmost execution level at the stop stack or-1if the stop stack is empty.Returns the dictionary stack.intReturns the size of the execution stack.Returns the execution stack.voidfork()booleanGets the stopped flag to the specified value.voidhandleExecutionStack(int level) voidvoidvoidvoidinterpretBraced(PsyReader oReader) <T extends PsyObject>
TbooleanloadLibraryResource(String resourceName) booleanReturns the namespace pool.Returns the operand stack.operandStackBacked(int count) intRemoves the execution level from the loop stack and returns this level or-1if the loop stack is empty.intRemoves the execution level from the stop stack and returns this level or-1if the stop stack is empty.prompt()Returns the REPL prompt.<T extends PsyObject>
TpsyLoad(PsyTextual oKey) voidpsyRequire(PsyTextual oResourceName) intPushes the current execution level onto the loop stack and returns this level.intPushes the current execution level onto the stop stack and returns this level.voidquit()voidrepl()voidsetClassPath(String[] classPath) voidsetEnvironment(Map<String, String> env) voidsetErrorWriter(Writer writer) Sets the interpreter’s standard error writer.voidsetLibraryPath(String[] libraryPath) voidsetRandomSeed(Long randomSeed) voidSets the interpreter’s standard reader.voidsetScriptName(String scriptName) voidsetShellArguments(String[] args) voidsetStopped(boolean stopped) Sets the stopped flag to the specified value.voidSets the interpreter’s standard writer.voidvoidstop_()Returns the system dictionary.userDict()Returns the user dictionary.Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yieldMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface coneforest.psylla.core.PsyContext
getId, join, psyWhere, toSyntaxStringMethods inherited from interface coneforest.psylla.core.PsyObject
convert, execute, invoke, psyClone, psyEq, psyHashCode, psyInstanceOf, psyNe, psySyntax, psyToName, psyToString, psyType, typeName
-
Constructor Details
-
Interpreter
public Interpreter()Creates a new Psylla language interpreter.
-
-
Method Details
-
fork
- Specified by:
forkin interfacePsyContext- Throws:
PsyStackUnderflowExceptionPsyUnmatchedMarkException
-
operandStack
Description copied from interface:PsyContextReturns the operand stack.- Specified by:
operandStackin interfacePsyContext- Returns:
- the operand stack.
-
operandStackBacked
- Specified by:
operandStackBackedin interfacePsyContext- Throws:
PsyStackUnderflowException
-
dictStack
Description copied from interface:PsyContextReturns the dictionary stack.- Specified by:
dictStackin interfacePsyContext- Returns:
- the dictionary stack.
-
executionStack
Description copied from interface:PsyContextReturns the execution stack.- Specified by:
executionStackin interfacePsyContext- Returns:
- the execution stack.
-
classLoader
Returns the interpreter’s class loader.- Returns:
- the interpreter’s class loader.
-
load
- Throws:
PsyUndefinedException
-
psyLoad
- Specified by:
psyLoadin interfacePsyContext- Throws:
PsyUndefinedException
-
handleExecutionStack
public void handleExecutionStack(int level) - Specified by:
handleExecutionStackin interfacePsyContext
-
currentDict
Description copied from interface:PsyContextReturns the current dictionary (the topmost on the dictionary stack).- Specified by:
currentDictin interfacePsyContext- Returns:
- the current dictionary.
-
systemDict
Description copied from interface:PsyContextReturns the system dictionary.- Specified by:
systemDictin interfacePsyContext- Returns:
- the system dictionary.
-
userDict
Description copied from interface:PsyContextReturns the user dictionary.- Specified by:
userDictin interfacePsyContext- Returns:
- the user dictionary.
-
namespacePool
Description copied from interface:PsyContextReturns the namespace pool.- Specified by:
namespacePoolin interfacePsyContext- Returns:
- the namespace pool.
-
currentNamespace
Returns the current namespace.- Returns:
- the current namespace.
-
setReader
Sets the interpreter’s standard reader.- Parameters:
reader- the reader.
-
setWriter
Sets the interpreter’s standard writer.- Parameters:
writer- the writer.
-
setErrorWriter
Sets the interpreter’s standard error writer.- Parameters:
writer- the error writer.
-
setRandomSeed
- Throws:
PsyUndefinedException
-
setClassPath
public void setClassPath(String[] classPath) throws PsyLimitCheckException, PsyRangeCheckException, PsyUndefinedException -
setLibraryPath
public void setLibraryPath(String[] libraryPath) throws PsyLimitCheckException, PsyRangeCheckException, PsyUndefinedException -
interpret
-
interpret
-
interpret
- Specified by:
interpretin interfacePsyContext
-
interpretBraced
- Specified by:
interpretBracedin interfacePsyContext- Throws:
PsyLimitCheckException
-
errorDict
- Throws:
PsyUndefinedException
-
showStacks
public void showStacks() -
execLevel
public int execLevel()Description copied from interface:PsyContextReturns the size of the execution stack.- Specified by:
execLevelin interfacePsyContext- Returns:
- the size of the execution stack.
-
getStopped
public boolean getStopped()Description copied from interface:PsyContextGets the stopped flag to the specified value.- Specified by:
getStoppedin interfacePsyContext- Returns:
- the value of the stopped flag.
-
setStopped
public void setStopped(boolean stopped) Description copied from interface:PsyContextSets the stopped flag to the specified value.- Specified by:
setStoppedin interfacePsyContext- Parameters:
stopped- the value of the stopped flag.
-
pushLoopLevel
public int pushLoopLevel()Description copied from interface:PsyContextPushes the current execution level onto the loop stack and returns this level.- Specified by:
pushLoopLevelin interfacePsyContext- Returns:
- the current execution level.
-
popLoopLevel
public int popLoopLevel()Description copied from interface:PsyContextRemoves the execution level from the loop stack and returns this level or-1if the loop stack is empty.- Specified by:
popLoopLevelin interfacePsyContext- Returns:
- the execution level on the top of the loop stack or
-1if the loop stack is empty.
-
currentLoopLevel
public int currentLoopLevel()Description copied from interface:PsyContextReturns the topmost execution level at the loop stack or-1if the loop stack is empty.- Specified by:
currentLoopLevelin interfacePsyContext- Returns:
- the topmost execution level at the loop stack or
-1if the loop stack is empty.
-
pushStopLevel
public int pushStopLevel()Description copied from interface:PsyContextPushes the current execution level onto the stop stack and returns this level.- Specified by:
pushStopLevelin interfacePsyContext- Returns:
- the current execution level.
-
popStopLevel
public int popStopLevel()Description copied from interface:PsyContextRemoves the execution level from the stop stack and returns this level or-1if the stop stack is empty.- Specified by:
popStopLevelin interfacePsyContext- Returns:
- the execution level on the top of the stop stack or
-1if the stop stack is empty.
-
currentStopLevel
public int currentStopLevel()Description copied from interface:PsyContextReturns the topmost execution level at the stop stack or-1if the stop stack is empty.- Specified by:
currentStopLevelin interfacePsyContext- Returns:
- the topmost execution level at the stop stack or
-1if the stop stack is empty.
-
setScriptName
-
setShellArguments
-
setEnvironment
-
quit
public void quit()- Specified by:
quitin interfacePsyContext
-
repl
- Specified by:
replin interfacePsyContext- Throws:
PsyIOErrorException
-
banner
Returns the Psylla banner.- Returns:
- the banner.
-
prompt
Returns the REPL prompt.- Returns:
- the REPL prompt.
-
stop_
public void stop_()- Specified by:
stop_in interfacePsyContext
-
loadLibraryResource
public boolean loadLibraryResource(String resourceName) throws PsyFileAccessDeniedException, PsyFileNotFoundException, PsyIOErrorException, PsySecurityErrorException, PsyUndefinedException, PsyErrorException -
loadType
-
psyRequire
public void psyRequire(PsyTextual oResourceName) throws PsyFileAccessDeniedException, PsyFileNotFoundException, PsyIOErrorException, PsySecurityErrorException, PsyUndefinedException, PsyErrorException - Specified by:
psyRequirein interfacePsyContext- Throws:
PsyFileAccessDeniedExceptionPsyFileNotFoundExceptionPsyIOErrorExceptionPsySecurityErrorExceptionPsyUndefinedExceptionPsyErrorException
-