This module contains a strategies for workin on the XTC universe. This includes composing components, passing databetween components, and basic file handling.
The XTC model is based around Unix pipes and ATerm storedas (temporary) files on disk. Each XT component is a an executable program, which reads an ATerm as input(either from stdin or from a file), processes it, and thenwrites the result to another file (or stdout).
The lowlevel details of creating temporary files, openingpipes, and executing components have been hidden behind thestrategies found in this module. You will find many examplesof wrapper strategies, which perform bookkeeping of temporaryfiles, opened file descriptors, and similar, to ensure thatthese are removed and freed upon program termination.
Strategy summary
|
check-options(Strategy deps)
|
n/a
|
Proc.str
|
xtc-check-dependencies
|
Succeeds if all necessary components for the running program are available, and the user has specified --check
|
Proc.str
|
xtc-ensure-file
|
Succeeds if the input term is a FILE
|
Proc.str
|
xtc-ensure-file
|
Succeeds if the input term is stdin, and it can be successfully copied to a FILE
|
Proc.str
|
xtc-exit
|
Clean up temporary files and exit program
|
Proc.str
|
xtc-find-file
|
Searches for an XT component, by name
|
Proc.str
|
xtc-input(Strategy s)
|
n/a
|
Proc.str
|
xtc-input-wrap(Strategy s)
|
Option parsing wrapper for XTC programs that only read data
|
Proc.str
|
xtc-input-wrap(Strategy extra-options, Strategy s)
|
Option parsing wrapper for XTC programs that only read data
|
Proc.str
|
xtc-io(Strategy s)
|
n/a
|
Proc.str
|
xtc-io-exit
|
n/a
|
Proc.str
|
xtc-io-wrap(Strategy s)
|
n/a
|
Proc.str
|
xtc-io-wrap(Strategy extra-opts, Strategy s)
|
n/a
|
Proc.str
|
xtc-io-wrap(Strategy extra-opts, Strategy deps, Strategy s)
|
n/a
|
Proc.str
|
xtc-io-wrap(Strategy extra-opts, Strategy usage, Strategy about, Strategy deps, Strategy s)
|
n/a
|
Proc.str
|
xtc-iowrap(Strategy s)
|
n/a
|
Proc.str
|
xtc-iowrap(Strategy extra-opts, Strategy s)
|
n/a
|
Proc.str
|
xtc-output(Strategy s)
|
Applies the strategy s to the current term, then writes the result to output
|
Proc.str
|
xtc-output-wrap(Strategy s)
|
Option parsing wrapper for XTC programs that only generate data
|
Proc.str
|
xtc-output-wrap(Strategy extra-options, Strategy s)
|
Option parsing wrapper for XTC programs that only generate data
|
Proc.str
|
xtc-remove-temporaries
|
n/a
|
Proc.str
|
xtc-temp-files(Strategy s)
|
Wrapper strategy that automatically cleans all temporary files created by s
|
Proc.str
|
xtc-write-output
|
Writes a FILE to the output of this component
|
Proc.str
|
xtc-write-output
|
n/a
|
Proc.str
|
Strategy details
|
ATerm
|
xtc-check-dependencies
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Succeeds if all necessary components for the running programare available, and the user has specified --check. The check-options strategy must have been added to the command lineoptions of the running program, see check-options for details. Additionally, xtc-check-dependencies will only run if the userspecified --check on the command line when invoking the program.
|
|
ATerm
|
xtc-ensure-file
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Succeeds if the input term is a FILE
|
|
ATerm
|
xtc-ensure-file
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Succeeds if the input term is stdin, and it can be successfullycopied to a FILE.
|
|
ATerm
|
xtc-exit
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Clean up temporary files and exit program. In normal operation,XT components create temporary files, which should be cleanedup on program exit. Calling this strategy instead of<tt>exit</tt> ensures that no files are left behind.
|
|
ATerm
|
xtc-find-file
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Searches for an XT component, by name. The input to thisstrategy is the name of the component, as registered inthe XTC registry. If found, a FILE representing its location (path) is returned.
type
|
String -> FILE(String)
|
|
|
ATerm
|
xtc-input-wrap(Strategy s)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
s
|
s FILE(a) -> b
|
|
Option parsing wrapper for XTC programs that only read data. Thisstrategy functions like xtc-io-wrap, except that it only exposesthe -i option, and will not write any output to pipe (or file).
Typically, s will start with a call to read-from.
Example: xtc-input-wrap(read-from ; id)
|
|
ATerm
|
xtc-input-wrap(Strategy extra-options, Strategy s)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
extra-options
|
extra-options _ -> Option or ArgOption
|
Strategy
s
|
s FILE(a) -> b
|
|
Option parsing wrapper for XTC programs that only read data. Thisstrategy functions like xtc-io-wrap, except that it only exposesthe -i option, and will not write any output to pipe (or file).
Typically, s will start with a call to read-from.
Example: xtc-input-wrap(ArgOption(....), read-from ; id)
|
|
ATerm
|
xtc-output(Strategy s)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
s
|
s a -> FILE(c)
|
|
Applies the strategy s to the current term, then writes the resultto output. The output file is taken from the -o option on the commandline, if given, or defaults to stdout, if not.
|
|
ATerm
|
xtc-output-wrap(Strategy s)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
s
|
s a -> FILE(b)
|
|
Option parsing wrapper for XTC programs that only generate data. This strategy functions like xtc-io-wrap, except that it onlyexposes the -o option, and will read any output from stdin(or file).
Typically, s will will end with a call to write-to.
Example: xtc-output-wrap(!"foo" ; write-to)
|
|
ATerm
|
xtc-output-wrap(Strategy extra-options, Strategy s)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
extra-options
|
extra-options _ -> Option or ArgOption
|
Strategy
s
|
s a -> FILE(b)
|
|
Option parsing wrapper for XTC programs that only generate data. This strategy functions like xtc-io-wrap, except that it onlyexposes the -o option, and will read any output from stdin(or file).
Typically, s will end with a call to write-to.
Example: xtc-output-wrap(!"foo" ; write-to)
|
|
ATerm
|
xtc-temp-files(Strategy s)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
|
Wrapper strategy that automatically cleans all temporary filescreated by s. This strategy is used to wrap a strategy <tt>s</tt>,which can create one or multiple temporary files. All temporaryfiles will be cleaned up automatically, and the result of<tt>s</tt> will be returned.
|
|
ATerm
|
xtc-write-output
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Writes a FILE to the output of this component. The outputis file is retrieved from the -o option given to theprogram; if -o was not given, stdout is used.
|
|
ATerm
|
xtc-write-output
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
No information available.
|
|
Rule details
|
ATerm
|
copy-to(Strategy name)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
name
|
name _ -> b
|
|
Copies one file to another. If the new file has the same nameas the old, no action is taken. In addition to a real file,the new file can be stdout (or stderr). In this case, the contentsof the old file will be written to stdout (or stderr) before thefile is removed.
|
|
ATerm
|
copy-to(Strategy name)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
No information available.
|
|
ATerm
|
copy-to(Strategy name)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
No information available.
|
|
ATerm
|
print-to
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Writes a (list of) string(s) to a temporary file. A singlestring, or a list of strings is written to a text file. Thefile name is generated automatically, and returned by thisstrategy.
type
|
String or List(String) -> FILE
|
|
|
ATerm
|
read-from
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Reads a term from a stdin. The input on stdin is assumed to bean ATerm. It will be parsed, and returned as a term.
|
|
ATerm
|
rename-to(Strategy name)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Parameters
Strategy
name
|
name _ -> newname
|
|
Renames one file to another, on disk. If the new nameis identical to the old, no action is taken. The oldfile can also be 'renamed' to stdout, in which casethe content of the old file is written to stdoutbefore the file is removed.
type
|
FILE(oldname) -> FILE(newname) or stdout
|
|
|
ATerm
|
rename-to(Strategy name)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
No information available.
|
|
ATerm
|
rename-to(Strategy name)
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
No information available.
|
|
ATerm
|
write-to
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Write a term to a temporary file, in binary. The name of the fileis generated automatically, the term is written to it in thebinary ATerm format (BAF), and a handle is returned by this strategy.
|
|
ATerm
|
write-to-text
|
File
|
Proc.str
|
Author
|
unknown
|
Since
|
unknown
|
|
Write a term to a temporary file, as text. The name of the fileis generated automatically, the term is written to it in thetextual ATerm format (TAF), and a handle is returned by this strategy.
|
|