summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2005-12-15 15:45:42 +0000
committeraarne <aarne@cs.chalmers.se>2005-12-15 15:45:42 +0000
commite3a896685cda238603d3fc24388cd52a74f8ff25 (patch)
treefa8bd88f3d88f4b0c54e5b628de656c0dcfbba6b
parent1acf3636d33afb11cfc55d03098d11cf7ab704d3 (diff)
tutorial in txt format
-rw-r--r--doc/tutorial/gf-tutorial2.html2246
-rw-r--r--doc/tutorial/gf-tutorial2.txt1320
2 files changed, 2501 insertions, 1065 deletions
diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html
index 0254a7465..4a3e15d44 100644
--- a/doc/tutorial/gf-tutorial2.html
+++ b/doc/tutorial/gf-tutorial2.html
@@ -1,964 +1,1073 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html><head><title></title></head>
- <body bgcolor="#ffffff" text="#000000">
-<center>
-
-<img src="../gf-logo.gif">
-
-<h1>Grammatical Framework Tutorial</h1>
-
-<p>
-
-<b>3rd Edition, for GF version 2.2 or later</b>
-
-<p>
-
-<a href="http://www.cs.chalmers.se/~aarne">Aarne Ranta</a>
-
-<p>
-
-<tt>aarne@cs.chalmers.se</tt>
-
-<p>
-
-17 May 2005
-</center>
-
-
-<!-- NEW -->
-<h2>GF = Grammatical Framework</h2>
-
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+<META NAME="generator" CONTENT="http://txt2tags.sf.net">
+<TITLE>Grammatical Framework Tutorial</TITLE>
+</HEAD><BODY BGCOLOR="white" TEXT="black">
+<P ALIGN="center"><CENTER><H1>Grammatical Framework Tutorial</H1>
+<FONT SIZE="4">
+<I>Author: Aarne Ranta &lt;aarne (at) cs.chalmers.se&gt;</I><BR>
+Last update: Thu Dec 15 16:43:59 2005
+</FONT></CENTER>
+
+<P></P>
+<HR NOSHADE SIZE=1>
+<P></P>
+ <UL>
+ <LI><A HREF="#toc1">Grammatical Framework Tutorial</A>
+ <UL>
+ <LI><A HREF="#toc2">GF = Grammatical Framework</A>
+ <UL>
+ <LI><A HREF="#toc3">Getting the GF program</A>
+ </UL>
+ <LI><A HREF="#toc4">My first grammar</A>
+ <UL>
+ <LI><A HREF="#toc5">Importing grammars and parsing strings</A>
+ <LI><A HREF="#toc6">Generating trees and strings</A>
+ <LI><A HREF="#toc7">Some random-generated sentences</A>
+ <LI><A HREF="#toc8">Systematic generation</A>
+ <LI><A HREF="#toc9">More on pipes; tracing</A>
+ <LI><A HREF="#toc10">Writing and reading files</A>
+ <LI><A HREF="#toc11">Labelled context-free grammars</A>
+ </UL>
+ <LI><A HREF="#toc12">The GF grammar format</A>
+ <UL>
+ <LI><A HREF="#toc13">Abstract and concrete syntax</A>
+ <LI><A HREF="#toc14">Resource modules</A>
+ <LI><A HREF="#toc15">Opening a ``resource``</A>
+ </UL>
+ <LI><A HREF="#toc16">Topics still to be written</A>
+ </UL>
+ </UL>
+
+<P></P>
+<HR NOSHADE SIZE=1>
+<P></P>
+<P>
+<IMG ALIGN="middle" SRC="../gf-logo.gif" BORDER="0" ALT="">
+</P>
+<A NAME="toc1"></A>
+<H1>Grammatical Framework Tutorial</H1>
+<P>
+<B>3rd Edition, for GF version 2.2 or later</B>
+</P>
+<P>
+<A HREF="http://www.cs.chalmers.se/~aarne">Aarne Ranta</A>
+</P>
+<P>
+<CODE>aarne@cs.chalmers.se</CODE>
+</P>
+<A NAME="toc2"></A>
+<H2>GF = Grammatical Framework</H2>
+<P>
The term GF is used for different things:
-<ul>
-<li> a <b>program</b> used for working with grammars
-<li> a <b>programming language</b> in which grammars can be written
-<li> a <b>theory</b> about grammars and languages
-</ul>
-
-<p>
-
+</P>
+<UL>
+<LI>a <B>program</B> used for working with grammars
+<LI>a <B>programming language</B> in which grammars can be written
+<LI>a <B>theory</B> about grammars and languages
+</UL>
+
+<P>
This tutorial is primarily about the GF program and
the GF programming language.
It will guide you
-<ul>
-<li> to use the GF program
-<li> to write GF grammars
-<li> to write programs in which GF grammars are used as components
-</ul>
-
-
-
-<!-- NEW -->
-<h3>Getting the GF program</h3>
-
+</P>
+<UL>
+<LI>to use the GF program
+<LI>to write GF grammars
+<LI>to write programs in which GF grammars are used as components
+</UL>
+
+<A NAME="toc3"></A>
+<H3>Getting the GF program</H3>
+<P>
The program is open-source free software, which you can download via the
-GF Homepage:<br>
-<a href="http://www.cs.chalmers.se/%7Eaarne/GF">
-<tt>http://www.cs.chalmers.se/~aarne/GF</tt></a>
-
-<p>
-
+GF Homepage:
+<A HREF="http://www.cs.chalmers.se/~aarne/GF"><CODE>http://www.cs.chalmers.se/~aarne/GF</CODE></A>
+</P>
+<P>
There you can download
-<ul>
-<li> ready-made binaries for Linux, Solaris, Macintosh, and Windows
-<li> source code and documentation
-<li> grammar libraries and examples
-</ul>
+</P>
+<UL>
+<LI>ready-made binaries for Linux, Solaris, Macintosh, and Windows
+<LI>source code and documentation
+<LI>grammar libraries and examples
+</UL>
+
+<P>
If you want to compile GF from source, you need Haskell and Java
compilers. But normally you don't have to compile, and you definitely
don't need to know Haskell or Java to use GF.
-
-<p>
-
+</P>
+<P>
To start the GF program, assuming you have installed it, just type
-<pre>
- gf
-</pre>
-in the shell. You will see GF's welcome message and the prompt <tt>></tt>.
-
-
-<!-- NEW -->
-<h2>My first grammar</h2>
-
+</P>
+<PRE>
+ gf
+</PRE>
+<P>
+in the shell. You will see GF's welcome message and the prompt <CODE>&gt;</CODE>.
+</P>
+<A NAME="toc4"></A>
+<H2>My first grammar</H2>
+<P>
Now you are ready to try out your first grammar.
We start with one that is not written in GF language, but
in the EBNF notation (Extended Backus Naur Form), which GF can also
understand. Type (or copy) the following lines in a file named
-<tt>paleolithic.ebnf</tt>:
-<pre>
- S ::= NP VP ;
- VP ::= V | TV NP | "is" A ;
- NP ::= ("this" | "that" | "the" | "a") CN ;
- CN ::= A CN ;
- CN ::= "boy" | "louse" | "snake" | "worm" ;
- A ::= "green" | "rotten" | "thick" | "warm" ;
- V ::= "laughs" | "sleeps" | "swims" ;
- TV ::= "eats" | "kills" | "washes" ;
-</pre>
-
-
-<!-- NEW -->
-<h3>Importing grammars and parsing strings</h3>
-
-The first GF command when using a grammar is to <b>import</b> it.
-The command has a long name, <tt>import</tt>, and a short name, <tt>i</tt>.
-<pre>
- import paleolithic.gf
-</pre>
-The GF program now <b>compiles</b> your grammar into an internal
+<CODE>paleolithic.ebnf</CODE>:
+</P>
+<PRE>
+ S ::= NP VP ;
+ VP ::= V | TV NP | "is" A ;
+ NP ::= ("this" | "that" | "the" | "a") CN ;
+ CN ::= A CN ;
+ CN ::= "boy" | "louse" | "snake" | "worm" ;
+ A ::= "green" | "rotten" | "thick" | "warm" ;
+ V ::= "laughs" | "sleeps" | "swims" ;
+ TV ::= "eats" | "kills" | "washes" ;
+</PRE>
+<P></P>
+<A NAME="toc5"></A>
+<H3>Importing grammars and parsing strings</H3>
+<P>
+The first GF command when using a grammar is to <B>import</B> it.
+The command has a long name, <CODE>import</CODE>, and a short name, <CODE>i</CODE>.
+</P>
+<PRE>
+ import paleolithic.gf
+</PRE>
+<P>
+The GF program now <B>compiles</B> your grammar into an internal
representation, and shows a new prompt when it is ready.
-
-<p>
-
-You can use GF for <b>parsing</b>:
-<pre>
- > parse "the boy eats a snake"
- Mks_0 (Mks_6 Mks_9) (Mks_2 Mks_20 (Mks_7 Mks_11))
-
- > parse "the snake eats a boy"
- Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
-</pre>
-The <tt>parse</tt> (= <tt>p</tt>) command takes a <b>string</b>
-(in double quotes) and returns an <b>abstract syntax tree</b> - the thing
-with <tt>Mks</tt>s and parentheses. We will see soon how to make sense
+</P>
+<P>
+You can use GF for <B>parsing</B>:
+</P>
+<PRE>
+ &gt; parse "the boy eats a snake"
+ Mks_0 (Mks_6 Mks_9) (Mks_2 Mks_20 (Mks_7 Mks_11))
+
+ &gt; parse "the snake eats a boy"
+ Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
+</PRE>
+<P>
+The <CODE>parse</CODE> (= <CODE>p</CODE>) command takes a <B>string</B>
+(in double quotes) and returns an <B>abstract syntax tree</B> - the thing
+with <CODE>Mks</CODE>s and parentheses. We will see soon how to make sense
of the abstract syntax trees - now you should just notice that the tree
is different for the two strings.
-
-<p>
-
+</P>
+<P>
Strings that return a tree when parsed do so in virtue of the grammar
you imported. Try parsing something else, and you fail
-<pre>
- > p "hello world"
- No success in cf parsing
- no tree found
-</pre>
-
-
-<!-- NEW -->
-<h3>Generating trees and strings</h3>
-
-You can also use GF for <b>linearizing</b>
-(<tt>linearize = l</tt>). This is the inverse of
+</P>
+<PRE>
+ &gt; p "hello world"
+ No success in cf parsing
+ no tree found
+</PRE>
+<P></P>
+<A NAME="toc6"></A>
+<H3>Generating trees and strings</H3>
+<P>
+You can also use GF for <B>linearizing</B>
+(<CODE>linearize = l</CODE>). This is the inverse of
parsing, taking trees into strings:
-<pre>
- > linearize Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
- the snake eats a boy
-</pre>
+</P>
+<PRE>
+ &gt; linearize Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
+ the snake eats a boy
+</PRE>
+<P>
What is the use of this? Typically not that you type in a tree at
the GF prompt. The utility of linearization comes from the fact that
you can obtain a tree from somewhere else. One way to do so is
-<b>random generation</b> (<tt>generate_random = gr</tt>):
-<pre>
- > generate_random
- Mks_0 (Mks_4 Mks_11) (Mks_3 Mks_15)
-</pre>
-Now you can copy the tree and paste it to the <tt>linearize command</tt>.
+<B>random generation</B> (<CODE>generate_random = gr</CODE>):
+</P>
+<PRE>
+ &gt; generate_random
+ Mks_0 (Mks_4 Mks_11) (Mks_3 Mks_15)
+</PRE>
+<P>
+Now you can copy the tree and paste it to the <CODE>linearize command</CODE>.
Or, more efficiently, feed random generation into parsing by using
-a <b>pipe</b>.
-<pre>
- > gr | l
- this worm is warm
-</pre>
-
-
-<!-- NEW -->
-<h3>Some random-generated sentences</h3>
-
+a <B>pipe</B>.
+</P>
+<PRE>
+ &gt; gr | l
+ this worm is warm
+</PRE>
+<P></P>
+<A NAME="toc7"></A>
+<H3>Some random-generated sentences</H3>
+<P>
Random generation can be quite amusing. So you may want to
generate ten strings with one and the same command:
-<pre>
- > gr -number=10 | l
- this boy is green
- a snake laughs
- the rotten boy is thick
- a boy washes this worm
- a boy is warm
- this green warm boy is rotten
- the green thick green louse is rotten
- that boy is green
- this thick thick boy laughs
- a boy is green
-</pre>
-
-
-<!-- NEW -->
-<h3>Systematic generation</h3>
-
-To generate <i>all</i> sentence that a grammar
-can generate, use the command <tt>generate_trees = gt</tt>.
-<pre>
- > generate_trees | l
- this louse laughs
- this louse sleeps
- this louse swims
- this louse is green
- this louse is rotten
- ...
- a boy is rotten
- a boy is thick
- a boy is warm
-</pre>
+</P>
+<PRE>
+ &gt; gr -number=10 | l
+ this boy is green
+ a snake laughs
+ the rotten boy is thick
+ a boy washes this worm
+ a boy is warm
+ this green warm boy is rotten
+ the green thick green louse is rotten
+ that boy is green
+ this thick thick boy laughs
+ a boy is green
+</PRE>
+<P></P>
+<A NAME="toc8"></A>
+<H3>Systematic generation</H3>
+<P>
+To generate &lt;i&gt;all&lt;i&gt; sentence that a grammar
+can generate, use the command <CODE>generate_trees = gt</CODE>.
+</P>
+<PRE>
+ &gt; generate_trees | l
+ this louse laughs
+ this louse sleeps
+ this louse swims
+ this louse is green
+ this louse is rotten
+ ...
+ a boy is rotten
+ a boy is thick
+ a boy is warm
+</PRE>
+<P>
You get quite a few trees but not all of them: only up to a given
-<b>depth</b> of trees. To see how you can get more, use the
-<tt>help = h</tt> command,
-<pre>
- help gr
-</pre>
-<b>Quiz</b>. If the command <tt>gt</tt> generated all
+<B>depth</B> of trees. To see how you can get more, use the
+<CODE>help = h</CODE> command,
+</P>
+<PRE>
+ help gr
+</PRE>
+<P>
+<B>Quiz</B>. If the command <CODE>gt</CODE> generated all
trees in your grammar, it would never terminate. Why?
-
-
-
-<!-- NEW -->
-<h3>More on pipes; tracing</h3>
-
+</P>
+<A NAME="toc9"></A>
+<H3>More on pipes; tracing</H3>
+<P>
A pipe of GF commands can have any length, but the "output type"
(either string or tree) of one command must always match the "input type"
of the next command.
-
-<p>
-
+</P>
+<P>
The intermediate results in a pipe can be observed by putting the
-<b>tracing</b> flag <tt>-tr</tt> to each command whose output you
+<B>tracing</B> flag <CODE>-tr</CODE> to each command whose output you
want to see:
-<pre>
- > gr -tr | l -tr | p
- Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
- a louse sleeps
- Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
-</pre>
+</P>
+<PRE>
+ &gt; gr -tr | l -tr | p
+ Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
+ a louse sleeps
+ Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
+</PRE>
+<P>
This facility is good for test purposes: for instance, you
-may want to see if a grammar is <b>ambiguous</b>, i.e.
+may want to see if a grammar is <B>ambiguous</B>, i.e.
contains strings that can be parsed in more than one way.
-
-
-
-<!-- NEW -->
-<h3>Writing and reading files</h3>
-
+</P>
+<A NAME="toc10"></A>
+<H3>Writing and reading files</H3>
+<P>
To save the outputs of GF commands into a file, you can
-pipe it to the <tt>write_file = wf</tt> command,
-<pre>
- > gr -number=10 | l | write_file exx.tmp
-</pre>
+pipe it to the <CODE>write_file = wf</CODE> command,
+</P>
+<PRE>
+ &gt; gr -number=10 | l | write_file exx.tmp
+</PRE>
+<P>
You can read the file back to GF with the
-<tt>read_file = rf</tt> command,
-<pre>
- > read_file exx.tmp | l -tr | p -lines
-</pre>
-Notice the flag <tt>-lines</tt> given to the parsing
+<CODE>read_file = rf</CODE> command,
+</P>
+<PRE>
+ &gt; read_file exx.tmp | l -tr | p -lines
+</PRE>
+<P>
+Notice the flag <CODE>-lines</CODE> given to the parsing
command. This flag tells GF to parse each line of
the file separately. Without the flag, the grammar could
not recognize the string in the file, because it is not
a sentence but a sequence of ten sentences.
-
-
-
-<!-- NEW -->
-<h3>Labelled context-free grammars</h3>
-
+</P>
+<A NAME="toc11"></A>
+<H3>Labelled context-free grammars</H3>
+<P>
The syntax trees returned by GF's parser in the previous examples
-are not so nice to look at. The identifiers of form <tt>Mks</tt>
-are <b>labels</b> of the EBNF rules. To see which label corresponds to
-which rule, you can use the <tt>print_grammar = pg</tt> command
-with the <tt>printer</tt> flag set to <tt>cf</tt> (which means context-free):
-<pre>
- > print_grammar -printer=cf
- Mks_10. CN ::= "louse" ;
- Mks_11. CN ::= "snake" ;
- Mks_12. CN ::= "worm" ;
- Mks_8. CN ::= A CN ;
- Mks_9. CN ::= "boy" ;
- Mks_4. NP ::= "this" CN ;
- Mks_15. A ::= "thick" ;
- ...
-</pre>
+are not so nice to look at. The identifiers of form <CODE>Mks</CODE>
+are <B>labels</B> of the EBNF rules. To see which label corresponds to
+which rule, you can use the <CODE>print_grammar = pg</CODE> command
+with the <CODE>printer</CODE> flag set to <CODE>cf</CODE> (which means context-free):
+</P>
+<PRE>
+ &gt; print_grammar -printer=cf
+ Mks_10. CN ::= "louse" ;
+ Mks_11. CN ::= "snake" ;
+ Mks_12. CN ::= "worm" ;
+ Mks_8. CN ::= A CN ;
+ Mks_9. CN ::= "boy" ;
+ Mks_4. NP ::= "this" CN ;
+ Mks_15. A ::= "thick" ;
+ ...
+</PRE>
+<P>
A syntax tree such as
-<pre>
- Mks_4 (Mks_8 Mks_15 Mks_12)
- this thick worm
-</pre>
+</P>
+<PRE>
+ Mks_4 (Mks_8 Mks_15 Mks_12)
+ this thick worm
+</PRE>
+<P>
encodes the sequence of grammar rules used for building the
-expression. If you look at this tree, you will notice that <tt>Mks_4</tt>
-is the label of the rule prefixing <tt>this</tt> to a common noun,
-<tt>Mks_15</tt> is the label of the adjective <tt>thick</tt>,
+expression. If you look at this tree, you will notice that <CODE>Mks_4</CODE>
+is the label of the rule prefixing <CODE>this</CODE> to a common noun,
+<CODE>Mks_15</CODE> is the label of the adjective <CODE>thick</CODE>,
and so on.
-
-
-<!-- NEW -->
-<h4>The labelled context-free format</h4>
-
-The <b>labelled context-free grammar</b> format permits user-defined
+</P>
+<P>
+&lt;h4&gt;The labelled context-free format&lt;h4&gt;
+</P>
+<P>
+The <B>labelled context-free grammar</B> format permits user-defined
labels to each rule.
GF recognizes files of this format by the suffix
-<tt>.cf</tt>. It is intermediate between EBNF and full GF format.
+<CODE>.cf</CODE>. It is intermediate between EBNF and full GF format.
Let us include the following rules in the file
-<tt>paleolithic.cf</tt>.
-<pre>
- PredVP. S ::= NP VP ;
- UseV. VP ::= V ;
- ComplTV. VP ::= TV NP ;
- UseA. VP ::= "is" A ;
- This. NP ::= "this" CN ;
- That. NP ::= "that" CN ;
- Def. NP ::= "the" CN ;
- Indef. NP ::= "a" CN ;
- ModA. CN ::= A CN ;
- Boy. CN ::= "boy" ;
- Louse. CN ::= "louse" ;
- Snake. CN ::= "snake" ;
- Worm. CN ::= "worm" ;
- Green. A ::= "green" ;
- Rotten. A ::= "rotten" ;
- Thick. A ::= "thick" ;
- Warm. A ::= "warm" ;
- Laugh. V ::= "laughs" ;
- Sleep. V ::= "sleeps" ;
- Swim. V ::= "swims" ;
- Eat. TV ::= "eats" ;
- Kill. TV ::= "kills"
- Wash. TV ::= "washes" ;
-</pre>
-
-<!-- NEW -->
-<h4>Using the labelled context-free format</h4>
-
-The GF commands for the <tt>.cf</tt> format are
-exactly the same as for the <tt>.ebnf</tt> format.
+<CODE>paleolithic.cf</CODE>.
+</P>
+<PRE>
+ PredVP. S ::= NP VP ;
+ UseV. VP ::= V ;
+ ComplTV. VP ::= TV NP ;
+ UseA. VP ::= "is" A ;
+ This. NP ::= "this" CN ;
+ That. NP ::= "that" CN ;
+ Def. NP ::= "the" CN ;
+ Indef. NP ::= "a" CN ;
+ ModA. CN ::= A CN ;
+ Boy. CN ::= "boy" ;
+ Louse. CN ::= "louse" ;
+ Snake. CN ::= "snake" ;
+ Worm. CN ::= "worm" ;
+ Green. A ::= "green" ;
+ Rotten. A ::= "rotten" ;
+ Thick. A ::= "thick" ;
+ Warm. A ::= "warm" ;
+ Laugh. V ::= "laughs" ;
+ Sleep. V ::= "sleeps" ;
+ Swim. V ::= "swims" ;
+ Eat. TV ::= "eats" ;
+ Kill. TV ::= "kills"
+ Wash. TV ::= "washes" ;
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Using the labelled context-free format&lt;h4&gt;
+</P>
+<P>
+The GF commands for the <CODE>.cf</CODE> format are
+exactly the same as for the <CODE>.ebnf</CODE> format.
Just the syntax trees become nicer to read and
to remember. Notice that before reading in
a new grammar in GF you often (but not always,
as we will see later) have first to give the
-command (<tt>empty = e</tt>), which removes the
+command (<CODE>empty = e</CODE>), which removes the
old grammar from the GF shell state.
-<pre>
- > empty
-
- > i paleolithic.cf
-
- > p "the boy eats a snake"
- PredVP (Def Boy) (ComplTV Eat (Indef Snake))
-
- > gr -tr | l
- PredVP (Indef Louse) (UseA Thick)
- a louse is thick
-</pre>
-
-
-<!-- NEW -->
-<h2>The GF grammar format</h2>
-
+</P>
+<PRE>
+ &gt; empty
+
+ &gt; i paleolithic.cf
+
+ &gt; p "the boy eats a snake"
+ PredVP (Def Boy) (ComplTV Eat (Indef Snake))
+
+ &gt; gr -tr | l
+ PredVP (Indef Louse) (UseA Thick)
+ a louse is thick
+</PRE>
+<P></P>
+<A NAME="toc12"></A>
+<H2>The GF grammar format</H2>
+<P>
To see what there really is in GF's shell state when a grammar
has been imported, you can give the plain command
-<tt>print_grammar = pg</tt>.
-<pre>
- > print_grammar
-</pre>
+<CODE>print_grammar = pg</CODE>.
+</P>
+<PRE>
+ &gt; print_grammar
+</PRE>
+<P>
The output is quite unreadable at this stage, and you may feel happy that
you did not need to write the grammar in that notation, but that the
GF grammar compiler produced it.
-
-<p>
-
+</P>
+<P>
However, we will now start to show how GF's own notation gives you
-much more expressive power than the <tt>.cf</tt> and <tt>.ebnf</tt>
-formats. We will introduce the <tt>.gf</tt> format by presenting
+much more expressive power than the <CODE>.cf</CODE> and <CODE>.ebnf</CODE>
+formats. We will introduce the <CODE>.gf</CODE> format by presenting
one more way of defining the same grammar as in
-<tt>paleolithic.cf</tt> and <tt>paleolithic.ebnf</tt>.
+<CODE>paleolithic.cf</CODE> and <CODE>paleolithic.ebnf</CODE>.
Then we will show how the full GF grammar format enables you
to do things that are not possible in the weaker formats.
-
-
-<!-- NEW -->
-<h3>Abstract and concrete syntax</h3>
-
+</P>
+<A NAME="toc13"></A>
+<H3>Abstract and concrete syntax</H3>
+<P>
A GF grammar consists of two main parts:
-<ul>
-<li> <b>abstract syntax</b>, defining what syntax trees there are
-<li> <b>concrete syntax</b>, defining how trees are linearized into strings
-</ul>
+</P>
+<UL>
+<LI><B>abstract syntax</B>, defining what syntax trees there are
+<LI><B>concrete syntax</B>, defining how trees are linearized into strings
+</UL>
+
+<P>
The EBNF and CF formats fuse these two things together, but it is possible
to take them apart. For instance, the verb phrase predication rule
-<pre>
- PredVP. S ::= NP VP ;
-</pre>
+</P>
+<PRE>
+ PredVP. S ::= NP VP ;
+</PRE>
+<P>
is interpreted as the following pair of rules:
-<pre>
- fun PredVP : NP -> VP -> S ;
- lin PredVP x y = {s = x.s ++ y.s} ;
-</pre>
-The former rule, with the keyword <tt>fun</tt>, belongs to the abstract syntax.
-It defines the <b>function</b>
-<tt>PredVP</tt> which constructs syntax trees of form
-(<tt>PredVP</tt> <i>x</i> <i>y</i>).
-
-<p>
-
-The latter rule, with the keyword <tt>lin</tt>, belongs to the concrete syntax.
-It defines the <b>linearization function</b> for
-syntax trees of form (<tt>PredVP</tt> <i>x</i> <i>y</i>).
-
-
-<!-- NEW -->
-<h4>Judgement forms</h4>
-
-Rules in a GF grammar are called <b>judgements</b>, and the keywords
-<tt>fun</tt> and <tt>lin</tt> are used for distinguishing between two
-<b>judgement forms</b>. Here is a summary of the most important
+</P>
+<PRE>
+ fun PredVP : NP -&gt; VP -&gt; S ;
+ lin PredVP x y = {s = x.s ++ y.s} ;
+</PRE>
+<P>
+The former rule, with the keyword <CODE>fun</CODE>, belongs to the abstract syntax.
+It defines the <B>function</B>
+<CODE>PredVP</CODE> which constructs syntax trees of form
+(<CODE>PredVP</CODE> &lt;i&gt;x&lt;i&gt; &lt;i&gt;y&lt;i&gt;).
+</P>
+<P>
+The latter rule, with the keyword <CODE>lin</CODE>, belongs to the concrete syntax.
+It defines the <B>linearization function</B> for
+syntax trees of form (<CODE>PredVP</CODE> &lt;i&gt;x&lt;i&gt; &lt;i&gt;y&lt;i&gt;).
+</P>
+<P>
+&lt;h4&gt;Judgement forms&lt;h4&gt;
+</P>
+<P>
+Rules in a GF grammar are called <B>judgements</B>, and the keywords
+<CODE>fun</CODE> and <CODE>lin</CODE> are used for distinguishing between two
+<B>judgement forms</B>. Here is a summary of the most important
judgement forms:
-<ul>
- <li> abstract syntax
- <p>
- <table>
- <tr> <td>form </td><td>reading </td></tr>
- <tr> <td><tt>cat</tt> C</td><td>C is a category</td></tr>
- <tr> <td><tt>fun</tt> f <tt>:</tt> A</td><td>f is a function of type A</td></tr>
- </table>
- <li> concrete syntax
- <p>
- <table>
- <tr> <td>form </td><td>reading </td></tr>
- <tr> <td><tt>lincat</tt> C <tt>=</tt> T</td><td>category C has linearization type T</td></tr>
- <tr> <td><tt>lin</tt> f <tt>=</tt> t</td><td>function f has linearization t</td></tr>
- </table>
- </ul>
+</P>
+ <UL>
+ <LI>abstract syntax
+ <P></P>
+ </UL>
+
+<TABLE ALIGN="center" CELLPADDING="4" BORDER="1">
+<TR>
+<TD>form</TD>
+<TD>reading</TD>
+</TR>
+<TR>
+<TD><CODE>cat</CODE> C</TD>
+<TD>C is a category</TD>
+</TR>
+<TR>
+<TD><CODE>fun</CODE> f <CODE>:</CODE> A</TD>
+<TD>f is a function of type A</TD>
+</TR>
+</TABLE>
+
+<P></P>
+ <UL>
+ <LI>concrete syntax
+ <P></P>
+ </UL>
+
+<TABLE ALIGN="center" CELLPADDING="4" BORDER="1">
+<TR>
+<TD>form</TD>
+<TD>reading</TD>
+</TR>
+<TR>
+<TD><CODE>lincat</CODE> C <CODE>=</CODE> T</TD>
+<TD>category C has linearization type T</TD>
+</TR>
+<TR>
+<TD><CODE>lin</CODE> f <CODE>=</CODE> t</TD>
+<TD>function f has linearization t</TD>
+</TR>
+</TABLE>
+
+<P></P>
+<P>
We return to the precise meanings of these judgement forms later.
First we will look at how judgements are grouped into modules, and
-show how the grammar <tt>paleolithic.cf</tt> is
+show how the grammar <CODE>paleolithic.cf</CODE> is
expressed by using modules and judgements.
-
-
-<!-- NEW -->
-<h4>Module types</h4>
-
-A GF grammar consists of <b>modules</b>,
+</P>
+<P>
+&lt;h4&gt;Module types&lt;h4&gt;
+</P>
+<P>
+A GF grammar consists of <B>modules</B>,
into which judgements are grouped. The most important
module forms are
-<ul>
- <li> <tt>abstract</tt> A = M</tt>, abstract syntax A with judgements in
+</P>
+ <UL>
+ <LI><CODE>abstract</CODE> A = M``, abstract syntax A with judgements in
the module body M.
- <li> <tt>concrete</tt> C <tt>of</tt> A = M</tt>, concrete syntax C of the
+ <LI><CODE>concrete</CODE> C <CODE>of</CODE> A = M``, concrete syntax C of the
abstract syntax A, with judgements in the module body M.
-</ul>
-
-
-<!-- NEW -->
-<h4>Record types, records, and <tt>Str</tt>s</h4>
-
-The linearization type of a category is a <b>record type</b>, with
-zero of more <b>fields</b> of different types. The simplest record
+ </UL>
+
+<P>
+&lt;h4&gt;Record types, records, and <CODE>Str</CODE>s&lt;h4&gt;
+</P>
+<P>
+The linearization type of a category is a <B>record type</B>, with
+zero of more <B>fields</B> of different types. The simplest record
type used for linearization in GF is
-<pre>
- {s : Str}
-</pre>
-which has one field, with <b>label</b> <tt>s</tt> and type <tt>Str</tt>.
-
-<p>
-
+</P>
+<PRE>
+ {s : Str}
+</PRE>
+<P>
+which has one field, with <B>label</B> <CODE>s</CODE> and type <CODE>Str</CODE>.
+</P>
+<P>
Examples of records of this type are
-<pre>
- [s = "foo"}
- [s = "hello" ++ "world"}
-</pre>
-The type <tt>Str</tt> is really the type of <b>token lists</b>, but
+</P>
+<PRE>
+ [s = "foo"}
+ [s = "hello" ++ "world"}
+</PRE>
+<P>
+The type <CODE>Str</CODE> is really the type of <B>token lists</B>, but
most of the time one can conveniently think of it as the type of strings,
denoted by string literals in double quotes.
-
-<p>
-
-Whenever a record <tt>r</tt> of type <tt>{s : Str}</tt> is given,
-<tt>r.s</tt> is an object of type <tt>Str</tt>. This is of course
-a special case of the <b>projection</b> rule, allowing the extraction
+</P>
+<P>
+Whenever a record <CODE>r</CODE> of type <CODE>{s : Str}</CODE> is given,
+<CODE>r.s</CODE> is an object of type <CODE>Str</CODE>. This is of course
+a special case of the <B>projection</B> rule, allowing the extraction
of fields from a record.
-
-
-<!-- NEW -->
-<h4>An abstract syntax example</h4>
-
-Each nonterminal occurring in the grammar <tt>paleolithic.cf</tt> is
-introduced by a <tt>cat</tt> judgement. Each
-rule label is introduced by a <tt>fun</tt> judgement.
-<pre>
-abstract Paleolithic = {
-cat
- S ; NP ; VP ; CN ; A ; V ; TV ;
-fun
- PredVP : NP -> VP -> S ;
- UseV : V -> VP ;
- ComplTV : TV -> NP -> VP ;
- UseA : A -> VP ;
- ModA : A -> CN -> CN ;
- This, That, Def, Indef : CN -> NP ;
- Boy, Louse, Snake, Worm : CN ;
- Green, Rotten, Thick, Warm : A ;
- Laugh, Sleep, Swim : V ;
- Eat, Kill, Wash : TV ;
-}
-</pre>
+</P>
+<P>
+&lt;h4&gt;An abstract syntax example&lt;h4&gt;
+</P>
+<P>
+Each nonterminal occurring in the grammar <CODE>paleolithic.cf</CODE> is
+introduced by a <CODE>cat</CODE> judgement. Each
+rule label is introduced by a <CODE>fun</CODE> judgement.
+</P>
+<PRE>
+ abstract Paleolithic = {
+ cat
+ S ; NP ; VP ; CN ; A ; V ; TV ;
+ fun
+ PredVP : NP -&gt; VP -&gt; S ;
+ UseV : V -&gt; VP ;
+ ComplTV : TV -&gt; NP -&gt; VP ;
+ UseA : A -&gt; VP ;
+ ModA : A -&gt; CN -&gt; CN ;
+ This, That, Def, Indef : CN -&gt; NP ;
+ Boy, Louse, Snake, Worm : CN ;
+ Green, Rotten, Thick, Warm : A ;
+ Laugh, Sleep, Swim : V ;
+ Eat, Kill, Wash : TV ;
+ }
+</PRE>
+<P>
Notice the use of shorthands permitting the sharing of
the keyword in subsequent judgements, and of the type
-in subsequent <tt>fun</tt> judgements.
-
-
-<!-- NEW -->
-<h4>A concrete syntax example</h4>
-
-Each category introduced in <tt>Paleolithic.gf</tt> is
-given a <tt>lincat</tt> rule, and each
-function is given a <tt>fun</tt> rule. Similar shorthands
-apply as in <tt>abstract</tt> modules.
-<pre>
-concrete PaleolithicEng of Paleolithic = {
-lincat
- S, NP, VP, CN, A, V, TV = {s : Str} ;
-lin
- PredVP np vp = {s = np.s ++ vp.s} ;
- UseV v = v ;
- ComplTV tv np = {s = tv.s ++ np.s} ;
- UseA a = {s = "is" ++ a.s} ;
- This cn = {s = "this" ++ cn.s} ;
- That cn = {s = "that" ++ cn.s} ;
- Def cn = {s = "the" ++ cn.s} ;
- Indef cn = {s = "a" ++ cn.s} ;
- ModA a cn = {s = a.s ++ cn.s} ;
- Boy = {s = "boy"} ;
- Louse = {s = "louse"} ;
- Snake = {s = "snake"} ;
- Worm = {s = "worm"} ;
- Green = {s = "green"} ;
- Rotten = {s = "rotten"} ;
- Thick = {s = "thick"} ;
- Warm = {s = "warm"} ;
- Laugh = {s = "laughs"} ;
- Sleep = {s = "sleeps"} ;
- Swim = {s = "swims"} ;
- Eat = {s = "eats"} ;
- Kill = {s = "kills"} ;
- Wash = {s = "washes"} ;
-}
-</pre>
-
-
-<!-- NEW -->
-<h4>Modules and files</h4>
-
-Module name + <tt>.gf</tt> = file name
-
-<p>
-
-Each module is compiled into a <tt>.gfc</tt> file.
-
-<p>
-
-Import <tt>PaleolithicEng.gf</tt> and try what happens
-<pre>
- > i PaleolithicEng.gf
-</pre>
+in subsequent <CODE>fun</CODE> judgements.
+</P>
+<P>
+&lt;h4&gt;A concrete syntax example&lt;h4&gt;
+</P>
+<P>
+Each category introduced in <CODE>Paleolithic.gf</CODE> is
+given a <CODE>lincat</CODE> rule, and each
+function is given a <CODE>fun</CODE> rule. Similar shorthands
+apply as in <CODE>abstract</CODE> modules.
+</P>
+<PRE>
+ concrete PaleolithicEng of Paleolithic = {
+ lincat
+ S, NP, VP, CN, A, V, TV = {s : Str} ;
+ lin
+ PredVP np vp = {s = np.s ++ vp.s} ;
+ UseV v = v ;
+ ComplTV tv np = {s = tv.s ++ np.s} ;
+ UseA a = {s = "is" ++ a.s} ;
+ This cn = {s = "this" ++ cn.s} ;
+ That cn = {s = "that" ++ cn.s} ;
+ Def cn = {s = "the" ++ cn.s} ;
+ Indef cn = {s = "a" ++ cn.s} ;
+ ModA a cn = {s = a.s ++ cn.s} ;
+ Boy = {s = "boy"} ;
+ Louse = {s = "louse"} ;
+ Snake = {s = "snake"} ;
+ Worm = {s = "worm"} ;
+ Green = {s = "green"} ;
+ Rotten = {s = "rotten"} ;
+ Thick = {s = "thick"} ;
+ Warm = {s = "warm"} ;
+ Laugh = {s = "laughs"} ;
+ Sleep = {s = "sleeps"} ;
+ Swim = {s = "swims"} ;
+ Eat = {s = "eats"} ;
+ Kill = {s = "kills"} ;
+ Wash = {s = "washes"} ;
+ }
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Modules and files&lt;h4&gt;
+</P>
+<P>
+Module name + <CODE>.gf</CODE> = file name
+</P>
+<P>
+Each module is compiled into a <CODE>.gfc</CODE> file.
+</P>
+<P>
+Import <CODE>PaleolithicEng.gf</CODE> and try what happens
+</P>
+<PRE>
+ &gt; i PaleolithicEng.gf
+</PRE>
+<P>
The GF program does not only read the file
-<tt>PaleolithicEng.gf</tt>, but also all other files that it
-depends on - in this case, <tt>Paleolithic.gf</tt>.
-
-<p>
-
-For each file that is compiled, a <tt>.gfc</tt> file
+<CODE>PaleolithicEng.gf</CODE>, but also all other files that it
+depends on - in this case, <CODE>Paleolithic.gf</CODE>.
+</P>
+<P>
+For each file that is compiled, a <CODE>.gfc</CODE> file
is generated. The GFC format (="GF Canonical") is the
"machine code" of GF, which is faster to process than
GF source files. When reading a module, GF knows whether
-to use an existing <tt>.gfc</tt> file or to generate
+to use an existing <CODE>.gfc</CODE> file or to generate
a new one, by looking at modification times.
-
-
-
-<!-- NEW -->
-<h4>Multilingual grammar</h4>
-
+</P>
+<P>
+&lt;h4&gt;Multilingual grammar&lt;h4&gt;
+</P>
+<P>
The main advantage of separating abstract from concrete syntax is that
one abstract syntax can be equipped with many concrete syntaxes.
-A system with this property is called a <b>multilingual grammar</b>.
-
-<p>
-
+A system with this property is called a <B>multilingual grammar</B>.
+</P>
+<P>
Multilingual grammars can be used for applications such as
translation. Let us buid an Italian concrete syntax for
-<tt>Paleolithic</tt> and then test the resulting
+<CODE>Paleolithic</CODE> and then test the resulting
multilingual grammar.
-
-
-
-
-<!-- NEW -->
-<h4>An Italian concrete syntax</h4>
-
-<pre>
-concrete PaleolithicIta of Paleolithic = {
-lincat
- S, NP, VP, CN, A, V, TV = {s : Str} ;
-lin
- PredVP np vp = {s = np.s ++ vp.s} ;
- UseV v = v ;
- ComplTV tv np = {s = tv.s ++ np.s} ;
- UseA a = {s = "è" ++ a.s} ;
- This cn = {s = "questo" ++ cn.s} ;
- That cn = {s = "quello" ++ cn.s} ;
- Def cn = {s = "il" ++ cn.s} ;
- Indef cn = {s = "un" ++ cn.s} ;
- ModA a cn = {s = cn.s ++ a.s} ;
- Boy = {s = "ragazzo"} ;
- Louse = {s = "pidocchio"} ;
- Snake = {s = "serpente"} ;
- Worm = {s = "verme"} ;
- Green = {s = "verde"} ;
- Rotten = {s = "marcio"} ;
- Thick = {s = "grosso"} ;
- Warm = {s = "caldo"} ;
- Laugh = {s = "ride"} ;
- Sleep = {s = "dorme"} ;
- Swim = {s = "nuota"} ;
- Eat = {s = "mangia"} ;
- Kill = {s = "uccide"} ;
- Wash = {s = "lava"} ;
-}
-</pre>
-
-<!-- NEW -->
-<h4>Using a multilingual grammar</h4>
-
+</P>
+<P>
+&lt;h4&gt;An Italian concrete syntax&lt;h4&gt;
+</P>
+<PRE>
+ concrete PaleolithicIta of Paleolithic = {
+ lincat
+ S, NP, VP, CN, A, V, TV = {s : Str} ;
+ lin
+ PredVP np vp = {s = np.s ++ vp.s} ;
+ UseV v = v ;
+ ComplTV tv np = {s = tv.s ++ np.s} ;
+ UseA a = {s = "è" ++ a.s} ;
+ This cn = {s = "questo" ++ cn.s} ;
+ That cn = {s = "quello" ++ cn.s} ;
+ Def cn = {s = "il" ++ cn.s} ;
+ Indef cn = {s = "un" ++ cn.s} ;
+ ModA a cn = {s = cn.s ++ a.s} ;
+ Boy = {s = "ragazzo"} ;
+ Louse = {s = "pidocchio"} ;
+ Snake = {s = "serpente"} ;
+ Worm = {s = "verme"} ;
+ Green = {s = "verde"} ;
+ Rotten = {s = "marcio"} ;
+ Thick = {s = "grosso"} ;
+ Warm = {s = "caldo"} ;
+ Laugh = {s = "ride"} ;
+ Sleep = {s = "dorme"} ;
+ Swim = {s = "nuota"} ;
+ Eat = {s = "mangia"} ;
+ Kill = {s = "uccide"} ;
+ Wash = {s = "lava"} ;
+ }
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Using a multilingual grammar&lt;h4&gt;
+</P>
+<P>
Import without first emptying
-<pre>
- > i PaleolithicEng.gf
- > i PaleolithicIta.gf
-</pre>
+</P>
+<PRE>
+ &gt; i PaleolithicEng.gf
+ &gt; i PaleolithicIta.gf
+</PRE>
+<P>
Try generation now:
-<pre>
- > gr | l
- un pidocchio uccide questo ragazzo
-
- > gr | l -lang=PaleolithicEng
- that louse eats a louse
-</pre>
+</P>
+<PRE>
+ &gt; gr | l
+ un pidocchio uccide questo ragazzo
+
+ &gt; gr | l -lang=PaleolithicEng
+ that louse eats a louse
+</PRE>
+<P>
Translate by using a pipe:
-<pre>
- > p -lang=PaleolithicEng "the boy eats the snake" | l -lang=PaleolithicIta
- il ragazzo mangia il serpente
-</pre>
-
-
-
-<!-- NEW -->
-<h4>Translation quiz</h4>
-
+</P>
+<PRE>
+ &gt; p -lang=PaleolithicEng "the boy eats the snake" | l -lang=PaleolithicIta
+ il ragazzo mangia il serpente
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Translation quiz&lt;h4&gt;
+</P>
+<P>
This is a simple language exercise that can be automatically
generated from a multilingual grammar. The system generates a set of
random sentence, displays them in one language, and checks the user's
-answer given in another language. The command <tt>translation_quiz = tq</tt>
+answer given in another language. The command <CODE>translation_quiz = tq</CODE>
makes this in a subshell of GF.
-<pre>
- > translation_quiz PaleolithicEng PaleolithicIta
-
- Welcome to GF Translation Quiz.
- The quiz is over when you have done at least 10 examples
- with at least 75 % success.
- You can interrupt the quiz by entering a line consisting of a dot ('.').
-
- a green boy washes the louse
- un ragazzo verde lava il gatto
-
- No, not un ragazzo verde lava il gatto, but
- un ragazzo verde lava il pidocchio
- Score 0/1
-</pre>
+</P>
+<PRE>
+ &gt; translation_quiz PaleolithicEng PaleolithicIta
+
+ Welcome to GF Translation Quiz.
+ The quiz is over when you have done at least 10 examples
+ with at least 75 % success.
+ You can interrupt the quiz by entering a line consisting of a dot ('.').
+
+ a green boy washes the louse
+ un ragazzo verde lava il gatto
+
+ No, not un ragazzo verde lava il gatto, but
+ un ragazzo verde lava il pidocchio
+ Score 0/1
+</PRE>
+<P>
You can also generate a list of translation exercises and save it in a
-file for later use, by the command <tt>translation_list = tl</tt>
-<pre>
- > translation_list -number=25 PaleolithicEng PaleolithicIta
-</pre>
+file for later use, by the command <CODE>translation_list = tl</CODE>
+</P>
+<PRE>
+ &gt; translation_list -number=25 PaleolithicEng PaleolithicIta
+</PRE>
+<P>
The number flag gives the number of sentences generated.
-
-
-<!-- NEW -->
-<h4>The multilingual shell state</h4>
-
+</P>
+<P>
+&lt;h4&gt;The multilingual shell state&lt;h4&gt;
+</P>
+<P>
A GF shell is at any time in a state, which
contains a multilingual grammar. One of the concrete
syntaxes is the "main" one, which means that parsing and linearization
are performed by using it. By default, the main concrete syntax is the
-last-imported one. As we saw on previous slide, the <tt>lang</tt> flag
+last-imported one. As we saw on previous slide, the <CODE>lang</CODE> flag
can be used to change the linearization and parsing grammar.
-
-<p>
-
+</P>
+<P>
To see what the multilingual grammar is (as well as some other
things), you can use the command
-<tt>print_options = po</tt>:
-<pre>
- > print_options
- main abstract : Paleolithic
- main concrete : PaleolithicIta
- all concretes : PaleolithicIta PaleolithicEng
-</pre>
-
-
-<!-- NEW -->
-<h4>Extending a grammar</h4>
-
-The module system of GF makes it possible to <b>extend</b> a
+<CODE>print_options = po</CODE>:
+</P>
+<PRE>
+ &gt; print_options
+ main abstract : Paleolithic
+ main concrete : PaleolithicIta
+ all concretes : PaleolithicIta PaleolithicEng
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Extending a grammar&lt;h4&gt;
+</P>
+<P>
+The module system of GF makes it possible to <B>extend</B> a
grammar in different ways. The syntax of extension is
shown by the following example.
-<pre>
- abstract Neolithic = Paleolithic ** {
- fun
- Fire, Wheel : CN ;
- Think : V ;
- }
-</pre>
+</P>
+<PRE>
+ abstract Neolithic = Paleolithic ** {
+ fun
+ Fire, Wheel : CN ;
+ Think : V ;
+ }
+</PRE>
+<P>
Parallel to the abstract syntax, extensions can
be built for concrete syntaxes:
-<pre>
- concrete NeolithicEng of Neolithic = PaleolithicEng ** {
- lin
- Fire = {s = "fire"} ;
- Wheel = {s = "wheel"} ;
- Think = {s = "thinks"} ;
- }
-</pre>
+</P>
+<PRE>
+ concrete NeolithicEng of Neolithic = PaleolithicEng ** {
+ lin
+ Fire = {s = "fire"} ;
+ Wheel = {s = "wheel"} ;
+ Think = {s = "thinks"} ;
+ }
+</PRE>
+<P>
The effect of extension is that all of the contents of the extended
and extending module are put together.
-
-
-
-<!-- NEW -->
-<h4>Multiple inheritance</h4>
-
+</P>
+<P>
+&lt;h4&gt;Multiple inheritance&lt;h4&gt;
+</P>
+<P>
Specialized vocabularies can be represented as small grammars that
only do "one thing" each, e.g.
-<pre>
- abstract Fish = {
- cat Fish ;
- fun Salmon, Perch : Fish ;
- }
-
- abstract Mushrooms = {
- cat Mushroom ;
- fun Cep, Agaric : Mushroom ;
- }
-</pre>
+</P>
+<PRE>
+ abstract Fish = {
+ cat Fish ;
+ fun Salmon, Perch : Fish ;
+ }
+
+ abstract Mushrooms = {
+ cat Mushroom ;
+ fun Cep, Agaric : Mushroom ;
+ }
+</PRE>
+<P>
They can afterwards be combined into bigger grammars by using
-<b>multiple inheritance</b>, i.e. extension of several grammars at the
+<B>multiple inheritance</B>, i.e. extension of several grammars at the
same time:
-<pre>
- abstract Gatherer = Paleolithic, Fish, Mushrooms ** {
- fun
- UseFish : Fish -> CN ;
- UseMushroom : Mushroom -> CN ;
- }
-</pre>
-
-
-
-<!-- NEW -->
-<h4>Visualizing module structure</h4>
-
+</P>
+<PRE>
+ abstract Gatherer = Paleolithic, Fish, Mushrooms ** {
+ fun
+ UseFish : Fish -&gt; CN ;
+ UseMushroom : Mushroom -&gt; CN ;
+ }
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Visualizing module structure&lt;h4&gt;
+</P>
+<P>
When you have created all the abstract syntaxes and
-one set of concrete syntaxes needed for <tt>Gatherer</tt>,
+one set of concrete syntaxes needed for <CODE>Gatherer</CODE>,
your grammar consists of eight GF modules. To see how their
dependences look like, you can use the command
-<tt>visualize_graph = vg</tt>,
-<pre>
- > visualize_graph
-</pre>
+<CODE>visualize_graph = vg</CODE>,
+</P>
+<PRE>
+ &gt; visualize_graph
+</PRE>
+<P>
and the graph will pop up in a separate window. It can also
-be printed out into a file, e.g. a <tt>.gif</tt> file that
+be printed out into a file, e.g. a <CODE>.gif</CODE> file that
can be included in an HTML document
-<pre>
- > pm -printer=graph | wf Gatherer.dot
- > ! dot -Tgif Gatherer.dot > Gatherer.gif
-</pre>
+</P>
+<PRE>
+ &gt; pm -printer=graph | wf Gatherer.dot
+ &gt; ! dot -Tgif Gatherer.dot &gt; Gatherer.gif
+</PRE>
+<P>
The latter command is a Unix command, issued from GF by using the
-shell escape symbol <tt>!</tt>. The resulting graph is shown in the next section.
-
-<p>
-
-The command <tt>print_multi = pm</tt> is used for printing the current multilingual
-grammar in various formats, of which the format <tt>-printer=graph</tt> just
+shell escape symbol <CODE>!</CODE>. The resulting graph is shown in the next section.
+</P>
+<P>
+The command <CODE>print_multi = pm</CODE> is used for printing the current multilingual
+grammar in various formats, of which the format <CODE>-printer=graph</CODE> just
shows the module dependencies.
-
-
-<!-- NEW -->
-<h4>The module structure of <tt>GathererEng</tt></h4>
-
+</P>
+<P>
+&lt;h4&gt;The module structure of <CODE>GathererEng</CODE>&lt;h4&gt;
+</P>
+<P>
The graph uses
-<ul>
-<li> oval boxes for abstract modules
-<li> square boxes for concrete modules
-<li> black-headed arrows for inheritance
-<li> white-headed arrows for the concrete-of-abstract relation
-</ul>
-
-<p>
-
-<img src="Gatherer.gif">
-
-
-<!-- NEW -->
-<h3>Resource modules</h3>
-
+</P>
+<UL>
+<LI>oval boxes for abstract modules
+<LI>square boxes for concrete modules
+<LI>black-headed arrows for inheritance
+<LI>white-headed arrows for the concrete-of-abstract relation
+</UL>
+
+<P>
+&lt;img src="Gatherer.gif"&gt;
+</P>
+<A NAME="toc14"></A>
+<H3>Resource modules</H3>
+<P>
Suppose we want to say, with the vocabulary included in
-<tt>Paleolithic.gf</tt>, things like
-<pre>
- the boy eats two snakes
- all boys sleep
-</pre>
+<CODE>Paleolithic.gf</CODE>, things like
+</P>
+<PRE>
+ the boy eats two snakes
+ all boys sleep
+</PRE>
+<P>
The new grammatical facility we need are the plural forms
-of nouns and verbs (<i>boys, sleep</i>), as opposed to their
+of nouns and verbs (&lt;i&gt;boys, sleep&lt;i&gt;), as opposed to their
singular forms.
-
-<p>
-
+</P>
+<P>
The introduction of plural forms requires two things:
-<ul>
-<li> to <b>inflect</b> nouns and verbs in singular and plural number
-<li> to describe the <b>agreement</b> of the verb to subject: the
+</P>
+<UL>
+<LI>to <B>inflect</B> nouns and verbs in singular and plural number
+<LI>to describe the <B>agreement</B> of the verb to subject: the
rule that the verb must have the same number as the subject
-</ul>
+</UL>
+
+<P>
Different languages have different rules of inflection and agreement.
For instance, Italian has also agreement in gender (masculine vs. feminine).
We want to express such special features of languages precisely in
concrete syntax while ignoring them in abstract syntax.
-
-<p>
-
+</P>
+<P>
To be able to do all this, we need two new judgement forms,
a new module form, and a generalizarion of linearization types
from strings to more complex types.
-
-
-<!-- NEW -->
-<h4>Parameters and tables</h4>
-
-We define the <b>parameter type</b> of number in Englisn by
+</P>
+<P>
+&lt;h4&gt;Parameters and tables&lt;h4&gt;
+</P>
+<P>
+We define the <B>parameter type</B> of number in Englisn by
using a new form of judgement:
-<pre>
- param Number = Sg | Pl ;
-</pre>
+</P>
+<PRE>
+ param Number = Sg | Pl ;
+</PRE>
+<P>
To express that nouns in English have a linearization
-depending on number, we replace the linearization type <tt>{s : Str}</tt>
-with a type where the <tt>s</tt> field is a <b>table</b> depending on number:
-<pre>
- lincat CN = {s : Number => Str} ;
-</pre>
-The <b>table type</b> <tt>Number => Str</tt> is in many respects similar to
-a function type (<tt>Number -> Str</tt>). The main restriction is that the
+depending on number, we replace the linearization type <CODE>{s : Str}</CODE>
+with a type where the <CODE>s</CODE> field is a <B>table</B> depending on number:
+</P>
+<PRE>
+ lincat CN = {s : Number =&gt; Str} ;
+</PRE>
+<P>
+The <B>table type</B> <CODE>Number =&gt; Str</CODE> is in many respects similar to
+a function type (<CODE>Number -&gt; Str</CODE>). The main restriction is that the
argument type of a table type must always be a parameter type. This means
that the argument-value pairs can be listed in a finite table. The following
example shows such a table:
-<pre>
- lin Boy = {s = table {
- Sg => "boy" ;
- Pl => "boys"
- }
- } ;
-</pre>
-The application of a table to a parameter is done by the <b>selection</b>
-operator <tt>!</tt>. For instance,
-<pre>
- Boy.s ! Pl
-</pre>
-is a selection, whose value is <tt>"boys"</tt>.
-
-
-<!-- NEW -->
-<h4>Inflection tables, paradigms, and <tt>oper</tt> definitions</h4>
-
+</P>
+<PRE>
+ lin Boy = {s = table {
+ Sg =&gt; "boy" ;
+ Pl =&gt; "boys"
+ }
+ } ;
+</PRE>
+<P>
+The application of a table to a parameter is done by the <B>selection</B>
+operator <CODE>!</CODE>. For instance,
+</P>
+<PRE>
+ Boy.s ! Pl
+</PRE>
+<P>
+is a selection, whose value is <CODE>"boys"</CODE>.
+</P>
+<P>
+&lt;h4&gt;Inflection tables, paradigms, and <CODE>oper</CODE> definitions&lt;h4&gt;
+</P>
+<P>
All English common nouns are inflected in number, most of them in the
same way: the plural form is formed from the singular form by adding the
-ending <i>s</i>. This rule is an example of
-a <b>paradigm</b> - a formula telling how the inflection
+ending &lt;i&gt;s&lt;i&gt;. This rule is an example of
+a <B>paradigm</B> - a formula telling how the inflection
forms of a word are formed.
-
-<p>
-
-From GF point of view, a paradigm is a function that takes a <b>lemma</b> -
-a string also known as a <b>dictionary form</b> - and returns an inflection
+</P>
+<P>
+From GF point of view, a paradigm is a function that takes a <B>lemma</B> -
+a string also known as a <B>dictionary form</B> - and returns an inflection
table of desired type. Paradigms are not functions in the sense of the
-<tt>fun</tt> judgements of abstract syntax (which operate on trees and not
-on strings). Thus we call them <b>operations</b> for the sake of clarity,
-introduce one one form of judgement, with the keyword <tt>oper</tt>. As an
+<CODE>fun</CODE> judgements of abstract syntax (which operate on trees and not
+on strings). Thus we call them <B>operations</B> for the sake of clarity,
+introduce one one form of judgement, with the keyword <CODE>oper</CODE>. As an
example, the following operation defines the regular noun paradigm of English:
-<pre>
- oper regNoun : Str -> {s : Number => Str} = \x -> {
- s = table {
- Sg => x ;
- Pl => x + "s"
- }
- } ;
-</pre>
-Thus an <tt>oper</tt> judgement includes the name of the defined operation,
+</P>
+<PRE>
+ oper regNoun : Str -&gt; {s : Number =&gt; Str} = \x -&gt; {
+ s = table {
+ Sg =&gt; x ;
+ Pl =&gt; x + "s"
+ }
+ } ;
+</PRE>
+<P>
+Thus an <CODE>oper</CODE> judgement includes the name of the defined operation,
its type, and an expression defining it. As for the syntax of the defining
-expression, notice the <b>lambda abstraction</b> form <tt>\x -> t</tt> of
-the function, and the <b>glueing</b> operator <tt>+</tt> telling that
-the string held in the variable <tt>x</tt> and the ending <tt>"s"</tt>
-are written together to form one <b>token</b>.
-
-
-<!-- NEW -->
-<h4>The <tt>resource</tt> module type</h4>
-
+expression, notice the <B>lambda abstraction</B> form <CODE>\x -&gt; t</CODE> of
+the function, and the <B>glueing</B> operator <CODE>+</CODE> telling that
+the string held in the variable <CODE>x</CODE> and the ending <CODE>"s"</CODE>
+are written together to form one <B>token</B>.
+</P>
+<P>
+&lt;h4&gt;The <CODE>resource</CODE> module type&lt;h4&gt;
+</P>
+<P>
Parameter and operator definitions do not belong to the abstract syntax.
They can be used when defining concrete syntax - but they are not
tied to a particular set of linearization rules.
-The proper way to see them is as auxiliary concepts, as <b>resources</b>
+The proper way to see them is as auxiliary concepts, as <B>resources</B>
usable in many concrete syntaxes.
-
-<p>
-
-The <tt>resource</tt> module type thus consists of
-<tt>param</tt> and <tt>oper</tt> definitions. Here is an
+</P>
+<P>
+The <CODE>resource</CODE> module type thus consists of
+<CODE>param</CODE> and <CODE>oper</CODE> definitions. Here is an
example.
-<pre>
- resource MorphoEng = {
- param
- Number = Sg | Pl ;
- oper
- Noun : Type = {s : Number => Str} ;
- regNoun : Str -> Noun = \x -> {
- s = table {
- Sg => x ;
- Pl => x + "s"
- }
- } ;
- }
-</pre>
+</P>
+<PRE>
+ resource MorphoEng = {
+ param
+ Number = Sg | Pl ;
+ oper
+ Noun : Type = {s : Number =&gt; Str} ;
+ regNoun : Str -&gt; Noun = \x -&gt; {
+ s = table {
+ Sg =&gt; x ;
+ Pl =&gt; x + "s"
+ }
+ } ;
+ }
+</PRE>
+<P>
Resource modules can extend other resource modules, in the
same way as modules of other types can extend modules of the
same type.
-
-
-
-<!-- NEW -->
-<h3>Opening a <tt>resource</tt></h3>
-
-Any number of <tt>resource</tt> modules can be
-<b>opened</b> in a <tt>concrete</tt> syntax, which
+</P>
+<A NAME="toc15"></A>
+<H3>Opening a ``resource``</H3>
+<P>
+Any number of <CODE>resource</CODE> modules can be
+<B>opened</B> in a <CODE>concrete</CODE> syntax, which
makes the parameter and operation definitions contained
in the resource usable in the concrete syntax. Here is
-an example, where the resource <tt>MorphoEng</tt> is
-open in (the fragment of) a new version of <tt>PaleolithicEng</tt>.
-<pre>
-concrete PaleolithicEng of Paleolithic = open MorphoEng in {
- lincat
- CN = Noun ;
- lin
- Boy = regNoun "boy" ;
- Snake = regNoun "snake" ;
- Worm = regNoun "worm" ;
- }
-</pre>
+an example, where the resource <CODE>MorphoEng</CODE> is
+open in (the fragment of) a new version of <CODE>PaleolithicEng</CODE>.
+</P>
+<PRE>
+ concrete PaleolithicEng of Paleolithic = open MorphoEng in {
+ lincat
+ CN = Noun ;
+ lin
+ Boy = regNoun "boy" ;
+ Snake = regNoun "snake" ;
+ Worm = regNoun "worm" ;
+ }
+</PRE>
+<P>
Notice that, just like in abstract syntax, function application
is written by juxtaposition of the function and the argument.
-
-<p>
-
+</P>
+<P>
Using operations defined in resource modules is clearly a concise
way of giving e.g. inflection tables and other repeated patterns
of expression. In addition, it enables a new kind of modularity
@@ -967,347 +1076,354 @@ the linguistic details of a language can put this knowledge
available through resource grammars, whose users only need
to pick the right operations and not to know their implementation
details.
-
-
-
-<!-- NEW -->
-<h4>Worst-case macros and data abstraction</h4>
-
-Some English nouns, such as <tt>louse</tt>, are so irregular that
+</P>
+<P>
+&lt;h4&gt;Worst-case macros and data abstraction&lt;h4&gt;
+</P>
+<P>
+Some English nouns, such as <CODE>louse</CODE>, are so irregular that
it makes little sense to see them as instances of a paradigm. Even
-then, it is useful to perform <b>data abstraction</b> from the
-definition of the type <tt>Noun</tt>, and introduce a constructor
-operation, a <b>worst-case macro</b> for nouns:
-<pre>
- oper mkNoun : Str -> Str -> Noun = \x,y -> {
- s = table {
- Sg => x ;
- Pl => y
- }
- } ;
-</pre>
+then, it is useful to perform <B>data abstraction</B> from the
+definition of the type <CODE>Noun</CODE>, and introduce a constructor
+operation, a <B>worst-case macro</B> for nouns:
+</P>
+<PRE>
+ oper mkNoun : Str -&gt; Str -&gt; Noun = \x,y -&gt; {
+ s = table {
+ Sg =&gt; x ;
+ Pl =&gt; y
+ }
+ } ;
+</PRE>
+<P>
Thus we define
-<pre>
- lin Louse = mkNoun "louse" "lice" ;
-</pre>
+</P>
+<PRE>
+ lin Louse = mkNoun "louse" "lice" ;
+</PRE>
+<P>
instead of writing the inflection table explicitly.
-
-<p>
-
+</P>
+<P>
The grammar engineering advantage of worst-case macros is that
the author of the resource module may change the definitions of
-<tt>Noun</tt> and <tt>mkNoun</tt>, and still retain the
+<CODE>Noun</CODE> and <CODE>mkNoun</CODE>, and still retain the
interface (i.e. the system of type signatures) that makes it
correct to use these functions in concrete modules. In programming
-terms, <tt>Noun</tt> is then treated as an <b>abstract datatype</b>.
-
-
-
-<!-- NEW -->
-<h4>A system of paradigms using <tt>Prelude</tt> operations</h4>
-
-The regular noun paradigm <tt>regNoun</tt> can - and should - of course be defined
-by the worst-case macro <tt>mkNoun</tt>. In addition, some more noun paradigms
+terms, <CODE>Noun</CODE> is then treated as an <B>abstract datatype</B>.
+</P>
+<P>
+&lt;h4&gt;A system of paradigms using <CODE>Prelude</CODE> operations&lt;h4&gt;
+</P>
+<P>
+The regular noun paradigm <CODE>regNoun</CODE> can - and should - of course be defined
+by the worst-case macro <CODE>mkNoun</CODE>. In addition, some more noun paradigms
could be defined, for instance,
-<pre>
- regNoun : Str -> Noun = \snake -> mkNoun snake (snake + "s") ;
- sNoun : Str -> Noun = \kiss -> mkNoun kiss (kiss + "es") ;
-</pre>
-What about nouns like <i>fly</i>, with the plural <i>flies</i>? The already
-available solution is to use the so-called "technical stem" <i>fl</i> as
+</P>
+<PRE>
+ regNoun : Str -&gt; Noun = \snake -&gt; mkNoun snake (snake + "s") ;
+ sNoun : Str -&gt; Noun = \kiss -&gt; mkNoun kiss (kiss + "es") ;
+</PRE>
+<P>
+What about nouns like &lt;i&gt;fly&lt;i&gt;, with the plural &lt;i&gt;flies&lt;i&gt;? The already
+available solution is to use the so-called "technical stem" &lt;i&gt;fl&lt;i&gt; as
argument, and define
-<pre>
- yNoun : Str -> Noun = \fl -> mkNoun (fl + "y") (fl + "ies") ;
-</pre>
+</P>
+<PRE>
+ yNoun : Str -&gt; Noun = \fl -&gt; mkNoun (fl + "y") (fl + "ies") ;
+</PRE>
+<P>
But this paradigm would be very unintuitive to use, because the "technical stem"
is not even an existing form of the word. A better solution is to use
-the string operator <tt>init</tt>, which returns the initial segment (i.e.
+the string operator <CODE>init</CODE>, which returns the initial segment (i.e.
all characters but the last) of a string:
-<pre>
- yNoun : Str -> Noun = \fly -> mkNoun fly (init fly + "ies") ;
-</pre>
-The operator <tt>init</tt> belongs to a set of operations in the
-resource module <tt>Prelude</tt>, which therefore has to be
-<tt>open</tt>ed so that <tt>init</tt> can be used.
-
-
-
-<!-- NEW -->
-<h4>An intelligent noun paradigm using <tt>case</tt> expressions</h4>
-
+</P>
+<PRE>
+ yNoun : Str -&gt; Noun = \fly -&gt; mkNoun fly (init fly + "ies") ;
+</PRE>
+<P>
+The operator <CODE>init</CODE> belongs to a set of operations in the
+resource module <CODE>Prelude</CODE>, which therefore has to be
+<CODE>open</CODE>ed so that <CODE>init</CODE> can be used.
+</P>
+<P>
+&lt;h4&gt;An intelligent noun paradigm using <CODE>case</CODE> expressions&lt;h4&gt;
+</P>
+<P>
It may be hard for the user of a resource morphology to pick the right
inflection paradigm. A way to help this is to define a more intelligent
paradigms, which chooses the ending by first analysing the lemma.
The following variant for English regular nouns puts together all the
previously shown paradigms, and chooses one of them on the basis of
the final letter of the lemma.
-<pre>
- regNoun : Str -> Noun = \s -> case last s of {
- "s" | "z" => mkNoun s (s + "es") ;
- "y" => mkNoun s (init s + "ies") ;
- _ => mkNoun s (s + "s")
- } ;
-</pre>
+</P>
+<PRE>
+ regNoun : Str -&gt; Noun = \s -&gt; case last s of {
+ "s" | "z" =&gt; mkNoun s (s + "es") ;
+ "y" =&gt; mkNoun s (init s + "ies") ;
+ _ =&gt; mkNoun s (s + "s")
+ } ;
+</PRE>
+<P>
This definition displays many GF expression forms not shown befores;
these forms are explained in the following section.
-
-<p>
-
-The paradigms <tt>regNoun</tt> does not give the correct forms for
-all nouns. For instance, <i>louse - lice</i> and
-<i>fish - fish</i> must be given by using <tt>mkNoun</tt>.
-Also the word <i>boy</i> would be inflected incorrectly; to prevent
-this, either use <tt>mkNoun</tt> or modify
-<tt>regNoun</tt> so that the <tt>"y"</tt> case does not
+</P>
+<P>
+The paradigms <CODE>regNoun</CODE> does not give the correct forms for
+all nouns. For instance, &lt;i&gt;louse - lice&lt;i&gt; and
+&lt;i&gt;fish - fish&lt;i&gt; must be given by using <CODE>mkNoun</CODE>.
+Also the word &lt;i&gt;boy&lt;i&gt; would be inflected incorrectly; to prevent
+this, either use <CODE>mkNoun</CODE> or modify
+<CODE>regNoun</CODE> so that the <CODE>"y"</CODE> case does not
apply if the second-last character is a vowel.
-
-
-
-<!-- NEW -->
-<h4>Pattern matching</h4>
-
-Expressions of the <tt>table</tt> form are built from lists of
-argument-value pairs. These pairs are called the <b>branches</b>
+</P>
+<P>
+&lt;h4&gt;Pattern matching&lt;h4&gt;
+</P>
+<P>
+Expressions of the <CODE>table</CODE> form are built from lists of
+argument-value pairs. These pairs are called the <B>branches</B>
of the table. In addition to constants introduced in
-<tt>param</tt> definitions, the left-hand side of a branch can more
-generally be a <b>pattern</b>, and the computation of selection is
-then performed by <b>pattern matching</b>:
-<ul>
-<li> a variable pattern (identifier other than constant parameter) matches anything
-<li> the wild card <tt>_</tt> matches anything
-<li> a string literal pattern, e.g. <tt>"s"</tt>, matches the same string
-<li> a disjunctive pattern <tt>P | ... | Q</tt> matches anything that
+<CODE>param</CODE> definitions, the left-hand side of a branch can more
+generally be a <B>pattern</B>, and the computation of selection is
+then performed by <B>pattern matching</B>:
+</P>
+<UL>
+<LI>a variable pattern (identifier other than constant parameter) matches anything
+<LI>the wild card <CODE>_</CODE> matches anything
+<LI>a string literal pattern, e.g. <CODE>"s"</CODE>, matches the same string
+<LI>a disjunctive pattern <CODE>P | ... | Q</CODE> matches anything that
one of the disjuncts matches
-</ul>
+</UL>
+
+<P>
Pattern matching is performed in the order in which the branches
appear in the table.
-
-<p>
-
+</P>
+<P>
As syntactic sugar, one-branch tables can be written concisely,
-<pre>
- \\P,...,Q => t === table {P => ... table {Q => t} ...}
-</pre>
-Finally, the <tt>case</tt> expressions common in functional
+</P>
+<PRE>
+ \\P,...,Q =&gt; t === table {P =&gt; ... table {Q =&gt; t} ...}
+</PRE>
+<P>
+Finally, the <CODE>case</CODE> expressions common in functional
programming languages are syntactic sugar for table selections:
-<pre>
- case e of {...} === table {...} ! e
-</pre>
-
-
-
-<!-- NEW -->
-<h4>Morphological analysis and morphology quiz</h4>
-
+</P>
+<PRE>
+ case e of {...} === table {...} ! e
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Morphological analysis and morphology quiz&lt;h4&gt;
+</P>
+<P>
Even though in GF morphology
is mostly seen as an auxiliary of syntax, a morphology once defined
-can be used on its own right. The command <tt>morpho_analyse = ma</tt>
+can be used on its own right. The command <CODE>morpho_analyse = ma</CODE>
can be used to read a text and return for each word the analyses that
it has in the current concrete syntax.
-<pre>
- > rf bible.txt | morpho_analyse
-</pre>
+</P>
+<PRE>
+ &gt; rf bible.txt | morpho_analyse
+</PRE>
+<P>
Similarly to translation exercises, morphological exercises can
-be generated, by the command <tt>morpho_quiz = mq</tt>. Usually,
-the category is set to be something else than <tt>S</tt>. For instance,
-<pre>
- > i lib/resource/french/VerbsFre.gf
- > morpho_quiz -cat=V
-
- Welcome to GF Morphology Quiz.
- ...
-
- réapparaître : VFin VCondit Pl P2
- réapparaitriez
- > No, not réapparaitriez, but
- réapparaîtriez
- Score 0/1
-</pre>
+be generated, by the command <CODE>morpho_quiz = mq</CODE>. Usually,
+the category is set to be something else than <CODE>S</CODE>. For instance,
+</P>
+<PRE>
+ &gt; i lib/resource/french/VerbsFre.gf
+ &gt; morpho_quiz -cat=V
+
+ Welcome to GF Morphology Quiz.
+ ...
+
+ réapparaître : VFin VCondit Pl P2
+ réapparaitriez
+ &gt; No, not réapparaitriez, but
+ réapparaîtriez
+ Score 0/1
+</PRE>
+<P>
Finally, a list of morphological exercises and save it in a
-file for later use, by the command <tt>morpho_list = ml</tt>
-<pre>
- > morpho_list -number=25 -cat=V
-</pre>
+file for later use, by the command <CODE>morpho_list = ml</CODE>
+</P>
+<PRE>
+ &gt; morpho_list -number=25 -cat=V
+</PRE>
+<P>
The number flag gives the number of exercises generated.
-
-
-
-<!-- NEW -->
-<h4>Parametric vs. inherent features, agreement</h4>
-
+</P>
+<P>
+&lt;h4&gt;Parametric vs. inherent features, agreement&lt;h4&gt;
+</P>
+<P>
The rule of subject-verb agreement in English says that the verb
phrase must be inflected in the number of the subject. This
means that a noun phrase (functioning as a subject), in some sense
-<i>has</i> a number, which it "sends" to the verb. The verb does not
+&lt;i&gt;has&lt;i&gt; a number, which it "sends" to the verb. The verb does not
have a number, but must be able to receive whatever number the
subject has. This distinction is nicely represented by the
different linearization types of noun phrases and verb phrases:
-<pre>
- lincat NP = {s : Str ; n : Number} ;
- lincat VP = {s : Number => Str} ;
-</pre>
-We say that the number of <tt>NP</tt> is an <b>inherent feature</b>,
-whereas the number of <tt>NP</tt> is <b>parametric</b>.
-
-<p>
-
+</P>
+<PRE>
+ lincat NP = {s : Str ; n : Number} ;
+ lincat VP = {s : Number =&gt; Str} ;
+</PRE>
+<P>
+We say that the number of <CODE>NP</CODE> is an <B>inherent feature</B>,
+whereas the number of <CODE>NP</CODE> is <B>parametric</B>.
+</P>
+<P>
The agreement rule itself is expressed in the linearization rule of
the predication structure:
-<pre>
- lin PredVP np vp = {s = np.s ++ vp.s ! np.n} ;
-</pre>
+</P>
+<PRE>
+ lin PredVP np vp = {s = np.s ++ vp.s ! np.n} ;
+</PRE>
+<P>
The following page will present a new version of
-<tt>PaleolithingEng</tt>, assuming an abstract syntax
-xextended with <tt>All</tt> and <tt>Two</tt>.
-It also assumes that <tt>MorphoEng</tt> has a paradigm
-<tt>regVerb</tt> for regular verbs (which need only be
+<CODE>PaleolithingEng</CODE>, assuming an abstract syntax
+xextended with <CODE>All</CODE> and <CODE>Two</CODE>.
+It also assumes that <CODE>MorphoEng</CODE> has a paradigm
+<CODE>regVerb</CODE> for regular verbs (which need only be
regular only in the present tensse).
The reader is invited to inspect the way in which agreement works in
the formation of noun phrases and verb phrases.
-
-
-
-<!-- NEW -->
-<h4>English concrete syntax with parameters</h4>
-
-<pre>
-concrete PaleolithicEng of Paleolithic = open MorphoEng in {
-lincat
- S, A = {s : Str} ;
- VP, CN, V, TV = {s : Number => Str} ;
- NP = {s : Str ; n : Number} ;
-lin
- PredVP np vp = {s = np.s ++ vp.s ! np.n} ;
- UseV v = v ;
- ComplTV tv np = {s = \\n => tv.s ! n ++ np.s} ;
- UseA a = {s = \\n => case n of {Sg => "is" ; Pl => "are"} ++ a.s} ;
- This cn = {s = "this" ++ cn.s ! Sg } ;
- Indef cn = {s = "a" ++ cn.s ! Sg} ;
- All cn = {s = "all" ++ cn.s ! Pl} ;
- Two cn = {s = "two" ++ cn.s ! Pl} ;
- ModA a cn = {s = \\n => a.s ++ cn.s ! n} ;
- Louse = mkNoun "louse" "lice" ;
- Snake = regNoun "snake" ;
- Green = {s = "green"} ;
- Warm = {s = "warm"} ;
- Laugh = regVerb "laugh" ;
- Sleep = regVerb "sleep" ;
- Kill = regVerb "kill" ;
-}
-</pre>
-
-
-
-<!-- NEW -->
-<h4>Hierarchic parameter types</h4>
-
+</P>
+<P>
+&lt;h4&gt;English concrete syntax with parameters&lt;h4&gt;
+</P>
+<PRE>
+ concrete PaleolithicEng of Paleolithic = open MorphoEng in {
+ lincat
+ S, A = {s : Str} ;
+ VP, CN, V, TV = {s : Number =&gt; Str} ;
+ NP = {s : Str ; n : Number} ;
+ lin
+ PredVP np vp = {s = np.s ++ vp.s ! np.n} ;
+ UseV v = v ;
+ ComplTV tv np = {s = \\n =&gt; tv.s ! n ++ np.s} ;
+ UseA a = {s = \\n =&gt; case n of {Sg =&gt; "is" ; Pl =&gt; "are"} ++ a.s} ;
+ This cn = {s = "this" ++ cn.s ! Sg } ;
+ Indef cn = {s = "a" ++ cn.s ! Sg} ;
+ All cn = {s = "all" ++ cn.s ! Pl} ;
+ Two cn = {s = "two" ++ cn.s ! Pl} ;
+ ModA a cn = {s = \\n =&gt; a.s ++ cn.s ! n} ;
+ Louse = mkNoun "louse" "lice" ;
+ Snake = regNoun "snake" ;
+ Green = {s = "green"} ;
+ Warm = {s = "warm"} ;
+ Laugh = regVerb "laugh" ;
+ Sleep = regVerb "sleep" ;
+ Kill = regVerb "kill" ;
+ }
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Hierarchic parameter types&lt;h4&gt;
+</P>
+<P>
The reader familiar with a functional programming language such as
-<a href="http://www.haskell.org">Haskell</a> must have noticed the similarity
-between parameter types in GF and algebraic datatypes (<tt>data</tt> definitions
+&lt;a href="<A HREF="http://www.haskell.org">http://www.haskell.org</A>"&gt;Haskell&lt;a&gt; must have noticed the similarity
+between parameter types in GF and algebraic datatypes (<CODE>data</CODE> definitions
in Haskell). The GF parameter types are actually a special case of algebraic
datatypes: the main restriction is that in GF, these types must be finite.
(This restriction makes it possible to invert linearization rules into
parsing methods.)
-
-<p>
-
+</P>
+<P>
However, finite is not the same thing as enumerated. Even in GF, parameter
constructors can take arguments, provided these arguments are from other
parameter types (recursion is forbidden). Such parameter types impose a
hierarchic order among parameters. They are often useful to define
linguistically accurate parameter systems.
-
-<p>
-
+</P>
+<P>
To give an example, Swedish adjectives
are inflected in number (singular or plural) and
gender (uter or neuter). These parameters would suggest 2*2=4 different
forms. However, the gender distinction is done only in the singular. Therefore,
it would be inaccurate to define adjective paradigms using the type
-<tt>Gender => Number => Str</tt>. The following hierarchic definition
+<CODE>Gender =&gt; Number =&gt; Str</CODE>. The following hierarchic definition
yields an accurate system of three adjectival forms.
-<pre>
- param AdjForm = ASg Gender | APl ;
- param Gender = Uter | Neuter ;
-</pre>
+</P>
+<PRE>
+ param AdjForm = ASg Gender | APl ;
+ param Gender = Uter | Neuter ;
+</PRE>
+<P>
In pattern matching, a constructor can have patterns as arguments. For instance,
the adjectival paradigm in which the two singular forms are the same, can be defined
-<pre>
- oper plattAdj : Str -> AdjForm => Str = \x -> table {
- ASg _ => x ;
- APl => x + "a" ;
- }
-</pre>
-
-
-<!-- NEW -->
-<h4>Discontinuous constituents</h4>
-
+</P>
+<PRE>
+ oper plattAdj : Str -&gt; AdjForm =&gt; Str = \x -&gt; table {
+ ASg _ =&gt; x ;
+ APl =&gt; x + "a" ;
+ }
+</PRE>
+<P></P>
+<P>
+&lt;h4&gt;Discontinuous constituents&lt;h4&gt;
+</P>
+<P>
A linearization type may contain more strings than one.
An example of where this is useful are English particle
-verbs, such as <i>switch off</i>. The linearization of
+verbs, such as &lt;i&gt;switch off&lt;i&gt;. The linearization of
a sentence may place the object between the verb and the particle:
-<i>he switched it off</i>.
-
-<p>
-
+&lt;i&gt;he switched it off&lt;i&gt;.
+</P>
+<P>
The first of the following judgements defines transitive verbs as a
-<b>discontinuous constituents</b>, i.e. as having a linearization
+<B>discontinuous constituents</B>, i.e. as having a linearization
type with two strings and not just one. The second judgement
shows how the constituents are separated by the object in complementization.
-<pre>
- lincat TV = {s : Number => Str ; s2 : Str} ;
- lin ComplTV tv obj = {s = \\n => tv.s ! n ++ obj.s ++ tv.s2} ;
-</pre>
-
-<p>
-
+</P>
+<PRE>
+ lincat TV = {s : Number =&gt; Str ; s2 : Str} ;
+ lin ComplTV tv obj = {s = \\n =&gt; tv.s ! n ++ obj.s ++ tv.s2} ;
+</PRE>
+<P></P>
+<P>
GF currently requires that all fields in linearization records that
-have a table with value type <tt>Str</tt> have as labels
-either <tt>s</tt> or <tt>s</tt> with an integer index.
-
-
-
-
-<!-- NEW -->
-<h2>Topics still to be written</h2>
-
-
+have a table with value type <CODE>Str</CODE> have as labels
+either <CODE>s</CODE> or <CODE>s</CODE> with an integer index.
+</P>
+<A NAME="toc16"></A>
+<H2>Topics still to be written</H2>
+<P>
Free variation
-
-<p>
-
+</P>
+<P>
Record extension, tuples
-
-<p>
-
+</P>
+<P>
Predefined types and operations
-
-<p>
-
+</P>
+<P>
Lexers and unlexers
-
-<p>
-
+</P>
+<P>
Grammars of formal languages
-
-<p>
-
+</P>
+<P>
Resource grammars and their reuse
-
-<p>
-
+</P>
+<P>
Embedded grammars in Haskell and Java
-
-<p>
-
+</P>
+<P>
Dependent types, variable bindings, semantic definitions
-
-<p>
-
+</P>
+<P>
Transfer rules
-
-
-
-</body>
-</html> \ No newline at end of file
+</P>
+<P>
+&lt;body&gt;
+&lt;html&gt;
+</P>
+
+<!-- html code generated by txt2tags 2.3 (http://txt2tags.sf.net) -->
+<!-- cmdline: txt2tags -\-toc gf-tutorial2.txt -->
+</BODY></HTML>
diff --git a/doc/tutorial/gf-tutorial2.txt b/doc/tutorial/gf-tutorial2.txt
new file mode 100644
index 000000000..f417968d5
--- /dev/null
+++ b/doc/tutorial/gf-tutorial2.txt
@@ -0,0 +1,1320 @@
+Grammatical Framework Tutorial
+Author: Aarne Ranta <aarne (at) cs.chalmers.se>
+Last update: %%date(%c)
+
+% NOTE: this is a txt2tags file.
+% Create an html file from this file using:
+% txt2tags --toc gf-tutorial2.txt
+
+%!target:html
+
+[../gf-logo.gif]
+
+=Grammatical Framework Tutorial=
+
+
+
+**3rd Edition, for GF version 2.2 or later**
+
+
+
+[Aarne Ranta http://www.cs.chalmers.se/~aarne]
+
+
+``aarne@cs.chalmers.se``
+
+
+
+
+%--!
+==GF = Grammatical Framework==
+
+The term GF is used for different things:
+
+- a **program** used for working with grammars
+- a **programming language** in which grammars can be written
+- a **theory** about grammars and languages
+
+
+
+
+This tutorial is primarily about the GF program and
+the GF programming language.
+It will guide you
+
+- to use the GF program
+- to write GF grammars
+- to write programs in which GF grammars are used as components
+
+
+
+
+%--!
+===Getting the GF program===
+
+The program is open-source free software, which you can download via the
+GF Homepage:
+[``http://www.cs.chalmers.se/~aarne/GF`` http://www.cs.chalmers.se/~aarne/GF]
+
+
+
+There you can download
+
+- ready-made binaries for Linux, Solaris, Macintosh, and Windows
+- source code and documentation
+- grammar libraries and examples
+
+
+
+If you want to compile GF from source, you need Haskell and Java
+compilers. But normally you don't have to compile, and you definitely
+don't need to know Haskell or Java to use GF.
+
+
+
+To start the GF program, assuming you have installed it, just type
+```
+ gf
+```
+in the shell. You will see GF's welcome message and the prompt ``>``.
+
+
+%--!
+==My first grammar==
+
+Now you are ready to try out your first grammar.
+We start with one that is not written in GF language, but
+in the EBNF notation (Extended Backus Naur Form), which GF can also
+understand. Type (or copy) the following lines in a file named
+``paleolithic.ebnf``:
+```
+ S ::= NP VP ;
+ VP ::= V | TV NP | "is" A ;
+ NP ::= ("this" | "that" | "the" | "a") CN ;
+ CN ::= A CN ;
+ CN ::= "boy" | "louse" | "snake" | "worm" ;
+ A ::= "green" | "rotten" | "thick" | "warm" ;
+ V ::= "laughs" | "sleeps" | "swims" ;
+ TV ::= "eats" | "kills" | "washes" ;
+```
+
+
+%--!
+===Importing grammars and parsing strings===
+
+The first GF command when using a grammar is to **import** it.
+The command has a long name, ``import``, and a short name, ``i``.
+```
+ import paleolithic.gf
+```
+The GF program now **compiles** your grammar into an internal
+representation, and shows a new prompt when it is ready.
+
+
+
+You can use GF for **parsing**:
+```
+ > parse "the boy eats a snake"
+ Mks_0 (Mks_6 Mks_9) (Mks_2 Mks_20 (Mks_7 Mks_11))
+
+ > parse "the snake eats a boy"
+ Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
+```
+The ``parse`` (= ``p``) command takes a **string**
+(in double quotes) and returns an **abstract syntax tree** - the thing
+with ``Mks``s and parentheses. We will see soon how to make sense
+of the abstract syntax trees - now you should just notice that the tree
+is different for the two strings.
+
+
+
+Strings that return a tree when parsed do so in virtue of the grammar
+you imported. Try parsing something else, and you fail
+```
+ > p "hello world"
+ No success in cf parsing
+ no tree found
+```
+
+
+%--!
+===Generating trees and strings===
+
+You can also use GF for **linearizing**
+(``linearize = l``). This is the inverse of
+parsing, taking trees into strings:
+```
+ > linearize Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
+ the snake eats a boy
+```
+What is the use of this? Typically not that you type in a tree at
+the GF prompt. The utility of linearization comes from the fact that
+you can obtain a tree from somewhere else. One way to do so is
+**random generation** (``generate_random = gr``):
+```
+ > generate_random
+ Mks_0 (Mks_4 Mks_11) (Mks_3 Mks_15)
+```
+Now you can copy the tree and paste it to the ``linearize command``.
+Or, more efficiently, feed random generation into parsing by using
+a **pipe**.
+```
+ > gr | l
+ this worm is warm
+```
+
+
+%--!
+===Some random-generated sentences===
+
+Random generation can be quite amusing. So you may want to
+generate ten strings with one and the same command:
+```
+ > gr -number=10 | l
+ this boy is green
+ a snake laughs
+ the rotten boy is thick
+ a boy washes this worm
+ a boy is warm
+ this green warm boy is rotten
+ the green thick green louse is rotten
+ that boy is green
+ this thick thick boy laughs
+ a boy is green
+```
+
+
+%--!
+===Systematic generation===
+
+To generate <i>all<i> sentence that a grammar
+can generate, use the command ``generate_trees = gt``.
+```
+ > generate_trees | l
+ this louse laughs
+ this louse sleeps
+ this louse swims
+ this louse is green
+ this louse is rotten
+ ...
+ a boy is rotten
+ a boy is thick
+ a boy is warm
+```
+You get quite a few trees but not all of them: only up to a given
+**depth** of trees. To see how you can get more, use the
+``help = h`` command,
+```
+ help gr
+```
+**Quiz**. If the command ``gt`` generated all
+trees in your grammar, it would never terminate. Why?
+
+
+
+%--!
+===More on pipes; tracing===
+
+A pipe of GF commands can have any length, but the "output type"
+(either string or tree) of one command must always match the "input type"
+of the next command.
+
+
+
+The intermediate results in a pipe can be observed by putting the
+**tracing** flag ``-tr`` to each command whose output you
+want to see:
+```
+ > gr -tr | l -tr | p
+ Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
+ a louse sleeps
+ Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
+```
+This facility is good for test purposes: for instance, you
+may want to see if a grammar is **ambiguous**, i.e.
+contains strings that can be parsed in more than one way.
+
+
+
+%--!
+===Writing and reading files===
+
+To save the outputs of GF commands into a file, you can
+pipe it to the ``write_file = wf`` command,
+```
+ > gr -number=10 | l | write_file exx.tmp
+```
+You can read the file back to GF with the
+``read_file = rf`` command,
+```
+ > read_file exx.tmp | l -tr | p -lines
+```
+Notice the flag ``-lines`` given to the parsing
+command. This flag tells GF to parse each line of
+the file separately. Without the flag, the grammar could
+not recognize the string in the file, because it is not
+a sentence but a sequence of ten sentences.
+
+
+
+%--!
+===Labelled context-free grammars===
+
+The syntax trees returned by GF's parser in the previous examples
+are not so nice to look at. The identifiers of form ``Mks``
+are **labels** of the EBNF rules. To see which label corresponds to
+which rule, you can use the ``print_grammar = pg`` command
+with the ``printer`` flag set to ``cf`` (which means context-free):
+```
+ > print_grammar -printer=cf
+ Mks_10. CN ::= "louse" ;
+ Mks_11. CN ::= "snake" ;
+ Mks_12. CN ::= "worm" ;
+ Mks_8. CN ::= A CN ;
+ Mks_9. CN ::= "boy" ;
+ Mks_4. NP ::= "this" CN ;
+ Mks_15. A ::= "thick" ;
+ ...
+```
+A syntax tree such as
+```
+ Mks_4 (Mks_8 Mks_15 Mks_12)
+ this thick worm
+```
+encodes the sequence of grammar rules used for building the
+expression. If you look at this tree, you will notice that ``Mks_4``
+is the label of the rule prefixing ``this`` to a common noun,
+``Mks_15`` is the label of the adjective ``thick``,
+and so on.
+
+
+%--!
+<h4>The labelled context-free format<h4>
+
+The **labelled context-free grammar** format permits user-defined
+labels to each rule.
+GF recognizes files of this format by the suffix
+``.cf``. It is intermediate between EBNF and full GF format.
+Let us include the following rules in the file
+``paleolithic.cf``.
+```
+ PredVP. S ::= NP VP ;
+ UseV. VP ::= V ;
+ ComplTV. VP ::= TV NP ;
+ UseA. VP ::= "is" A ;
+ This. NP ::= "this" CN ;
+ That. NP ::= "that" CN ;
+ Def. NP ::= "the" CN ;
+ Indef. NP ::= "a" CN ;
+ ModA. CN ::= A CN ;
+ Boy. CN ::= "boy" ;
+ Louse. CN ::= "louse" ;
+ Snake. CN ::= "snake" ;
+ Worm. CN ::= "worm" ;
+ Green. A ::= "green" ;
+ Rotten. A ::= "rotten" ;
+ Thick. A ::= "thick" ;
+ Warm. A ::= "warm" ;
+ Laugh. V ::= "laughs" ;
+ Sleep. V ::= "sleeps" ;
+ Swim. V ::= "swims" ;
+ Eat. TV ::= "eats" ;
+ Kill. TV ::= "kills"
+ Wash. TV ::= "washes" ;
+```
+
+%--!
+<h4>Using the labelled context-free format<h4>
+
+The GF commands for the ``.cf`` format are
+exactly the same as for the ``.ebnf`` format.
+Just the syntax trees become nicer to read and
+to remember. Notice that before reading in
+a new grammar in GF you often (but not always,
+as we will see later) have first to give the
+command (``empty = e``), which removes the
+old grammar from the GF shell state.
+```
+ > empty
+
+ > i paleolithic.cf
+
+ > p "the boy eats a snake"
+ PredVP (Def Boy) (ComplTV Eat (Indef Snake))
+
+ > gr -tr | l
+ PredVP (Indef Louse) (UseA Thick)
+ a louse is thick
+```
+
+
+%--!
+==The GF grammar format==
+
+To see what there really is in GF's shell state when a grammar
+has been imported, you can give the plain command
+``print_grammar = pg``.
+```
+ > print_grammar
+```
+The output is quite unreadable at this stage, and you may feel happy that
+you did not need to write the grammar in that notation, but that the
+GF grammar compiler produced it.
+
+
+
+However, we will now start to show how GF's own notation gives you
+much more expressive power than the ``.cf`` and ``.ebnf``
+formats. We will introduce the ``.gf`` format by presenting
+one more way of defining the same grammar as in
+``paleolithic.cf`` and ``paleolithic.ebnf``.
+Then we will show how the full GF grammar format enables you
+to do things that are not possible in the weaker formats.
+
+
+%--!
+===Abstract and concrete syntax===
+
+A GF grammar consists of two main parts:
+
+- **abstract syntax**, defining what syntax trees there are
+- **concrete syntax**, defining how trees are linearized into strings
+
+
+
+The EBNF and CF formats fuse these two things together, but it is possible
+to take them apart. For instance, the verb phrase predication rule
+```
+ PredVP. S ::= NP VP ;
+```
+is interpreted as the following pair of rules:
+```
+ fun PredVP : NP -> VP -> S ;
+ lin PredVP x y = {s = x.s ++ y.s} ;
+```
+The former rule, with the keyword ``fun``, belongs to the abstract syntax.
+It defines the **function**
+``PredVP`` which constructs syntax trees of form
+(``PredVP`` <i>x<i> <i>y<i>).
+
+
+
+The latter rule, with the keyword ``lin``, belongs to the concrete syntax.
+It defines the **linearization function** for
+syntax trees of form (``PredVP`` <i>x<i> <i>y<i>).
+
+
+%--!
+<h4>Judgement forms<h4>
+
+Rules in a GF grammar are called **judgements**, and the keywords
+``fun`` and ``lin`` are used for distinguishing between two
+**judgement forms**. Here is a summary of the most important
+judgement forms:
+
+ - abstract syntax
+
+ | form | reading |
+ | ``cat`` C | C is a category
+ | ``fun`` f ``:`` A | f is a function of type A
+
+ - concrete syntax
+
+ | form | reading |
+ | ``lincat`` C ``=`` T | category C has linearization type T
+ | ``lin`` f ``=`` t | function f has linearization t
+
+
+
+We return to the precise meanings of these judgement forms later.
+First we will look at how judgements are grouped into modules, and
+show how the grammar ``paleolithic.cf`` is
+expressed by using modules and judgements.
+
+
+%--!
+<h4>Module types<h4>
+
+A GF grammar consists of **modules**,
+into which judgements are grouped. The most important
+module forms are
+
+ - ``abstract`` A = M``, abstract syntax A with judgements in
+ the module body M.
+ - ``concrete`` C ``of`` A = M``, concrete syntax C of the
+ abstract syntax A, with judgements in the module body M.
+
+
+
+%--!
+<h4>Record types, records, and ``Str``s<h4>
+
+The linearization type of a category is a **record type**, with
+zero of more **fields** of different types. The simplest record
+type used for linearization in GF is
+```
+ {s : Str}
+```
+which has one field, with **label** ``s`` and type ``Str``.
+
+
+
+Examples of records of this type are
+```
+ [s = "foo"}
+ [s = "hello" ++ "world"}
+```
+The type ``Str`` is really the type of **token lists**, but
+most of the time one can conveniently think of it as the type of strings,
+denoted by string literals in double quotes.
+
+
+
+Whenever a record ``r`` of type ``{s : Str}`` is given,
+``r.s`` is an object of type ``Str``. This is of course
+a special case of the **projection** rule, allowing the extraction
+of fields from a record.
+
+
+%--!
+<h4>An abstract syntax example<h4>
+
+Each nonterminal occurring in the grammar ``paleolithic.cf`` is
+introduced by a ``cat`` judgement. Each
+rule label is introduced by a ``fun`` judgement.
+```
+abstract Paleolithic = {
+cat
+ S ; NP ; VP ; CN ; A ; V ; TV ;
+fun
+ PredVP : NP -> VP -> S ;
+ UseV : V -> VP ;
+ ComplTV : TV -> NP -> VP ;
+ UseA : A -> VP ;
+ ModA : A -> CN -> CN ;
+ This, That, Def, Indef : CN -> NP ;
+ Boy, Louse, Snake, Worm : CN ;
+ Green, Rotten, Thick, Warm : A ;
+ Laugh, Sleep, Swim : V ;
+ Eat, Kill, Wash : TV ;
+}
+```
+Notice the use of shorthands permitting the sharing of
+the keyword in subsequent judgements, and of the type
+in subsequent ``fun`` judgements.
+
+
+%--!
+<h4>A concrete syntax example<h4>
+
+Each category introduced in ``Paleolithic.gf`` is
+given a ``lincat`` rule, and each
+function is given a ``fun`` rule. Similar shorthands
+apply as in ``abstract`` modules.
+```
+concrete PaleolithicEng of Paleolithic = {
+lincat
+ S, NP, VP, CN, A, V, TV = {s : Str} ;
+lin
+ PredVP np vp = {s = np.s ++ vp.s} ;
+ UseV v = v ;
+ ComplTV tv np = {s = tv.s ++ np.s} ;
+ UseA a = {s = "is" ++ a.s} ;
+ This cn = {s = "this" ++ cn.s} ;
+ That cn = {s = "that" ++ cn.s} ;
+ Def cn = {s = "the" ++ cn.s} ;
+ Indef cn = {s = "a" ++ cn.s} ;
+ ModA a cn = {s = a.s ++ cn.s} ;
+ Boy = {s = "boy"} ;
+ Louse = {s = "louse"} ;
+ Snake = {s = "snake"} ;
+ Worm = {s = "worm"} ;
+ Green = {s = "green"} ;
+ Rotten = {s = "rotten"} ;
+ Thick = {s = "thick"} ;
+ Warm = {s = "warm"} ;
+ Laugh = {s = "laughs"} ;
+ Sleep = {s = "sleeps"} ;
+ Swim = {s = "swims"} ;
+ Eat = {s = "eats"} ;
+ Kill = {s = "kills"} ;
+ Wash = {s = "washes"} ;
+}
+```
+
+
+%--!
+<h4>Modules and files<h4>
+
+Module name + ``.gf`` = file name
+
+
+
+Each module is compiled into a ``.gfc`` file.
+
+
+
+Import ``PaleolithicEng.gf`` and try what happens
+```
+ > i PaleolithicEng.gf
+```
+The GF program does not only read the file
+``PaleolithicEng.gf``, but also all other files that it
+depends on - in this case, ``Paleolithic.gf``.
+
+
+
+For each file that is compiled, a ``.gfc`` file
+is generated. The GFC format (="GF Canonical") is the
+"machine code" of GF, which is faster to process than
+GF source files. When reading a module, GF knows whether
+to use an existing ``.gfc`` file or to generate
+a new one, by looking at modification times.
+
+
+
+%--!
+<h4>Multilingual grammar<h4>
+
+The main advantage of separating abstract from concrete syntax is that
+one abstract syntax can be equipped with many concrete syntaxes.
+A system with this property is called a **multilingual grammar**.
+
+
+
+Multilingual grammars can be used for applications such as
+translation. Let us buid an Italian concrete syntax for
+``Paleolithic`` and then test the resulting
+multilingual grammar.
+
+
+
+
+%--!
+<h4>An Italian concrete syntax<h4>
+
+```
+concrete PaleolithicIta of Paleolithic = {
+lincat
+ S, NP, VP, CN, A, V, TV = {s : Str} ;
+lin
+ PredVP np vp = {s = np.s ++ vp.s} ;
+ UseV v = v ;
+ ComplTV tv np = {s = tv.s ++ np.s} ;
+ UseA a = {s = "è" ++ a.s} ;
+ This cn = {s = "questo" ++ cn.s} ;
+ That cn = {s = "quello" ++ cn.s} ;
+ Def cn = {s = "il" ++ cn.s} ;
+ Indef cn = {s = "un" ++ cn.s} ;
+ ModA a cn = {s = cn.s ++ a.s} ;
+ Boy = {s = "ragazzo"} ;
+ Louse = {s = "pidocchio"} ;
+ Snake = {s = "serpente"} ;
+ Worm = {s = "verme"} ;
+ Green = {s = "verde"} ;
+ Rotten = {s = "marcio"} ;
+ Thick = {s = "grosso"} ;
+ Warm = {s = "caldo"} ;
+ Laugh = {s = "ride"} ;
+ Sleep = {s = "dorme"} ;
+ Swim = {s = "nuota"} ;
+ Eat = {s = "mangia"} ;
+ Kill = {s = "uccide"} ;
+ Wash = {s = "lava"} ;
+}
+```
+
+%--!
+<h4>Using a multilingual grammar<h4>
+
+Import without first emptying
+```
+ > i PaleolithicEng.gf
+ > i PaleolithicIta.gf
+```
+Try generation now:
+```
+ > gr | l
+ un pidocchio uccide questo ragazzo
+
+ > gr | l -lang=PaleolithicEng
+ that louse eats a louse
+```
+Translate by using a pipe:
+```
+ > p -lang=PaleolithicEng "the boy eats the snake" | l -lang=PaleolithicIta
+ il ragazzo mangia il serpente
+```
+
+
+
+%--!
+<h4>Translation quiz<h4>
+
+This is a simple language exercise that can be automatically
+generated from a multilingual grammar. The system generates a set of
+random sentence, displays them in one language, and checks the user's
+answer given in another language. The command ``translation_quiz = tq``
+makes this in a subshell of GF.
+```
+ > translation_quiz PaleolithicEng PaleolithicIta
+
+ Welcome to GF Translation Quiz.
+ The quiz is over when you have done at least 10 examples
+ with at least 75 % success.
+ You can interrupt the quiz by entering a line consisting of a dot ('.').
+
+ a green boy washes the louse
+ un ragazzo verde lava il gatto
+
+ No, not un ragazzo verde lava il gatto, but
+ un ragazzo verde lava il pidocchio
+ Score 0/1
+```
+You can also generate a list of translation exercises and save it in a
+file for later use, by the command ``translation_list = tl``
+```
+ > translation_list -number=25 PaleolithicEng PaleolithicIta
+```
+The number flag gives the number of sentences generated.
+
+
+%--!
+<h4>The multilingual shell state<h4>
+
+A GF shell is at any time in a state, which
+contains a multilingual grammar. One of the concrete
+syntaxes is the "main" one, which means that parsing and linearization
+are performed by using it. By default, the main concrete syntax is the
+last-imported one. As we saw on previous slide, the ``lang`` flag
+can be used to change the linearization and parsing grammar.
+
+
+
+To see what the multilingual grammar is (as well as some other
+things), you can use the command
+``print_options = po``:
+```
+ > print_options
+ main abstract : Paleolithic
+ main concrete : PaleolithicIta
+ all concretes : PaleolithicIta PaleolithicEng
+```
+
+
+%--!
+<h4>Extending a grammar<h4>
+
+The module system of GF makes it possible to **extend** a
+grammar in different ways. The syntax of extension is
+shown by the following example.
+```
+ abstract Neolithic = Paleolithic ** {
+ fun
+ Fire, Wheel : CN ;
+ Think : V ;
+ }
+```
+Parallel to the abstract syntax, extensions can
+be built for concrete syntaxes:
+```
+ concrete NeolithicEng of Neolithic = PaleolithicEng ** {
+ lin
+ Fire = {s = "fire"} ;
+ Wheel = {s = "wheel"} ;
+ Think = {s = "thinks"} ;
+ }
+```
+The effect of extension is that all of the contents of the extended
+and extending module are put together.
+
+
+
+%--!
+<h4>Multiple inheritance<h4>
+
+Specialized vocabularies can be represented as small grammars that
+only do "one thing" each, e.g.
+```
+ abstract Fish = {
+ cat Fish ;
+ fun Salmon, Perch : Fish ;
+ }
+
+ abstract Mushrooms = {
+ cat Mushroom ;
+ fun Cep, Agaric : Mushroom ;
+ }
+```
+They can afterwards be combined into bigger grammars by using
+**multiple inheritance**, i.e. extension of several grammars at the
+same time:
+```
+ abstract Gatherer = Paleolithic, Fish, Mushrooms ** {
+ fun
+ UseFish : Fish -> CN ;
+ UseMushroom : Mushroom -> CN ;
+ }
+```
+
+
+
+%--!
+<h4>Visualizing module structure<h4>
+
+When you have created all the abstract syntaxes and
+one set of concrete syntaxes needed for ``Gatherer``,
+your grammar consists of eight GF modules. To see how their
+dependences look like, you can use the command
+``visualize_graph = vg``,
+```
+ > visualize_graph
+```
+and the graph will pop up in a separate window. It can also
+be printed out into a file, e.g. a ``.gif`` file that
+can be included in an HTML document
+```
+ > pm -printer=graph | wf Gatherer.dot
+ > ! dot -Tgif Gatherer.dot > Gatherer.gif
+```
+The latter command is a Unix command, issued from GF by using the
+shell escape symbol ``!``. The resulting graph is shown in the next section.
+
+
+
+The command ``print_multi = pm`` is used for printing the current multilingual
+grammar in various formats, of which the format ``-printer=graph`` just
+shows the module dependencies.
+
+
+%--!
+<h4>The module structure of ``GathererEng``<h4>
+
+The graph uses
+
+- oval boxes for abstract modules
+- square boxes for concrete modules
+- black-headed arrows for inheritance
+- white-headed arrows for the concrete-of-abstract relation
+
+
+
+
+<img src="Gatherer.gif">
+
+
+%--!
+===Resource modules===
+
+Suppose we want to say, with the vocabulary included in
+``Paleolithic.gf``, things like
+```
+ the boy eats two snakes
+ all boys sleep
+```
+The new grammatical facility we need are the plural forms
+of nouns and verbs (<i>boys, sleep<i>), as opposed to their
+singular forms.
+
+
+
+The introduction of plural forms requires two things:
+
+- to **inflect** nouns and verbs in singular and plural number
+- to describe the **agreement** of the verb to subject: the
+ rule that the verb must have the same number as the subject
+
+
+
+Different languages have different rules of inflection and agreement.
+For instance, Italian has also agreement in gender (masculine vs. feminine).
+We want to express such special features of languages precisely in
+concrete syntax while ignoring them in abstract syntax.
+
+
+
+To be able to do all this, we need two new judgement forms,
+a new module form, and a generalizarion of linearization types
+from strings to more complex types.
+
+
+%--!
+<h4>Parameters and tables<h4>
+
+We define the **parameter type** of number in Englisn by
+using a new form of judgement:
+```
+ param Number = Sg | Pl ;
+```
+To express that nouns in English have a linearization
+depending on number, we replace the linearization type ``{s : Str}``
+with a type where the ``s`` field is a **table** depending on number:
+```
+ lincat CN = {s : Number => Str} ;
+```
+The **table type** ``Number => Str`` is in many respects similar to
+a function type (``Number -> Str``). The main restriction is that the
+argument type of a table type must always be a parameter type. This means
+that the argument-value pairs can be listed in a finite table. The following
+example shows such a table:
+```
+ lin Boy = {s = table {
+ Sg => "boy" ;
+ Pl => "boys"
+ }
+ } ;
+```
+The application of a table to a parameter is done by the **selection**
+operator ``!``. For instance,
+```
+ Boy.s ! Pl
+```
+is a selection, whose value is ``"boys"``.
+
+
+%--!
+<h4>Inflection tables, paradigms, and ``oper`` definitions<h4>
+
+All English common nouns are inflected in number, most of them in the
+same way: the plural form is formed from the singular form by adding the
+ending <i>s<i>. This rule is an example of
+a **paradigm** - a formula telling how the inflection
+forms of a word are formed.
+
+
+
+From GF point of view, a paradigm is a function that takes a **lemma** -
+a string also known as a **dictionary form** - and returns an inflection
+table of desired type. Paradigms are not functions in the sense of the
+``fun`` judgements of abstract syntax (which operate on trees and not
+on strings). Thus we call them **operations** for the sake of clarity,
+introduce one one form of judgement, with the keyword ``oper``. As an
+example, the following operation defines the regular noun paradigm of English:
+```
+ oper regNoun : Str -> {s : Number => Str} = \x -> {
+ s = table {
+ Sg => x ;
+ Pl => x + "s"
+ }
+ } ;
+```
+Thus an ``oper`` judgement includes the name of the defined operation,
+its type, and an expression defining it. As for the syntax of the defining
+expression, notice the **lambda abstraction** form ``\x -> t`` of
+the function, and the **glueing** operator ``+`` telling that
+the string held in the variable ``x`` and the ending ``"s"``
+are written together to form one **token**.
+
+
+%--!
+<h4>The ``resource`` module type<h4>
+
+Parameter and operator definitions do not belong to the abstract syntax.
+They can be used when defining concrete syntax - but they are not
+tied to a particular set of linearization rules.
+The proper way to see them is as auxiliary concepts, as **resources**
+usable in many concrete syntaxes.
+
+
+
+The ``resource`` module type thus consists of
+``param`` and ``oper`` definitions. Here is an
+example.
+```
+ resource MorphoEng = {
+ param
+ Number = Sg | Pl ;
+ oper
+ Noun : Type = {s : Number => Str} ;
+ regNoun : Str -> Noun = \x -> {
+ s = table {
+ Sg => x ;
+ Pl => x + "s"
+ }
+ } ;
+ }
+```
+Resource modules can extend other resource modules, in the
+same way as modules of other types can extend modules of the
+same type.
+
+
+
+%--!
+===Opening a ``resource``===
+
+Any number of ``resource`` modules can be
+**opened** in a ``concrete`` syntax, which
+makes the parameter and operation definitions contained
+in the resource usable in the concrete syntax. Here is
+an example, where the resource ``MorphoEng`` is
+open in (the fragment of) a new version of ``PaleolithicEng``.
+```
+concrete PaleolithicEng of Paleolithic = open MorphoEng in {
+ lincat
+ CN = Noun ;
+ lin
+ Boy = regNoun "boy" ;
+ Snake = regNoun "snake" ;
+ Worm = regNoun "worm" ;
+ }
+```
+Notice that, just like in abstract syntax, function application
+is written by juxtaposition of the function and the argument.
+
+
+
+Using operations defined in resource modules is clearly a concise
+way of giving e.g. inflection tables and other repeated patterns
+of expression. In addition, it enables a new kind of modularity
+and division of labour in grammar writing: grammarians familiar with
+the linguistic details of a language can put this knowledge
+available through resource grammars, whose users only need
+to pick the right operations and not to know their implementation
+details.
+
+
+
+%--!
+<h4>Worst-case macros and data abstraction<h4>
+
+Some English nouns, such as ``louse``, are so irregular that
+it makes little sense to see them as instances of a paradigm. Even
+then, it is useful to perform **data abstraction** from the
+definition of the type ``Noun``, and introduce a constructor
+operation, a **worst-case macro** for nouns:
+```
+ oper mkNoun : Str -> Str -> Noun = \x,y -> {
+ s = table {
+ Sg => x ;
+ Pl => y
+ }
+ } ;
+```
+Thus we define
+```
+ lin Louse = mkNoun "louse" "lice" ;
+```
+instead of writing the inflection table explicitly.
+
+
+
+The grammar engineering advantage of worst-case macros is that
+the author of the resource module may change the definitions of
+``Noun`` and ``mkNoun``, and still retain the
+interface (i.e. the system of type signatures) that makes it
+correct to use these functions in concrete modules. In programming
+terms, ``Noun`` is then treated as an **abstract datatype**.
+
+
+
+%--!
+<h4>A system of paradigms using ``Prelude`` operations<h4>
+
+The regular noun paradigm ``regNoun`` can - and should - of course be defined
+by the worst-case macro ``mkNoun``. In addition, some more noun paradigms
+could be defined, for instance,
+```
+ regNoun : Str -> Noun = \snake -> mkNoun snake (snake + "s") ;
+ sNoun : Str -> Noun = \kiss -> mkNoun kiss (kiss + "es") ;
+```
+What about nouns like <i>fly<i>, with the plural <i>flies<i>? The already
+available solution is to use the so-called "technical stem" <i>fl<i> as
+argument, and define
+```
+ yNoun : Str -> Noun = \fl -> mkNoun (fl + "y") (fl + "ies") ;
+```
+But this paradigm would be very unintuitive to use, because the "technical stem"
+is not even an existing form of the word. A better solution is to use
+the string operator ``init``, which returns the initial segment (i.e.
+all characters but the last) of a string:
+```
+ yNoun : Str -> Noun = \fly -> mkNoun fly (init fly + "ies") ;
+```
+The operator ``init`` belongs to a set of operations in the
+resource module ``Prelude``, which therefore has to be
+``open``ed so that ``init`` can be used.
+
+
+
+%--!
+<h4>An intelligent noun paradigm using ``case`` expressions<h4>
+
+It may be hard for the user of a resource morphology to pick the right
+inflection paradigm. A way to help this is to define a more intelligent
+paradigms, which chooses the ending by first analysing the lemma.
+The following variant for English regular nouns puts together all the
+previously shown paradigms, and chooses one of them on the basis of
+the final letter of the lemma.
+```
+ regNoun : Str -> Noun = \s -> case last s of {
+ "s" | "z" => mkNoun s (s + "es") ;
+ "y" => mkNoun s (init s + "ies") ;
+ _ => mkNoun s (s + "s")
+ } ;
+```
+This definition displays many GF expression forms not shown befores;
+these forms are explained in the following section.
+
+
+
+The paradigms ``regNoun`` does not give the correct forms for
+all nouns. For instance, <i>louse - lice<i> and
+<i>fish - fish<i> must be given by using ``mkNoun``.
+Also the word <i>boy<i> would be inflected incorrectly; to prevent
+this, either use ``mkNoun`` or modify
+``regNoun`` so that the ``"y"`` case does not
+apply if the second-last character is a vowel.
+
+
+
+%--!
+<h4>Pattern matching<h4>
+
+Expressions of the ``table`` form are built from lists of
+argument-value pairs. These pairs are called the **branches**
+of the table. In addition to constants introduced in
+``param`` definitions, the left-hand side of a branch can more
+generally be a **pattern**, and the computation of selection is
+then performed by **pattern matching**:
+
+- a variable pattern (identifier other than constant parameter) matches anything
+- the wild card ``_`` matches anything
+- a string literal pattern, e.g. ``"s"``, matches the same string
+- a disjunctive pattern ``P | ... | Q`` matches anything that
+ one of the disjuncts matches
+
+
+
+Pattern matching is performed in the order in which the branches
+appear in the table.
+
+
+
+As syntactic sugar, one-branch tables can be written concisely,
+```
+ \\P,...,Q => t === table {P => ... table {Q => t} ...}
+```
+Finally, the ``case`` expressions common in functional
+programming languages are syntactic sugar for table selections:
+```
+ case e of {...} === table {...} ! e
+```
+
+
+
+%--!
+<h4>Morphological analysis and morphology quiz<h4>
+
+Even though in GF morphology
+is mostly seen as an auxiliary of syntax, a morphology once defined
+can be used on its own right. The command ``morpho_analyse = ma``
+can be used to read a text and return for each word the analyses that
+it has in the current concrete syntax.
+```
+ > rf bible.txt | morpho_analyse
+```
+Similarly to translation exercises, morphological exercises can
+be generated, by the command ``morpho_quiz = mq``. Usually,
+the category is set to be something else than ``S``. For instance,
+```
+ > i lib/resource/french/VerbsFre.gf
+ > morpho_quiz -cat=V
+
+ Welcome to GF Morphology Quiz.
+ ...
+
+ réapparaître : VFin VCondit Pl P2
+ réapparaitriez
+ > No, not réapparaitriez, but
+ réapparaîtriez
+ Score 0/1
+```
+Finally, a list of morphological exercises and save it in a
+file for later use, by the command ``morpho_list = ml``
+```
+ > morpho_list -number=25 -cat=V
+```
+The number flag gives the number of exercises generated.
+
+
+
+%--!
+<h4>Parametric vs. inherent features, agreement<h4>
+
+The rule of subject-verb agreement in English says that the verb
+phrase must be inflected in the number of the subject. This
+means that a noun phrase (functioning as a subject), in some sense
+<i>has<i> a number, which it "sends" to the verb. The verb does not
+have a number, but must be able to receive whatever number the
+subject has. This distinction is nicely represented by the
+different linearization types of noun phrases and verb phrases:
+```
+ lincat NP = {s : Str ; n : Number} ;
+ lincat VP = {s : Number => Str} ;
+```
+We say that the number of ``NP`` is an **inherent feature**,
+whereas the number of ``NP`` is **parametric**.
+
+
+
+The agreement rule itself is expressed in the linearization rule of
+the predication structure:
+```
+ lin PredVP np vp = {s = np.s ++ vp.s ! np.n} ;
+```
+The following page will present a new version of
+``PaleolithingEng``, assuming an abstract syntax
+xextended with ``All`` and ``Two``.
+It also assumes that ``MorphoEng`` has a paradigm
+``regVerb`` for regular verbs (which need only be
+regular only in the present tensse).
+The reader is invited to inspect the way in which agreement works in
+the formation of noun phrases and verb phrases.
+
+
+
+%--!
+<h4>English concrete syntax with parameters<h4>
+
+```
+concrete PaleolithicEng of Paleolithic = open MorphoEng in {
+lincat
+ S, A = {s : Str} ;
+ VP, CN, V, TV = {s : Number => Str} ;
+ NP = {s : Str ; n : Number} ;
+lin
+ PredVP np vp = {s = np.s ++ vp.s ! np.n} ;
+ UseV v = v ;
+ ComplTV tv np = {s = \\n => tv.s ! n ++ np.s} ;
+ UseA a = {s = \\n => case n of {Sg => "is" ; Pl => "are"} ++ a.s} ;
+ This cn = {s = "this" ++ cn.s ! Sg } ;
+ Indef cn = {s = "a" ++ cn.s ! Sg} ;
+ All cn = {s = "all" ++ cn.s ! Pl} ;
+ Two cn = {s = "two" ++ cn.s ! Pl} ;
+ ModA a cn = {s = \\n => a.s ++ cn.s ! n} ;
+ Louse = mkNoun "louse" "lice" ;
+ Snake = regNoun "snake" ;
+ Green = {s = "green"} ;
+ Warm = {s = "warm"} ;
+ Laugh = regVerb "laugh" ;
+ Sleep = regVerb "sleep" ;
+ Kill = regVerb "kill" ;
+}
+```
+
+
+
+%--!
+<h4>Hierarchic parameter types<h4>
+
+The reader familiar with a functional programming language such as
+<a href="http://www.haskell.org">Haskell<a> must have noticed the similarity
+between parameter types in GF and algebraic datatypes (``data`` definitions
+in Haskell). The GF parameter types are actually a special case of algebraic
+datatypes: the main restriction is that in GF, these types must be finite.
+(This restriction makes it possible to invert linearization rules into
+parsing methods.)
+
+
+
+However, finite is not the same thing as enumerated. Even in GF, parameter
+constructors can take arguments, provided these arguments are from other
+parameter types (recursion is forbidden). Such parameter types impose a
+hierarchic order among parameters. They are often useful to define
+linguistically accurate parameter systems.
+
+
+
+To give an example, Swedish adjectives
+are inflected in number (singular or plural) and
+gender (uter or neuter). These parameters would suggest 2*2=4 different
+forms. However, the gender distinction is done only in the singular. Therefore,
+it would be inaccurate to define adjective paradigms using the type
+``Gender => Number => Str``. The following hierarchic definition
+yields an accurate system of three adjectival forms.
+```
+ param AdjForm = ASg Gender | APl ;
+ param Gender = Uter | Neuter ;
+```
+In pattern matching, a constructor can have patterns as arguments. For instance,
+the adjectival paradigm in which the two singular forms are the same, can be defined
+```
+ oper plattAdj : Str -> AdjForm => Str = \x -> table {
+ ASg _ => x ;
+ APl => x + "a" ;
+ }
+```
+
+
+%--!
+<h4>Discontinuous constituents<h4>
+
+A linearization type may contain more strings than one.
+An example of where this is useful are English particle
+verbs, such as <i>switch off<i>. The linearization of
+a sentence may place the object between the verb and the particle:
+<i>he switched it off<i>.
+
+
+
+The first of the following judgements defines transitive verbs as a
+**discontinuous constituents**, i.e. as having a linearization
+type with two strings and not just one. The second judgement
+shows how the constituents are separated by the object in complementization.
+```
+ lincat TV = {s : Number => Str ; s2 : Str} ;
+ lin ComplTV tv obj = {s = \\n => tv.s ! n ++ obj.s ++ tv.s2} ;
+```
+
+
+
+GF currently requires that all fields in linearization records that
+have a table with value type ``Str`` have as labels
+either ``s`` or ``s`` with an integer index.
+
+
+
+
+%--!
+==Topics still to be written==
+
+
+Free variation
+
+
+
+Record extension, tuples
+
+
+
+Predefined types and operations
+
+
+
+Lexers and unlexers
+
+
+
+Grammars of formal languages
+
+
+
+Resource grammars and their reuse
+
+
+
+Embedded grammars in Haskell and Java
+
+
+
+Dependent types, variable bindings, semantic definitions
+
+
+
+Transfer rules
+
+
+
+<body>
+<html> \ No newline at end of file