summaryrefslogtreecommitdiff
path: root/doc/tutorial
diff options
context:
space:
mode:
authoraarne <unknown>2005-04-20 19:55:00 +0000
committeraarne <unknown>2005-04-20 19:55:00 +0000
commit3155a82696ba533c4a59f84a495982b9eb1a9b83 (patch)
tree551b128b2dffea34bb56a570ac74a14fb1f0fd50 /doc/tutorial
parenteabbc979dfbef3e23069ac243d54d2a6eca19e18 (diff)
smaller exx
Diffstat (limited to 'doc/tutorial')
-rw-r--r--doc/tutorial/Paleolithic.gf6
-rw-r--r--doc/tutorial/PaleolithicEng.gf3
-rw-r--r--doc/tutorial/PaleolithicIta.gf3
-rw-r--r--doc/tutorial/gf-tutorial2.html66
-rw-r--r--doc/tutorial/paleolithic.cf3
-rw-r--r--doc/tutorial/paleolithic.ebnf4
6 files changed, 39 insertions, 46 deletions
diff --git a/doc/tutorial/Paleolithic.gf b/doc/tutorial/Paleolithic.gf
index dadfd5140..05158ba18 100644
--- a/doc/tutorial/Paleolithic.gf
+++ b/doc/tutorial/Paleolithic.gf
@@ -7,10 +7,10 @@ fun
UseV : V -> VP ;
ComplTV : TV -> NP -> VP ;
UseA : A -> VP ;
- This, That, Def, Indef : CN -> NP ;
ModA : A -> CN -> CN ;
- Bird, Boy, Man, Louse, Snake, Worm : CN ;
- Big, Green, Rotten, Thick, Warm : A ;
+ This, That, Def, Indef : CN -> NP ;
+ Boy, Louse, Snake, Worm : CN ;
+ Green, Rotten, Thick, Warm : A ;
Laugh, Sleep, Swim : V ;
Eat, Kill, Wash : TV ;
} \ No newline at end of file
diff --git a/doc/tutorial/PaleolithicEng.gf b/doc/tutorial/PaleolithicEng.gf
index 4bbf81707..ac78f9d9d 100644
--- a/doc/tutorial/PaleolithicEng.gf
+++ b/doc/tutorial/PaleolithicEng.gf
@@ -11,13 +11,10 @@ lin
Def cn = {s = "the" ++ cn.s} ;
Indef cn = {s = "a" ++ cn.s} ;
ModA a cn = {s = a.s ++ cn.s} ;
- Bird = {s = "bird"} ;
Boy = {s = "boy"} ;
Louse = {s = "louse"} ;
- Man = {s = "man"} ;
Snake = {s = "snake"} ;
Worm = {s = "worm"} ;
- Big = {s = "big"} ;
Green = {s = "green"} ;
Rotten = {s = "rotten"} ;
Thick = {s = "thick"} ;
diff --git a/doc/tutorial/PaleolithicIta.gf b/doc/tutorial/PaleolithicIta.gf
index 2b7648767..242c615d7 100644
--- a/doc/tutorial/PaleolithicIta.gf
+++ b/doc/tutorial/PaleolithicIta.gf
@@ -11,13 +11,10 @@ lin
Def cn = {s = "il" ++ cn.s} ;
Indef cn = {s = "un" ++ cn.s} ;
ModA a cn = {s = cn.s ++ a.s} ;
- Bird = {s = "uccello"} ;
Boy = {s = "ragazzo"} ;
Louse = {s = "pidocchio"} ;
- Man = {s = "uomo"} ;
Snake = {s = "serpente"} ;
Worm = {s = "verme"} ;
- Big = {s = "grande"} ;
Green = {s = "verde"} ;
Rotten = {s = "marcio"} ;
Thick = {s = "grosso"} ;
diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html
index 67da66394..18e5342ab 100644
--- a/doc/tutorial/gf-tutorial2.html
+++ b/doc/tutorial/gf-tutorial2.html
@@ -108,10 +108,10 @@ representation, and shows a new prompt when it is ready.
You can use GF for <b>parsing</b>:
<pre>
> parse "the boy eats a snake"
- Mks_0 (Mks_6 Mks_10) (Mks_2 Mks_23 (Mks_7 Mks_13))
+ 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_13) (Mks_2 Mks_23 (Mks_7 Mks_10))
+ 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
@@ -137,7 +137,7 @@ You can also use GF for <b>linearizing</b>
(<tt>linearize = l</tt>). This is the inverse of
parsing, taking trees into strings:
<pre>
- > linearize Mks_0 (Mks_6 Mks_13) (Mks_2 Mks_23 (Mks_7 Mks_10))
+ > linearize Mks_0 (Mks_6 Mks_11) (Mks_2 Mks_20 (Mks_7 Mks_9))
the snake eats a boy
</pre>
What is the use of this? Typically not that you type in a tree at
@@ -153,7 +153,7 @@ Or, more efficiently, feed random generation into parsing by using
a <b>pipe</b>.
<pre>
> gr | l
- this man is big
+ this worm is warm
</pre>
@@ -164,16 +164,16 @@ 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
- that man laughs
- the man swims
- this man is warm
- a louse is rotten
- that worm washes a man
- a boy swims
- a snake laughs
- a man washes this man
- this louse kills the boy
+ 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>
@@ -183,13 +183,15 @@ generate ten strings with one and the same command:
To generate <i>all</i> sentence that a grammar
can generate, use the command <tt>generate_trees = gt</tt>.
<pre>
- this boy laughs
- this boy sleeps
- this boy swims
+ this louse laughs
+ this louse sleeps
+ this louse swims
+ this louse is green
+ this louse is rotten
...
- a worm is rotten
- a worm is thick
- a worm is warm
+ a boy is rotten
+ a boy is thick
+ a boy is warm
</pre>
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
@@ -215,9 +217,9 @@ The intermediate results in a pipe can be observed by putting the
want to see:
<pre>
> gr -tr | l -tr | p
- Mks_0 (Mks_6 Mks_13) (Mks_1 Mks_20)
- the snake laughs
- Mks_0 (Mks_6 Mks_13) (Mks_1 Mks_20)
+ Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
+ a louse sleeps
+ Mks_0 (Mks_7 Mks_10) (Mks_1 Mks_18)
</pre>
This facility is good for test purposes: for instance, you
may want to see if a grammar is <b>ambiguous</b>, i.e.
@@ -256,27 +258,27 @@ 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 ::= "boy" ;
- Mks_11. CN ::= "man" ;
- Mks_12. CN ::= "louse" ;
- Mks_13. CN ::= "snake" ;
- Mks_14. CN ::= "worm" ;
+ Mks_10. CN ::= "louse" ;
+ Mks_11. CN ::= "snake" ;
+ Mks_12. CN ::= "worm" ;
Mks_8. CN ::= A CN ;
- Mks_9. CN ::= "bird" ;
+ Mks_9. CN ::= "boy" ;
Mks_4. NP ::= "this" CN ;
- Mks_18. A ::= "thick" ;
+ Mks_15. A ::= "thick" ;
+ ...
</pre>
A syntax tree such as
<pre>
- Mks_4 (Mks_8 Mks_18 Mks_14)
+ Mks_4 (Mks_8 Mks_15 Mks_12)
this thick worm
</pre>
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_18</tt> is the label of the adjective <tt>thick</tt>,
+<tt>Mks_15</tt> is the label of the adjective <tt>thick</tt>,
and so on.
+
<!-- NEW -->
<h4>The labelled context-free format</h4>
@@ -574,7 +576,7 @@ Inspect the shell state (<tt>print_options = po</tt>):
<!-- NEW -->
<h4>Extending the grammar</h4>
-Neolithic
+Neolithic: fire, wheel, think,...
diff --git a/doc/tutorial/paleolithic.cf b/doc/tutorial/paleolithic.cf
index d9869a257..08496c800 100644
--- a/doc/tutorial/paleolithic.cf
+++ b/doc/tutorial/paleolithic.cf
@@ -7,13 +7,10 @@ That. NP ::= "that" CN ;
Def. NP ::= "the" CN ;
Indef. NP ::= "a" CN ;
ModA. CN ::= A CN ;
-Bird. CN ::= "bird" ;
Boy. CN ::= "boy" ;
-Man. CN ::= "man" ;
Louse. CN ::= "louse" ;
Snake. CN ::= "snake" ;
Worm. CN ::= "worm" ;
-Big. A ::= "big" ;
Green. A ::= "green" ;
Rotten. A ::= "rotten" ;
Thick. A ::= "thick" ;
diff --git a/doc/tutorial/paleolithic.ebnf b/doc/tutorial/paleolithic.ebnf
index 96b155993..cd091ae04 100644
--- a/doc/tutorial/paleolithic.ebnf
+++ b/doc/tutorial/paleolithic.ebnf
@@ -2,7 +2,7 @@ S ::= NP VP ;
VP ::= V | TV NP | "is" A ;
NP ::= ("this" | "that" | "the" | "a") CN ;
CN ::= A CN ;
-CN ::= "bird" | "boy" | "man" | "louse" | "snake" | "worm" ;
-A ::= "big" | "green" | "rotten" | "thick" | "warm" ;
+CN ::= "boy" | "louse" | "snake" | "worm" ;
+A ::= "green" | "rotten" | "thick" | "warm" ;
V ::= "laughs" | "sleeps" | "swims" ;
TV ::= "eats" | "kills" | "washes" ;