Given that Grail and its grammar files are written in Prolog, some basic familiarity with Prolog and its syntax will be useful, though the fundamentals will be explained in the text. An introduction to Prolog can be found here (offsite).
lex(Word,
Formula, Semantics)
triples. Where Word
is the
orthographical form of the lexical entry, Formula
is the
formula assigned to this word and Semantics
the
corresponding lambda-term semantics.
The simplest possible lexical entry is then.
lex(arthur, np, arthur).
which states "Arthur" (note the lowercase letter in
the lexical entry: unquoted Prolog constants need to start with a
lowercase letter) is of category np
and has
arthur
as its semantics. Remark that a Prolog fact like
the lexical entry above has to be terminated by a period.
I
is the Prolog atom corresponding to the mode
i, A
is the Prolog term corresponding to the
formula A and B
is the Prolog term corresponding to the
formula B.
The mnemonics for the term constructors are `division right' for
dr
, `product' for p
, `division left' for
dl
, `diamond' for dia
and `box' box
.
After having edited a file, remember that you can select [File/Reload Grammar] from the menu bar to reload your edited grammar into Grail.
macro
declarations to your grammar. A macro is a
Prolog fact of the form macro(Term, Formula)
indicating
that Term
should be replaced by
Formula
. This term
occur anywhere a formula can occur and Grail will recursively expand
the macro definitions until a normal form is reached.
As an example, two frequently occurring macro's are the following.
macro(iv, dl(0,np,s)).
macro(tv, dr(0,iv,np)).
The first macro indicates that the atom iv
, for intransitive verb,
corresponds to the formula np \0 s, ie. the formula which
looks for a noun phrase to its left in order to produce a sentence.
The second macro indicates that the atom tv
corresponds
to a formula which is looking to its right for a noun phrase in order
to produce an intransitive verb, as defined by the first macro.
Grail makes the tacit assumption that your macro definitions will terminate and produce a unique normal form for any term using them. The macro facilities are meant as a simply way to factorize your grammars and not as a tool to perform complex computations. Changing macro definitions is a way to quickly make global changes to your grammar.