diff --git a/doc/gf-tutorial.html b/doc/gf-tutorial.html index 2a6d74c9e..fcf5683d4 100644 --- a/doc/gf-tutorial.html +++ b/doc/gf-tutorial.html @@ -8,7 +8,7 @@
-The main focus of this tutorial is on using the GF programming language. +The focus of this tutorial is on using the GF programming language.
At the same time, we learn the way of thinking in the GF theory. @@ -391,7 +391,7 @@ using the GF system. A GF program is called a grammar.
-A grammar defines of a language. +A grammar defines a language.
From this definition, language processing components can be derived: @@ -647,8 +647,8 @@ by a new prompt:
> i HelloEng.gf
- - compiling Hello.gf... wrote file Hello.gfc 8 msec
- - compiling HelloEng.gf... wrote file HelloEng.gfc 12 msec
+ - compiling Hello.gf... wrote file Hello.gfo 8 msec
+ - compiling HelloEng.gf... wrote file HelloEng.gfo 12 msec
12 msec
>
@@ -841,8 +841,8 @@ Application programs, using techniques from Lesson 7:
-The variants construct of GF expresses free variation. For example,
+The variants construct of GF expresses free variation. For example,
- lin Delicious = {s = variants {"delicious" ; "exquisit" ; "tasty"}} ;
+ lin Delicious = {s = "delicious" | "exquisit" | "tasty"} ;
By default, the linearize command
-shows only the first variant from each variants list; to see them
+shows only the first variant from such lists; to see them
all, use the option -all:
@@ -1274,8 +1274,18 @@ all, use the option -all:
this delicious wine is exquisit
...
+
-Limiting case: an empty variant list + +
++An equivalent notation for variants is +
+
+ lin Delicious = {s = variants {"delicious" ; "exquisit" ; "tasty"}} ;
+
++This notation also allows the limiting case: an empty variant list,
variants {}
@@ -1285,7 +1295,7 @@ It can be used e.g. if a word lacks a certain inflection form.
Free variation works for all types in concrete syntax; all terms in
-a variants list must be of the same type.
+a variant list must be of the same type.
@@ -1302,7 +1312,7 @@ a variants list must be of the same type.
linearizations in different languages:
- > gr -number=2 | tree_bank
+ > gr -number=2 | l -treebank
Is (That Cheese) (Very Boring)
quel formaggio è molto noioso
@@ -1312,10 +1322,7 @@ linearizations in different languages:
quel formaggio è fresco
that cheese is fresh
-
-There is also an XML format for treebanks and a set of commands
-suitable for regression testing; see help tb for more details.
-
+
@@ -1356,7 +1363,7 @@ answer given in another language.
The "cf" grammar format
-The grammar FoodEng could be written in a BNF format as follows:
+The grammar FoodEng can be written in a BNF format as follows:
Is. Phrase ::= Item "is" Quality ;
@@ -1375,14 +1382,14 @@ The grammar FoodEng could be written in a BNF format as follows:
Warm. Quality ::= "warm" ;
-The GF system v 2.9 can be used for converting BNF grammars into GF.
-BNF files are recognized by the file name suffix .cf:
+GF can convert BNF grammars into GF.
+BNF files are recognized by the file name suffix .cf (for context-free):
> import food.cf
-It creates separate abstract and concrete modules.
+The compiler creates separate abstract and concrete modules internally.
@@ -1413,7 +1420,7 @@ GF uses suffixes to recognize different file formats:
.gf
-.gfc
+.gfo
@@ -1641,8 +1648,7 @@ A new module can extend an old one: Question ; fun QIs : Item -> Quality -> Question ; - Pizza : Kind ; - + Pizza : Kind ; }
@@ -1851,7 +1857,10 @@ argument. For instance,
case e of {...} === table {...} ! e
-
++Since they are familiar to Haskell and ML programmers, they can come out handy +when writing GF programs. +
@@ -1899,7 +1908,7 @@ words is inflected.
From the GF point of view, a paradigm is a function that takes -a lemma (dictionary form, citation form) and +a lemma (also known as a dictionary form, or a citation form) and returns an inflection table.
@@ -2892,9 +2901,6 @@ Thus
-Prefix-dependent choice may be deprecated in GF version 3. -
-@@ -4076,10 +4082,6 @@ tenses and moods, e.g. the Romance languages.
-NOTICE: The methods described in this lesson are not yet fully supported -in GF 3.0 beta. Use GF 2.9 to get all functionalities. -
-@@ -4241,18 +4243,21 @@ to mark incomplete parts of trees in the syntax editor.
-Use the command put_tree = pt with the flag -transform=solve:
+Use the command put_tree = pt with the option -typecheck:
- > parse "dim the light" | put_tree -transform=solve
+ > parse "dim the light" | put_tree -typecheck
CAction light dim (DKindOne light)
-The solve process may fail, in which case no tree is returned:
+The typecheck process may fail, in which case an error message
+is shown and no tree is returned:
- > parse "dim the fan" | put_tree -transform=solve - no tree found + > parse "dim the fan" | put_tree -typecheck + + Error in tree UCommand (CAction ? 0 dim (DKindOne fan)) : + (? 0 <> fan) (? 0 <> light)
@@ -4603,18 +4608,20 @@ The linearization of the variable x is,
-GF needs to know what strings are parsed as variable symbols. -
--This is defined in a special lexer, +GF can treat any one-word string as a variable symbol.
- > p -cat=Prop -lexer=codevars "(All x)(x = x)"
+ > p -cat=Prop "( All x ) ( x = x )"
All (\x -> Eq x x)
-More details on lexers here. +Variables must be bound if they are used:
++ > p -cat=Prop "( All x ) ( x = y )" + no tree found ++
@@ -4779,10 +4786,6 @@ Type checking can be invoked with
put_term -transform=solve.
-NOTICE: The methods described in this lesson are not yet fully supported -in GF 3.0 beta. Use GF 2.9 to get all functionalities. -
-
@@ -4896,23 +4899,27 @@ Moreover, the tokens "12", "3", and "4" s
integer literals - they cannot be found in the grammar.
-We choose a proper with a flag: + +
+
+Lexers are invoked by flags to the command put_string = ps.
- > parse -cat=Exp -lexer=codelit "(2 + (3 * 4))" - EPlus (EInt 2) (ETimes (EInt 3) (EInt 4)) + > put_string -lexcode "(2 + (3 * 4))" + ( 2 + ( 3 * 4 ) )
-We could also put the flag into the grammar (concrete syntax): +This can be piped into a parser, as usual:
- flags lexer = codelit ; + > ps -lexcode "(2 + (3 * 4))" | parse + EPlus (EInt 2) (ETimes (EInt 3) (EInt 4))
In linearization, we use a corresponding unlexer:
- > l -unlexer=code EPlus (EInt 2) (ETimes (EInt 3) (EInt 4))
+ > linearize EPlus (EInt 2) (ETimes (EInt 3) (EInt 4)) | ps -unlexcode
(2 + (3 * 4))
@@ -4924,66 +4931,33 @@ In linearization, we use a corresponding unlexer:
| lexer | -description | -|
|---|---|---|
words |
-(default) tokens are separated by spaces or newlines | -|
literals |
-like words, but integer and string literals recognized | -|
chars |
-each character is a token | -|
code |
-program code conventions (uses Haskell's lex) | -|
text |
-with conventions on punctuation and capital letters | -|
codelit |
-like code, but recognize literals (unknown words as strings) | -|
textlit |
-like text, but recognize literals (unknown words as strings) | -|
| unlexer | description | |
|---|---|---|
chars |
+unchars |
+each character is a token | +
lexcode |
+unlexcode |
+program code conventions (uses Haskell's lex) | +
lexmixed |
+unlexmixed |
+like text, but between $ signs like code | +
lextext |
+unlextext |
+with conventions on punctuation and capitals | +
words |
unwords |
-(default) space-separated token list | -
text |
-format as text: punctuation, capitals, paragraph <p> | -|
code |
-format as code (spacing, indentation) | -|
textlit |
-like text, but remove string literal quotes | -|
codelit |
-like code, but remove string literal quotes | -|
concat |
-remove all spaces | +(default) tokens separated by space characters |