summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/errors/gluing.md27
-rw-r--r--doc/gf-developers.t2t2
-rw-r--r--doc/gf-refman.md19
-rw-r--r--doc/gf-video-tutorials.md35
-rw-r--r--doc/tutorial/gf-tutorial.t2t85
5 files changed, 110 insertions, 58 deletions
diff --git a/doc/errors/gluing.md b/doc/errors/gluing.md
new file mode 100644
index 000000000..111f8406c
--- /dev/null
+++ b/doc/errors/gluing.md
@@ -0,0 +1,27 @@
+## unsupported token gluing `foo + bar`
+
+There was a problem in an expression using +, e.g. `foo + bar`.
+This can be due to two causes, check which one applies in your case.
+
+1. You are trying to use + on runtime arguments. Even if you are using
+`foo + bar` in an oper, make sure that the oper isn't called in a
+linearization that takes arguments. Both of the following are illegal:
+
+ lin Test foo bar = foo.s + bar.s -- explicit + in a lin
+ lin Test foo bar = opWithPlus foo bar -- the oper uses +
+
+2. One of the arguments in `foo + bar` is a bound variable
+from pattern matching a string, but the cases are non-exhaustive.
+Example:
+ case "test" of {
+ x + "a" => x + "b" -- no applicable case for "test", so x = ???
+ } ;
+
+You can fix this by adding a catch-all case in the end:
+ { x + "a" => x + "b" ;
+ _ => "default case" } ;
+
+3. If neither applies to your problem, submit a bug report and we
+will update the error message and this documentation.
+
+ https://github.com/GrammaticalFramework/gf-core/issues
diff --git a/doc/gf-developers.t2t b/doc/gf-developers.t2t
index 74059199b..ed336b9a7 100644
--- a/doc/gf-developers.t2t
+++ b/doc/gf-developers.t2t
@@ -391,6 +391,8 @@ bindings are found in the ``src/runtime/python`` and ``src/runtime/java``
directories, respecively. Compile them by following the instructions in
the ``INSTALL`` files in those directories.
+The Python library can also be installed from PyPI using `pip install pgf`.
+
== Compilation of RGL ==
As of 2018-07-26, the RGL is distributed separately from the GF compiler and runtimes.
diff --git a/doc/gf-refman.md b/doc/gf-refman.md
index 2a53041d9..503a5060c 100644
--- a/doc/gf-refman.md
+++ b/doc/gf-refman.md
@@ -1809,6 +1809,23 @@ As the last rule, subtyping is transitive:
- if *A* is a subtype of *B* and *B* is a subtype of *C*, then *A* is
a subtype of *C*.
+### List categories
+
+[]{#lists}
+
+Since categories of lists of elements of another category are a common idiom, the following syntactic sugar is available:
+
+ cat [C] {n}
+
+abbreviates a set of three judgements:
+
+ cat ListC ;
+ fun BaseC : C -> ... -> C -> ListC ; --n C’s
+ fun ConsC : C -> ListC -> ListC
+
+The functions `BaseC` and `ConsC` are automatically generated in the abstract syntax, but their linearizations, as well as the linearization type of `ListC`, must be defined manually. The type expression `[C]` is in all contexts interchangeable with `ListC`.
+
+More information on lists in GF can be found [here](https://inariksit.github.io/gf/2021/02/22/lists.html).
### Tables and table types
@@ -2113,7 +2130,7 @@ of *x*, and the application thereby disappears.
[]{#reuse}
-*This section is valid for GF 3.0, which abandons the \"lock field\"*
+*This section is valid for GF 3.0, which abandons the \"[lock field](https://inariksit.github.io/gf/2018/05/25/subtyping-gf.html#lock-fields)\"*
*discipline of GF 2.8.*
As explained [here](#openabstract), abstract syntax modules can be
diff --git a/doc/gf-video-tutorials.md b/doc/gf-video-tutorials.md
new file mode 100644
index 000000000..72acce26e
--- /dev/null
+++ b/doc/gf-video-tutorials.md
@@ -0,0 +1,35 @@
+---
+title: "Video tutorials"
+---
+
+The GF [YouTube channel](https://www.youtube.com/channel/UCZ96DechSUVcXAhtOId9VVA) keeps a playlist of [all GF videos](https://www.youtube.com/playlist?list=PLrgqBB5thLeT15fUtJ8_Dtk8ppdtH90MK), and more specific playlists for narrower topics.
+If you make a video about GF, let us know and we'll add it to the suitable playlist(s)!
+
+- [General introduction to GF](#general-introduction-to-gf)
+- [Beginner resources](#beginner-resources)
+- [Resource grammar tutorials](#resource-grammar-tutorials)
+
+## General introduction to GF
+
+These videos introduce GF at a high level, and present some use cases.
+
+__Grammatical Framework: Formalizing the Grammars of the World__
+
+<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/x1LFbDQhbso" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
+
+__Aarne Ranta: Automatic Translation for Consumers and Producers__
+
+<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/An-AmFScw1o" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
+
+## Beginner resources
+
+These videos show how to install GF on your computer (Mac or Windows), and how to play with simple grammars in a [Jupyter notebook](https://github.com/GrammaticalFramework/gf-binder) (any platform, hosted at [mybinder.org](https://mybinder.org)).
+
+<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/videoseries?list=PLrgqBB5thLeRa8eViJJnjT8jBhxqCPMF2" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
+
+## Resource grammar tutorials
+
+These videos show incremental improvements to a [miniature version of the resource grammar](https://github.com/inariksit/comp-syntax-2020/tree/master/lab2/grammar/dummy#readme).
+They assume some prior knowledge of GF, roughly lessons 1-3 from the [GF tutorial](http://www.grammaticalframework.org/doc/tutorial/gf-tutorial.html).
+
+<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/videoseries?list=PLrgqBB5thLeTPkp88lnOmRtprCa8g0wX2" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
diff --git a/doc/tutorial/gf-tutorial.t2t b/doc/tutorial/gf-tutorial.t2t
index 525749822..63407a38a 100644
--- a/doc/tutorial/gf-tutorial.t2t
+++ b/doc/tutorial/gf-tutorial.t2t
@@ -898,7 +898,7 @@ Parentheses are only needed for grouping.
Parsing something that is not in grammar will fail:
```
> parse "hello dad"
- Unknown words: dad
+ The parser failed at token 2: "dad"
> parse "world hello"
no tree found
@@ -2475,7 +2475,7 @@ can be used to read a text and return for each word its analyses
```
The command ``morpho_quiz = mq`` generates inflection exercises.
```
- % gf -path=alltenses:prelude $GF_LIB_PATH/alltenses/IrregFre.gfo
+ % gf alltenses/IrregFre.gfo
> morpho_quiz -cat=V
@@ -2488,11 +2488,6 @@ The command ``morpho_quiz = mq`` generates inflection exercises.
réapparaîtriez
Score 0/1
```
-To create a list for later use, use the command ``morpho_list = ml``
-```
- > morpho_list -number=25 -cat=V | write_file exx.txt
-```
-
@@ -2651,12 +2646,12 @@ The verb //switch off// is called a
We can define transitive verbs and their combinations as follows:
```
- lincat TV = {s : Number => Str ; part : Str} ;
+ lincat V2 = {s : Number => Str ; part : Str} ;
- fun AppTV : Item -> TV -> Item -> Phrase ;
+ fun AppV2 : Item -> V2 -> Item -> Phrase ;
- lin AppTV subj tv obj =
- {s = subj.s ++ tv.s ! subj.n ++ obj.s ++ tv.part} ;
+ lin AppV2 subj v2 obj =
+ {s = subj.s ++ v2.s ! subj.n ++ obj.s ++ v2.part} ;
```
**Exercise**. Define the language ``a^n b^n c^n`` in GF, i.e.
@@ -2722,11 +2717,11 @@ This topic will be covered in #Rseclexing.
The symbol ``**`` is used for both record types and record objects.
```
- lincat TV = Verb ** {c : Case} ;
+ lincat V2 = Verb ** {c : Case} ;
lin Follow = regVerb "folgen" ** {c = Dative} ;
```
-``TV`` becomes a **subtype** of ``Verb``.
+``V2`` (transitive verb) becomes a **subtype** of ``Verb``.
If //T// is a subtype of //R//, an object of //T// can be used whenever
an object of //R// is required.
@@ -2757,7 +2752,11 @@ Thus the labels ``p1, p2,...`` are hard-coded.
English indefinite article:
```
oper artIndef : Str =
- pre {"a" ; "an" / strs {"a" ; "e" ; "i" ; "o"}} ;
+ pre {
+ ("a" | "e" | "i" | "o") => "an" ;
+ _ => "a"
+ } ;
+
```
Thus
```
@@ -2948,7 +2947,7 @@ We need the following combinations:
```
We also need **lexical insertion**, to form phrases from single words:
```
- mkCN : N -> NP ;
+ mkCN : N -> CN ;
mkAP : A -> AP ;
```
Naming convention: to construct a //C//, use a function ``mk``//C//.
@@ -2969,7 +2968,7 @@ can be built as follows:
```
mkCl
(mkNP these_Det
- (mkCN (mkAP very_AdA (mkAP warm_A)) (mkCN pizza_CN)))
+ (mkCN (mkAP very_AdA (mkAP warm_A)) (mkCN pizza_N)))
(mkAP italian_AP)
```
The task now: to define the concrete syntax of ``Foods`` so that
@@ -3718,49 +3717,25 @@ Concrete syntax does not know if a category is a dependent type.
```
Notice that the ``Kind`` argument is suppressed in linearization.
-Parsing with dependent types is performed in two phases:
+Parsing with dependent types consists of two phases:
+ context-free parsing
+ filtering through type checker
+Parsing a type-correct command works as expected:
-By just doing the first phase, the ``kind`` argument is not found:
```
> parse "dim the light"
- CAction ? dim (DKindOne light)
-```
-Moreover, type-incorrect commands are not rejected:
-```
- > parse "dim the fan"
- CAction ? dim (DKindOne fan)
-```
-The term ``?`` is a **metavariable**, returned by the parser
-for any subtree that is suppressed by a linearization rule.
-These are the same kind of metavariables as were used #Rsecediting
-to mark incomplete parts of trees in the syntax editor.
-
-
-
-#NEW
-
-===Solving metavariables===
-
-Use the command ``put_tree = pt`` with the option ``-typecheck``:
-```
- > parse "dim the light" | put_tree -typecheck
CAction light dim (DKindOne light)
```
-The ``typecheck`` process may fail, in which case an error message
-is shown and no tree is returned:
+However, type-incorrect commands are rejected by the typecheck:
```
- > parse "dim the fan" | put_tree -typecheck
-
- Error in tree UCommand (CAction ? 0 dim (DKindOne fan)) :
- (? 0 <> fan) (? 0 <> light)
+ > parse "dim the fan"
+ The parsing is successful but the type checking failed with error(s):
+ Couldn't match expected type Device light
+ against the interred type Device fan
+ In the expression: DKindOne fan
```
-
-
-
#NEW
==Polymorphism==
@@ -3786,23 +3761,19 @@ to express Haskell-type library functions:
\_,_,_,f,x,y -> f y x ;
```
-
#NEW
===Dependent types: exercises===
1. Write an abstract syntax module with above contents
and an appropriate English concrete syntax. Try to parse the commands
-//dim the light// and //dim the fan//, with and without ``solve`` filtering.
-
+//dim the light// and //dim the fan//.
-2. Perform random and exhaustive generation, with and without
-``solve`` filtering.
+2. Perform random and exhaustive generation.
3. Add some device kinds and actions to the grammar.
-
#NEW
==Proof objects==
@@ -3912,7 +3883,6 @@ fun
Classes for new actions can be added incrementally.
-
#NEW
==Variable bindings==
@@ -4200,7 +4170,8 @@ We construct a calculator with addition, subtraction, multiplication, and
division of integers.
```
abstract Calculator = {
-
+ flags startcat = Exp ;
+
cat Exp ;
fun
@@ -4226,7 +4197,7 @@ We begin with a
concrete syntax that always uses parentheses around binary
operator applications:
```
- concrete CalculatorP of Calculator = {
+ concrete CalculatorP of Calculator = open Prelude in {
lincat
Exp = SS ;