Command Shell

Invoking and Terminating the Interpreter

C:\> pnuts

"pnuts" command invoke a Pnuts interpreter and load 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.)
> 
> expression
result

Input an expression after the prompt (>) then hit ENTER key. The expression is evaluated and the result is shown.

> 1 + 2
3
> exit()

exit() function terminates the command shell.

pnuts Command Options

C:\> pnuts [ fileName | -e expression | -r resource | -v ]*

-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.

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.)
> 

-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)
	...
	...

On Unix platform, a command scripts can be written as follows.

#!/bin/sh
pnuts <<!
  /*
   * any Pnuts program here
   */
!

Properties

property description
pnuts.loadpath The initial value of pnuts_load_path
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.

Version Number

The value of pnuts_version variable is the version number of Pnuts.


Back