Command Shell
Invoking and Terminating the Interpreter
The "pnuts" command invokes a Pnuts interpreter and executes the initialization script (/init.pnut). The greeting message shows the version of Pnuts, the JDK version, and JVM vendor's name.
C:\> pnuts
Copyright (c) 1997,1998 Sun Microsystems, Inc. All rights reserved.
Pnuts interpreter Version 1.0beta1, 1.1.7 (Sun Microsystems Inc.)
>
|
Input an expression after the prompt (>) then hit ENTER key.
The expression is evaluated and the result is shown.
exit() function terminates the command shell.
pnuts Command Options
C:\> pnuts { -e expression | -r resource | -f initfile | -m packageName | -v }* { fileName { arg1, ... }}
|
-e option evaluates the next argument.
C:\> pnuts -e readURL("http://java.sun.com/")
...
C:\>
|
-r option loads a resource file specified with the next argument, and
continues the interactive session.
C:\> pnuts -r examples/fact.pnut
Copyright (c) 1997,1998 Sun Microsystems, Inc. All rights reserved.
Pnuts interpreter Version 1.0beta1, 1.1.7 (Sun Microsystems Inc.)
>
|
-f option loads a local file specified with the next argument, and
continues the interactive session.
C:\> pnuts -f "$HOME/init.pnut"
Copyright (c) 1997,1998 Sun Microsystems, Inc. All rights reserved.
Pnuts interpreter Version 1.0beta2, 1.1.7 (Sun Microsystems Inc.)
>
|
-m option add a package to the use()'d package list of the initial context. Functions in the package can be accessed from the global package.
C:\> pnuts -m "my::module"
|
-v option sets verbose output mode. When an exception is thrown the stack trace is printed. Besides, a message is printed when a script file is loaded.
C:\> pnuts -v
Copyright (c) 1997,1998 Sun Microsystems, Inc. All rights reserved.
Pnuts interpreter Version 1.0beta1, 1.1.7 (Sun Microsystems Inc.)
> throw("hogehoge")
java.lang.RuntimeException: hogehoge
at java.lang.Throwable.(Compiled Code)
at pnuts.lang.PnutsFunction.call_builtin(Compiled Code)
at pnuts.lang.PnutsFunction.exec(Compiled Code)
at pnuts.lang.PnutsInterpreter._applicationNode(Compiled Code)
at pnuts.lang.SimpleNode.jjtAccept(Compiled Code)
at pnuts.lang.PnutsInterpreter._expressionList(Compiled Code)
...
...
|
If a fileName is specified in pnuts command, the file and the arguments that follows can be accessed with the global variable '$args'.
for (i = 0; i < $args.length; i++) println($args[i])
|
echo.pnut
C:\> pnuts echo.pnut 1 2 3
echo.pnut
1
2
3
|
Properties
property |
description |
pnuts.interactive |
If this property is not specified, when neither script files nor
expression (with -e) nor redirection are given, pnuts command runs
in interactive mode, which means that the prompt string and results are
displayed. The property pnuts.interactive allows to specify
explicitly that pnuts command runs in interactive or batch mode no
matter what is given in the command line.
|
pnuts.compiled.script.prefix |
If this property is set at start up time, when the function load()
is called with a parameter that does not end with the suffix '.pnut', Pnuts
interpreter tries to load a precompiled script as a Java class. The class
name is the script name that '/' is replaced by '.' after
the value of the property. For instance, a script name is
"lib/stream" and the property "pnuts.compiled.script.prefix"
is "pnuts.precompiled.", pnuts.precompiled.lib.stream class is loaded
if it exists. The pnuts command defines the property as
"pnuts.precompiled." by default..
|
pnuts.package.factory |
If this property is specified at start up time, the class becomes the default package factory.
|
pnuts.debugger |
When -d option is given to the pnuts command, a class name of the debugger can be specified to the 'pnuts.debugger' property. If the property value is "pnuts.tools.VisualDebugger", the graphical debugger is used instead of the terminal-style debugger.
|
Version Number
The value of pnuts_version variable is the version number of Pnuts.