diff --git a/doc/gf-index.html b/doc/gf-index.html index 340f64f44..01397554b 100644 --- a/doc/gf-index.html +++ b/doc/gf-index.html @@ -12,20 +12,27 @@

Version 2.1

November 8, 2004. + +

+ +Version 2.2 scheduled to be released May 16, 2005! See +highlights. +

News

- May 9, 2005. PhD Thesis by diff --git a/doc/tutorial/Fish.gf b/doc/tutorial/Fish.gf new file mode 100644 index 000000000..c404115e9 --- /dev/null +++ b/doc/tutorial/Fish.gf @@ -0,0 +1,4 @@ +abstract Fish = { + cat Fish ; + fun Salmon, Perch : Fish ; +} diff --git a/doc/tutorial/FishEng.gf b/doc/tutorial/FishEng.gf new file mode 100644 index 000000000..560f6cda4 --- /dev/null +++ b/doc/tutorial/FishEng.gf @@ -0,0 +1,5 @@ +concrete FishEng of Fish = { + lin + Salmon = {s = "salmon"} ; + Perch = {s = "perch"} ; +} diff --git a/doc/tutorial/Gatherer.gf b/doc/tutorial/Gatherer.gf new file mode 100644 index 000000000..254a46ec0 --- /dev/null +++ b/doc/tutorial/Gatherer.gf @@ -0,0 +1,5 @@ +abstract Gatherer = Paleolithic, Fish, Mushrooms ** { + fun + UseFish : Fish -> CN ; + UseMushroom : Mushroom -> CN ; +} \ No newline at end of file diff --git a/doc/tutorial/Gatherer.gif b/doc/tutorial/Gatherer.gif new file mode 100644 index 000000000..758b8ea8b Binary files /dev/null and b/doc/tutorial/Gatherer.gif differ diff --git a/doc/tutorial/GathererEng.gf b/doc/tutorial/GathererEng.gf new file mode 100644 index 000000000..3dfc7c8fd --- /dev/null +++ b/doc/tutorial/GathererEng.gf @@ -0,0 +1,5 @@ +concrete GathererEng of Gatherer = PaleolithicEng, FishEng, MushroomsEng ** { + lin + UseFish x = x ; + UseMushroom x = x ; +} diff --git a/doc/tutorial/Mushrooms.gf b/doc/tutorial/Mushrooms.gf new file mode 100644 index 000000000..87f14de96 --- /dev/null +++ b/doc/tutorial/Mushrooms.gf @@ -0,0 +1,4 @@ +abstract Mushrooms = { + cat Mushroom ; + fun Cep, Agaric : Mushroom ; +} diff --git a/doc/tutorial/MushroomsEng.gf b/doc/tutorial/MushroomsEng.gf new file mode 100644 index 000000000..d4e18d6d4 --- /dev/null +++ b/doc/tutorial/MushroomsEng.gf @@ -0,0 +1,5 @@ +concrete MushroomsEng of Mushrooms = { + lin + Cep = {s = "cep"} ; + Agaric = {s = "agaric"} ; +} diff --git a/doc/tutorial/Neolithic.gf b/doc/tutorial/Neolithic.gf new file mode 100644 index 000000000..2f5c6d116 --- /dev/null +++ b/doc/tutorial/Neolithic.gf @@ -0,0 +1,5 @@ +abstract Neolithic = Paleolithic ** { + fun + Fire, Wheel : CN ; + Think : V ; +} diff --git a/doc/tutorial/NeolithicEng.gf b/doc/tutorial/NeolithicEng.gf new file mode 100644 index 000000000..005781a7e --- /dev/null +++ b/doc/tutorial/NeolithicEng.gf @@ -0,0 +1,6 @@ +concrete NeolithicEng of Neolithic = PaleolithicEng ** { + lin + Fire = {s = "fire"} ; + Wheel = {s = "wheel"} ; + Think = {s = "thinks"} ; +} diff --git a/doc/tutorial/gf-tutorial2.html b/doc/tutorial/gf-tutorial2.html index 18e5342ab..51b300cd1 100644 --- a/doc/tutorial/gf-tutorial2.html +++ b/doc/tutorial/gf-tutorial2.html @@ -11,15 +11,18 @@ 3rd Edition, for GF version 2.2 or later -

+

Aarne Ranta -

aarne@cs.chalmers.se -

+ +

+ +12 May 2005 + @@ -29,12 +32,13 @@ The term GF is used for different things:

-This tutorial is about the GF program and the GF programming language. +This tutorial is primarily about the GF program and +the GF programming language. It will guide you

+ -

The GF program

+

Getting the GF program

The program is open-source free software, which you can download from the GF Homepage:
@@ -60,8 +65,8 @@ There you can download
  • 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 don't -need to know Haskell or Java to use GF. +compilers. But normally you don't have to compile, and you definitely +don't need to know Haskell or Java to use GF.

    @@ -127,7 +132,7 @@ you imported. Try parsing something else, and you fail > p "hello world" No success in cf parsing no tree found -

    +
    @@ -183,6 +188,7 @@ generate ten strings with one and the same command: To generate all sentence that a grammar can generate, use the command generate_trees = gt.
    +  > generate_trees | l
       this louse laughs
       this louse sleeps
       this louse swims
    @@ -197,12 +203,13 @@ 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,
     
    -  h gr
    +  help gr
     
    Quiz. If the command gt generated all trees in your grammar, it would never terminate. Why? +

    More on pipes; tracing

    @@ -509,10 +516,38 @@ Each module is compiled into a .gfc file. Import PaleolithicEng.gf and try what happens
    -
    +  > i PaleolithicEng.gf
     
    -Nothing more than before, except that the GFC files -are generated. +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 compiles, 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. + + + + +

    Multilingual grammar

    + +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. + + @@ -554,17 +589,39 @@ lin 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
     
    -Inspect the shell state (print_options = po): + + + +

    The multilingual shell state

    + +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
    @@ -574,11 +631,86 @@ Inspect the shell state (print_options = po):
     
     
     
    -

    Extending the grammar

    +

    Extending a grammar

    -Neolithic: fire, wheel, think,... +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. + +

    Multiple inheritance

    + +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 in 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 ;
    +    }
    +
    + + + + +

    Visualizing module structure

    + +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 below. + +

    + + + \ No newline at end of file