If you have run mk-build-tree then there will be makefiles in the demo build directories which will compile the demos. We don't go into too much detail here about how to build these demos, see the documentation for mindy and d2c
mindycomp -lhello-world hello-world-exports.dylan mindycomp -lhello-world hello-world.dylan mindy -f hello-world-exports.dbc -f hello-world.dbcto run it under mindy or:
d2c hello-world.lid ./hello-worldto run it under d2c.
mindy -f cat-exports.dbc -f cat.dbc file1 file2 ....or with no arguments, in which case it reads from "standard input". You may also specify special filename "-" which will refer to the standard input.
On most Unix systems you should be able to make it into an executable script by concatenating cat-exports.dbc and cat.dbc into say mindy-cat, prepending the the line
#DYLANDIR/bin/mindy -fand adding "execute" to the file's protection. Note that DYLANDIR must be substituted by you.
You could then simply type:
mindy-cat file1 file2 ....You must, of course, remember to specify the DYLANDIR environment variable so that it points to directories containing all of the relevant libraries. (This demo uses only "dylan" and "streams", but the "html2txt" demo also uses "collection-extensions".)
mindy -f diff-lib.dbc file1 file2
diff-lib.dbc is created by the Makegen makefile by contantenating diff-exports.dbc and diff.dbc. Limitations: Diff the stand-alone utility is meant purely as a demo. It doesn't support any of the options that a real diff utility does. It accepts input only as files; it won't read from standard input. The output format of our demo is slightly different from the standard Unix diff.
You must, of course, remember to specify the DYLANDIR environment variable so that it points to directories containing all of the relevant libraries. (This demo uses "dylan", "streams", "format", and "collection-extensions") The build procedure is similar to
Usage is similar to "cat" above, except that it does not support the "-" argument. You may therefore set of files on the command line or use standard input by specifying no command line arguments
mindy -f html2txt-lib.dbc file1.html file2.html .... mindy -f cat-lib.dbc file1.html file2.html | mindy -f html2txt-lib.dbcAt present, "html2txt" accepts no command line switches, although the behavior may be changed by changing several constant declarations towards the top of the source file.
A useful test case for this program is this file (demos.html).
The basic translation strategy used by html2txt is to scan the file line by line, looking for HTML "tags" and accumulating text that lies between any two tags. For each tag type, there is a set of routines (stored in tables) which define the appropriate actions for starting and ending the "environment" defined by the tag and for dumping the collected text from within that environment as formatted text. A basic control loop in "process-HTML" is responsible for calling the appropriate tag actions. This routine may be called recusively by some of the tag actions.
The "interface" between adjacent environments is handled via the "blank" parameter which is passed around extensively. This variable states whether a blank line has just been printed. Thus environments which believe that they must be preceded or followed by a blank line can determine whetehr they must do anything about it, and we lessen the risk that multiple routines will emit blank lines when we only want a maximum of one.
The primary advantage of this organization is that it allows the specialized actions for a single tag to be grouped together, and allows new tags to be cleanly added. It benefits greatly from Dylan's ability to create anonymous methods and manipulate them as first class data objects, as well as from the rich set of available collection types.
If you get the error message 'font "-adobe-courier-medium-r-normal--12*" doesn't exist', edit html2txt.dylan. Find the lines that define "normal-font" and "bold-font" and substitute a font your machine does have. Alternately, go down a few lines further and delete the "font: normal-font" and "font: bold-font" clauses.
fact) and having another library (
library-demo) use it. In the library-demo.lid note the use of
Unit-Prefix:to prevent the creation of C identifiers with hyphens in them and in fact.lid the use of
Unique-ID-Base:to make sure any exported classes have unique IDs (in this case there are none.)
Under Mindy, you can run this as the other demos:
mindy -f library-demo-lib.dbcNote however that library-demo-lib.dbc does not include the
Factlibrary. Instead this is demand-loaded by searching on DYLANPATH for fact-lib.dbc (preferrably) or fact.dbc. Sometimes you can get in trouble if the -lib.dbc file doesn't appear in DYLANPATH before some other file that happens to use the unsuffixed name. Under d2c, all used libraries are statically linked into the executable, and you just type: