SHELL.ICN

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
ENVIRONMENT VARIABLES
SCRIPTS
EXAMPLES
PORTABILITY
SEE ALSO
BUGS AND LIMITATIONS
AUTHOR

NAME

shell.icn − Launch tasks that collaborate via co-expression switching.

SYNOPSIS

shell [ options ] [ arguments ]

DESCRIPTION

shell.icn is a proof-of-concept implementation of a shell that facilitates composition of new solutions from Unicon tasks. A solution may be an assembly of tasks into a simple linear pipeline or into a more complicated network. These tasks are previously translated Unicon programs that the shell loads into its own virtual machine (and process) via the Load( ) function as originally described in [Jeffery 1997].

shell.icn can execute a "script" that defines a new solution without invoking the Unicon translator; it can read a script from a file or the standard input. To prevent occurrence of "infinite loops of failure", shell.icn sets up one "proxy" co-expression per task to monitor the execution of the task’s co-expression and to intervene if necessary.

Compatible tasks are ordinary Unicon programs in every way except that they may use the Get( ) and Put( ) methods from the Stream.icn( 3 ) interface to transfer control of execution to other tasks in the solution and to ensure that producer tasks will transmit the same result sequences to the consumer tasks regardless of whether the producer or the consumer is activated first.

For an extended introduction to shell.icn and ideas about how to apply it, please see [Eschenlauer, 2006].

OPTIONS

The following options are recognized by shell.icn:

−i script

Read script from file script instead of the standard input. You may wish to use ".shell" as the extension of script file names.

−p prog

(Option −p overrides option −i) Invoke prog as preprocessor, passing arguments to it; prog will be invoked with a task that is a recursive instance of shell.icn as the first argument and a list for enqueueing results as the second argument; any arguments appearing afterward will be passed through to prog as arguments 3:0 (see ush.icn( 1 ) for an example)

−r list

Use list specified by list for a result list instead of creating a new one; this option cannot be used from the command line because the argument must be of type list rather than type string.

−s path

Search directory specified by path for icode and script files. This option may be repeated; alternatively, several directories may be specified by enclosing path in double quotes and separating directory names with spaces (as is done for IPATH and LPATH). If a directory name contains a space, you must both enclose path in double quotes and enclose space-containing directory names in single quotes, (e.g., −s "’/path to/one folder’ ../another_folder" ). Directories specified with the −s option are searched after the working directory and before directories specified by the USHPATH environment variable.

−t

Trace co-expression activation, process setup, etc., by shell.icn

ENVIRONMENT VARIABLES

USHPATH

Space−separated directory names searched after those specified with the −s option. Enclose spaces in directory names in single quotes. USHPATH must not contain double quotes.

SCRIPTS

Grammar of Scripts

The parser built into shell.icn expects the lines in shell files to conform to the following grammar:

input_file_line         ::= task_declaration |
                            list_symbol_declaration |
                            task_activation |
                            comment

task_declaration        ::= lvalue ":=" <program_name> arguments

list_symbol_declaration ::= "list" lvalues

task_activation         ::= "@" lvalues

comment                 ::= "#" many(<&cset>)

arguments               ::= arguments argument | argument | <nothing>

argument                ::= lvalue | "$" many(<&digits>) | alphanum

lvalues                 ::= lvalues lvalue | lvalue

lvalue                  ::= alphanum

alphanum                ::= many(<&letters> ++ <&digits>)

many(c)                 ::= c many(c) | c

Additional Script Rules

Names of programs that are not in the current working directory must include relative or absolute path information suitable for the platform; the program name supplied is passed directly to the load( ) function.

List symbols must be declared before they are used.

Task declarations may include forward references to other tasks.

Task activations must be deferred until all referenced tasks have been declared. The convert_tasks( ) procedure loads the tasks, wraps them with a monitoring co-expression (which is created by via the monitor_task( ) procedure), and activates them.

Once a task has terminated, it must be redeclared before it can be reactivated. Once one task has been redeclared, all must be redeclared before they are activated. List symbols need not be redeclared, however, but the lists that they represent are replaced with empty lists when convert_tasks( ) is executed.

If desired, string−valued arguments in scripts may be quoted in any way permitted by the balq(s) procedure (from the scan.icn file in the Icon Program Library), where balq(s) is invoked with a single argument.

EXAMPLES

The following script loads a consumer task and a producer task and activates the producer first, then it repeats this excepting that it activates the consumer first. Notice that arguments of the tasks invoked can be either co-expressions or strings.

    CONS   := consumer  PROD −
    PROD   := producer  CONS
    @ PROD
    CONS   := consumer  PROD −
    PROD   := producer  CONS
    @ CONS

In this script, "consumer" and "producer" are the name of icode files, "CONS" and "PROD" are symbols for the tasks created when the respective icode files are loaded, and "−" is a string. The consumer task is loaded and invoked with two arguments, the producer task and the string "−", and the producer task is loaded and invoked with one argument, the consumer task.

Suppose shell.icn is translated and on your PATH, and that consumer.icn and producer.icn have been translated and the icode files are in

    c:\My Documents\shelltest

and that a script file named test.shell containing the script above is also in that directory. Then you may either invoke the script with the command

    shell -s "’c:\My Documents\shelltest’" -i test.shell

or you may set USHPATH to

    ’c:\My Documents\shelltest’

and invoke the script with the command

    shell -i test.shell

PORTABILITY

shell.icn depends on Stream.icn( 3 ) which in turn depends on classes. Thus, shell.icn is compatible with Unicon but not Icon since Icon does not support classes. shell.icn is not Idol-compatible because Stream.icn is not Idol-compatible.

SEE ALSO

Eschenlauer, Arthur C., 2006. "A Unicon Shell", The Generator, Vol. 2, No. 2, pp 3-32.

  http://www.unicon.org/generator/v2n2.pdf

Jeffery, Clinton L., 1997. The MT Icon Interpreter. (Icon Project Document 169).

  http://www.cs.arizona.edu/icon/docs/ipd169.htm

Stream.icn( 3 )

BUGS AND LIMITATIONS

Infinite loops in tasks will prevent control being returned to shell.icn

At present, the parser for scripts is "built into" shell.icn. Specification of external parsing tasks has not yet been implemented. Thus, there is not yet an opportunity to use scripts with alternative grammars or in formats such as XML.

AUTHOR

Art Eschenlauer

shell.icn is in the public domain. The freedom of its content is protected by the Lesser GNU public license, version 2.1, February 1999,

  http://www.gnu.org/licenses/lgpl.html

which means you are granted permission to use this in any way that does not limit others’ freedom to use it.