Go to the first, previous, next, last section, table of contents.

Using DyALog

Unlike most Logic Program evaluators, DyALog has no toplevel, being designed to compile parsers.

The main command in the DyALog package is dyacc which is a PERL script used to compile programs.

This command uses dyalog to compile Prolog files (.pl) into DyALog Assembler files (.ma), and dyam2asm to convert .ma files into machine specific assembler (.s). The C compiler gcc is then called to build object files (.o) and link them.


The PERL script dyacc is a frontend to dyalog, dyam2asm, and gcc. An analysis of the command line is done to correctly forward the options to the different commands.

To use dyacc, issue the shell command:

dyacc [options | files]... [-- cc-options-and-files ]

where the possible options are

Compile or assemble the source files, but do not link. The compiler output is an object file corresponding to each source file.
To be used when DyALog is not installed (development mode)
`-I path'
Add `path' to the set of pathes used by dyalog to find files.
Compile DyALog source files, but do not call dyam2asm or gcc. By default, dyacc makes the object file name for a source file by replacing the suffix `.pl' with `.ma'. Use `-o' to select another name.
`-o file'
Place output in `file'. This applies regardless to whatever sort of output dyacc is producing.
Set option -parse for dyalog
`-pl-ext suffixe'
Specify an extra `suffixe' for Prolog files
Keep intermediate files (.ma and .s) but do not transmit the option to gcc.
Print (on standard error output) the commands executed to run the stages of compilation.
`-x lang'
Specify explicitly the `language' for the following input files (rather than choosing a default based on the file name suffix). This option applies to all following input files until the next `-x' option. Possible values of `language' are `pl', `ma', and `none' (to reset).
Mark the end of DyALog options. Everything on the right is passed to gcc and not considered as a dyacc option.


To use DyALog, issue the shell command:

% dyalog -a [options | files]

where the possible options are

Version information
`-f filename'
Load the program file filename. `-f' may be ommited when filename does not start with `-'.
`-I path'
Add path to the search path list of DyALog. The same effect can be achieved using the environment variable DYALOG_PGMPATH.
Compile grammar rules considering a parsing done from a database of tokens.
`-use filename'
Add filename to the list of modules to be imported. The same effect can be achieved using a directive require/1.
`-res filename'
Extend the compiler by loading the resource file filename. The same effect can be achieved using a directive resource/1.

The command dyalog also inherits all options available to DyAlog executables: they should take place before -a.


This command is used to convert DyALog Assembler files into machine assembler.

Its syntax is

% dyam2asm [option...] input_file
Show some help and exit
`-o filename'
Name the output file (otherwise use the standard output)
Print version number and exit

DyALog executables

All DyALog executables accept the following options:

%> <dyalog_exe> [options | files] [-a args]
Display some help and exit.
`-db filename'
Load `filename' as a database. `-db' may be ommited when `filename' does not start with `-'.
Display the shared forest at the end of the execution
Display the number of possible derivations per answer.
`-slex string'
Use string as the string to parse
`-flex file'
Use file as a character file to parse
`-v kind'
Display trace information relative to kind, which should belong to dyam, share, index, or all.
`-a args'
All args are collected in a Prolog list of symbols and accessible by the executable through the builtin argv/1.

By default, a filename on the command line is loaded as a database.

An example

We illustrate the use of dyalog on a small recursive example that will loop with standard Prolog systems.

% cat pgm.pl
q(X) :- q(f(X)).
?-q(X).    % the query must be inside the file

% dyacc pgm.pl -o pgm
% ./pgm
    X = f(f(a))
    X = f(a)
    X = a

Go to the first, previous, next, last section, table of contents.