The LMNtal system first compiles LMNtal source files into intermediate code. It then translates the intermediate code into Java programs, which is in turn compiled into Java bytecode and packaged into a .jar (Java archive) file.
The LMNtal system can also execute the intermediate code interpretively (rather than translating them into Java) by giving the --interpret option.
When invoked without a source filename, the LMNtal system enters the REPL (read-eval-print loop) mode in which expressions are executed interpretively.
The system comes with a library API. In addition, you can define your own libraries to be used with your programs. See How to create libraries (below) for details about libraries.
LMNtal programs transtaled into Java bytecode run an order of magnitude faster than the interpreted intermediate code.
(Note to Cygwin users: The command names (lmnc, lmnr, lmntal) shown below work on UNIX/Linux and Windows. On Cygwin, please use lmnc_cyg, lmnr_cyg, and lmntal_cyg instead.)
On Windows 2000/XP, Cygwin and UNIX/Linux, shellscripts in the bin directory facilitate compilation and execution.
(Note: Skip this step unless you have your own library.)
Prepare compiled libraries (how to make lirary .jar files will be explained below) and put them in the lib directory.
$lmnc foo.lmn
Compiler options can be specified either before or after the filename.
$ lmnc -O2 foo.lmn $ lmnc foo.lmn -d
$ lmnr foo.jar
Runtime options must be specified after the .jar filename.
(ok) $ lmnr foo.jar -g (no) $ lmnr -t foo.jar
$ lmntal
The system enters the interactive when a filename is not specified in the command line. Enter an LMNtal expression (that can spread over multiple lines) and hit the return key twice to execute it. you can also tell the system to start execution with one newline by giving the --immediate option.
The following list shows some interactive-mode commands:
:q - quit :h - see help :trace | :notrace - set trace mode :verbose [0-9] - set verbosity level :shuffle [0-3] - set shuffle level
Here is an example of an interactive mode session:
% lmntal [PRESS ENTER] LMNtal version 0.70.20060105 Type :h to see help. Type :q to quit. Enter an empty line to run the input. # A=f(f(f(f(f(A))))), c,c, ( c, X=f(Y) :- X=g(Y) ) [PRESS ENTER] [PRESS ENTER] f(g(g(f(f(_4)))),_4), @601 # A=f(f(f(f(f(A))))), c,c, ( c, X=f(Y) :- X=g(Y) ) [PRESS ENTER] [PRESS ENTER] g(f(f(f(g(_24)))),_24), @604 # :q [PRESS ENTER] %
$ java runtime.FrontEnd foo.lmn
java Main
There are many options for compilation and execution. Popular options include:
-t - trace mode -v[0-9] - set verbosity level ( -v = -v5 ) -s[0-3] - set shuffle level ( -s = -s3 ) -g - graphical mode (experimental)
To see the list of all available options, do:
lmntal --help
A Verbosity Level expresses how verbosely an LMNtal process is displayed.
0: silence 2: default 3: print `proxy atoms' and contents of rulesets 4: expand operators 5: expand atoms 6: expand rulesets
A shuffle Level expresses how randomly the execution goes on.
0: (default) use an atom stack for each membrane (atoms are selected in a LIFO manner) 1: atoms are selected in a system-defined order (which is not random or LIFO) 2: select atoms and membranes randomly from a membrane 3: select atoms, membranes and rules randomly from a membrane
The graphical Mode (experimental) visualizes program execution. A graphical window will be displayed that visualizes the evolution of hierarchical graph structure. Computation proceeds step by step by pressing the space bar or clicking on the 'Go ahead' button. Atoms can be dragged to arbitrary positions so that the graph may look better. To terminate the execution, close the window manually.
A library is a program that is prepared (compiled) separately and added to the classpath. A library can be used also with a program running under the --interpret option.
By using shellscripts in the bin directory, you can invoke LMNtal after adding all .jar files located in the lib directory to the classpath.
You can also use the source code of the library by giving the --use-source-library option, in which case the .lmn files in the lib/src directory will be read and compiled on demand.
To create your own program library, compile the program with the --library option:
lmnc --library libhoge.lmn java runtime.FrontEnd --library libhoge.lmn (Windows 9x)
Then, move the .jar file to the $LMNTAL_HOME/lib directory.