java.lang.Object
coneforest.psylla.runtime.Interpreter
- All Implemented Interfaces:
PsyContext
,PsyObject
,Runnable
The Psylla language interpreter.
-
Field Summary
Fields 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_YIELD
Fields inherited from interface coneforest.psylla.core.PsyObject
PSY_CLONE, PSY_EQ, PSY_HASHCODE, PSY_INSTANCEOF, PSY_NE, PSY_TOSTRING, PSY_TOSTRINGBUFFER, PSY_TYPE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the interpreter’s class loader.Returns the current dictionary (the topmost on the dictionary stack).Returns the current namespace.Returns the dictionary stack.int
Returns the size of the execution stack.Returns the execution stack.void
fork()
long
getId()
boolean
Returns the value of the stopped flag.void
handleExecutionStack
(int level) void
Interprets the Psylla code from thereader
object.void
void
void
interpretBraced
(PsyReader oReader) void
join()
void
join
(long millis) boolean
loadLibraryResource
(String resourceName) boolean
Returns the namespace pool.Returns the operand stack.operandStackBacked
(int count) prompt()
Returns the REPL prompt.<T extends PsyObject>
TpsyLoad
(PsyTextual oKey) void
psyRequire
(PsyTextual oResourceName) void
quit()
void
repl()
void
run()
void
setClassPath
(String[] classPath) void
setEnvironment
(Map<String, String> env) void
setErrorWriter
(Writer writer) Sets the interpreter’s standard error writer.void
setLibraryPath
(String[] libraryPath) void
setRandomSeed
(Long randomSeed) Reseeds the interpreter’s standard pseudorandom generator, using the given seed.void
Sets the interpreter’s standard reader.void
setScriptName
(String scriptName) void
setShellArguments
(String[] args) void
setStopped
(boolean stopped) Sets the stopped flag to the specified value.void
Sets the interpreter’s standard writer.void
void
start()
void
stop()
Returns the system dictionary.userDict()
Returns the user dictionary.Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface coneforest.psylla.core.PsyContext
psyCurrentContext, psyWhere, toSyntaxString
Methods inherited from interface coneforest.psylla.core.PsyObject
convert, execute, invoke, psyClone, psyEq, psyHashCode, psyInstanceOf, psyNe, psySyntax, psyToString, psyToStringBuffer, psyType, typeName
-
Constructor Details
-
Interpreter
public Interpreter()Creates a new Psylla language interpreter.
-
-
Method Details
-
fork
- Specified by:
fork
in interfacePsyContext
- Throws:
PsyStackUnderflowException
PsyUnmatchedMarkException
-
operandStack
Description copied from interface:PsyContext
Returns the operand stack.- Specified by:
operandStack
in interfacePsyContext
- Returns:
- the operand stack
-
operandStackBacked
- Specified by:
operandStackBacked
in interfacePsyContext
- Throws:
PsyStackUnderflowException
-
dictStack
Description copied from interface:PsyContext
Returns the dictionary stack.- Specified by:
dictStack
in interfacePsyContext
- Returns:
- the dictionary stack
-
executionStack
Description copied from interface:PsyContext
Returns the execution stack.- Specified by:
executionStack
in interfacePsyContext
- Returns:
- the execution stack
-
classLoader
Returns the interpreter’s class loader.- Returns:
- the interpreter’s class loader
-
psyLoad
- Specified by:
psyLoad
in interfacePsyContext
- Throws:
PsyUndefinedException
-
handleExecutionStack
public void handleExecutionStack(int level) - Specified by:
handleExecutionStack
in interfacePsyContext
-
currentDict
Description copied from interface:PsyContext
Returns the current dictionary (the topmost on the dictionary stack).- Specified by:
currentDict
in interfacePsyContext
- Returns:
- the current dictionary (the topmost on the dictionary stack)
-
systemDict
Description copied from interface:PsyContext
Returns the system dictionary.- Specified by:
systemDict
in interfacePsyContext
- Returns:
- the system dictionary
-
userDict
Description copied from interface:PsyContext
Returns the user dictionary.- Specified by:
userDict
in interfacePsyContext
- Returns:
- the user dictionary
-
namespacePool
Description copied from interface:PsyContext
Returns the namespace pool.- Specified by:
namespacePool
in 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
Reseeds the interpreter’s standard pseudorandom generator, using the given seed.- Parameters:
randomSeed
- the seed.- Throws:
PsyUndefinedException
- when TODO
-
setClassPath
public void setClassPath(String[] classPath) throws PsyLimitCheckException, PsyRangeCheckException, PsyUndefinedException -
setLibraryPath
public void setLibraryPath(String[] libraryPath) throws PsyLimitCheckException, PsyRangeCheckException, PsyUndefinedException -
interpret
-
interpret
-
interpret
Description copied from interface:PsyContext
Interprets the Psylla code from thereader
object.- Specified by:
interpret
in interfacePsyContext
- Parameters:
oReader
- thereader
object.
-
interpretBraced
- Specified by:
interpretBraced
in interfacePsyContext
- Throws:
PsyLimitCheckException
-
errorDict
- Throws:
PsyUndefinedException
-
showStacks
public void showStacks()- Specified by:
showStacks
in interfacePsyContext
-
execLevel
public int execLevel()Description copied from interface:PsyContext
Returns the size of the execution stack.- Specified by:
execLevel
in interfacePsyContext
- Returns:
- the size of the execution stack
-
getStopped
public boolean getStopped()Description copied from interface:PsyContext
Returns the value of the stopped flag.- Specified by:
getStopped
in interfacePsyContext
- Returns:
- the value of the stopped flag
-
setStopped
public void setStopped(boolean stopped) Description copied from interface:PsyContext
Sets the stopped flag to the specified value.- Specified by:
setStopped
in interfacePsyContext
- Parameters:
stopped
- the value of the stopped flag.
-
setScriptName
-
setShellArguments
-
setEnvironment
-
quit
public void quit()- Specified by:
quit
in interfacePsyContext
-
repl
- Specified by:
repl
in interfacePsyContext
- Throws:
PsyIOErrorException
-
prompt
Returns the REPL prompt.- Returns:
- the REPL prompt
-
start
public void start() -
run
public void run() -
join
- Specified by:
join
in interfacePsyContext
- Throws:
InterruptedException
-
join
- Throws:
InterruptedException
-
getId
public long getId()- Specified by:
getId
in interfacePsyContext
-
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:
psyRequire
in interfacePsyContext
- Throws:
PsyFileAccessDeniedException
PsyFileNotFoundException
PsyIOErrorException
PsySecurityErrorException
PsyUndefinedException
PsyErrorException
-