Produced by gfdoc - a rudimentary GF document generator. (c) Aarne Ranta (aarne@cs.chalmers.se) 2002 under GNU GPL.
incomplete resource Constructors = open Grammar in { flags optimize=noexpand ;
This module gives access to the syntactic constructions of the
GF Resource Grammar library. Its main principle is simple:
to construct an object of type C
, use the function mkC
.
For example, an object of type S
corresponding to the string
John loves Mary
is written
mkS (mkCl (mkNP (mkPN "John")) (mkV2 "love") (mkNP (mkPN "Mary")))
This module defines the syntactic constructors, which take trees as arguments.
Lexical constructors, which take strings as arguments, are defined in the
Paradigms
modules separately for each language.
The recommended usage of this module is via the wrapper module Syntax
,
which also contains the Structural
(structural words).
Together with Paradigms
, Syntax
gives everything that is needed
to implement the concrete syntax for a langauge.
To make the library easier to grasp and navigate, we have followed a set of principles when organizing it:
C
has an overloaded constructor mkC
, with value type C
.
mkC
, it is possible to construct any tree of type C
, except
atomic ones, i.e. those that take no arguments, and
those whose argument types are exactly the same as in some other instance
C
, a constant suffixed C
, and,
for other missing constructions, some operation suffixed C
.
These constructors are listed immediately after the mkC
group.
Structural
are not repeated here.
mkC
groups
include some frequently needed special cases, with two possible logics:
default value (to decrease the number of arguments), and
direct arguments of an intervening constructor (to flatten the terms).
A text is a list of phrases separated by punctuation marks. The default punctuation mark is the full stop, and the default continuation of a text is empty.
oper mkText : overload { mkText : Phr -> Text ; -- 1. But John walks. mkText : Phr -> (Punct) -> (Text) -> Text ; -- 2. John walks? Yes.
A text can also be directly built from utterances, which in turn can be directly built from sentences, present-tense clauses, questions, or positive imperatives.
mkText : Utt -> Text ; -- 3. John. mkText : S -> Text ; -- 4. John walked. mkText : Cl -> Text ; -- 5. John walks. mkText : QS -> Text ; -- 6. Did John walk? mkText : Imp -> Text -- 7. Walk! } ;
A text can also be empty.
emptyText : Text ; -- 8. (empty text)
There are three punctuation marks that can separate phrases in a text.
fullStopPunct : Punct ; -- . questMarkPunct : Punct ; -- ? exclMarkPunct : Punct ; -- !
Phrases are built from utterances by adding a phrasal conjunction and a vocative, both of which are by default empty.
mkPhr : overload { mkPhr : Utt -> Phr ; -- 1. why mkPhr : (PConj) -> Utt -> (Voc) -> Phr ; -- 2. but why John
A phrase can also be directly built by a sentence, a present-tense clause, a question, or a positive singular imperative.
mkPhr : S -> Phr ; -- 3. John walked mkPhr : Cl -> Phr ; -- 4. John walks mkPhr : QS -> Phr ; -- 5. did John walk mkPhr : Imp -> Phr -- 6. walk } ;
Any conjunction can be used as a phrasal conjunction.
More phrasal conjunctions are defined in Structural
.
mkPConj : Conj -> PConj ; -- 1. and
Any noun phrase can be turned into a vocative.
More vocatives are defined in Structural
.
mkVoc : NP -> Voc ; -- 1. John
Utterances are formed from sentences, clauses, questions, and positive singular imperatives.
mkUtt : overload { mkUtt : S -> Utt ; -- 1. John walked mkUtt : Cl -> Utt ; -- 2. John walks mkUtt : QS -> Utt ; -- 3. did John walk mkUtt : Imp -> Utt ; -- 4. love yourself
Imperatives can also vary in ImpForm
(number/politeness) and
polarity.
mkUtt : (ImpForm) -> (Pol) -> Imp -> Utt ; -- 5. don't love yourselves
Utterances can also be formed from interrogative phrases and interrogative adverbials, noun phrases, adverbs, and verb phrases.
mkUtt : IP -> Utt ; -- 6. who mkUtt : IAdv -> Utt ; -- 7. why mkUtt : NP -> Utt ; -- 8. John mkUtt : Adv -> Utt ; -- 9. here mkUtt : VP -> Utt -- 10. to walk } ;
The plural first-person imperative is a special construction.
lets_Utt : VP -> Utt ; -- 11. let's walk
Polarity is a parameter that sets a clause to positive or negative form. Since positive is the default, it need never be given explicitly.
positivePol : Pol ; -- (John walks) [default] negativePol : Pol ; -- (John doesn't walk)
Anteriority is a parameter that presents an event as simultaneous or anterior to some other reference time. Since simultaneous is the default, it need never be given explicitly.
simultaneousAnt : Ant ; -- (John walks) [default] anteriorAnt : Ant ; -- (John has walked) --# notpresent
Tense is a parameter that relates the time of an event to the time of speaking about it. Since present is the default, it need never be given explicitly.
presentTense : Tense ; -- (John walks) [default] pastTense : Tense ; -- (John walked) --# notpresent futureTense : Tense ; -- (John will walk) --# notpresent conditionalTense : Tense ; -- (John would walk) --# notpresent
Imperative form is a parameter that sets the form of imperative by reference to the person or persons addressed. Since singular is the default, it need never be given explicitly.
singularImpForm : ImpForm ; -- (help yourself) [default] pluralImpForm : ImpForm ; -- (help yourselves) politeImpForm : ImpForm ; -- (help yourself) (polite singular)
A sentence has a fixed tense, anteriority and polarity.
mkS : overload { mkS : Cl -> S ; -- 1. John walks mkS : (Tense) -> (Ant) -> (Pol) -> Cl -> S ; -- 2. John wouldn't have walked
Sentences can be combined with conjunctions. This can apply to a pair of sentences, but also to a list of more than two.
mkS : Conj -> S -> S -> S ; -- 3. John walks and I run mkS : Conj -> ListS -> S ; -- 4. John walks, I run and you sleep mkS : DConj -> S -> S -> S ; -- 5. either John walk or I run mkS : DConj -> ListS -> S ; -- 6. either John walks, I run or you sleep
A sentence can be prefixed by an adverb.
mkS : Adv -> S -> S -- 7. today, John walks } ;
A clause has a variable tense, anteriority and polarity. A clause can be built from a subject noun phrase with a verb and appropriate arguments.
mkCl : overload { mkCl : NP -> V -> Cl ; -- 1. John walks mkCl : NP -> V2 -> NP -> Cl ; -- 2. John loves her mkCl : NP -> V3 -> NP -> NP -> Cl ; -- 3. John sends it to her mkCl : NP -> VV -> VP -> Cl ; -- 4. John wants to walk mkCl : NP -> VS -> S -> Cl ; -- 5. John says that it is good mkCl : NP -> VQ -> QS -> Cl ; -- 6. John wonders if it is good mkCl : NP -> VA -> AP -> Cl ; -- 7. John becomes old mkCl : NP -> V2A ->NP -> AP -> Cl ; -- 8. John paints it red mkCl : NP -> A -> Cl ; -- 9. John is old mkCl : NP -> A -> NP -> Cl ; -- 10. John is older than her mkCl : NP -> A2 -> NP -> Cl ; -- 11. John is married to her mkCl : NP -> AP -> Cl ; -- 12. John is very old mkCl : NP -> N -> Cl ; -- 13. John is a man mkCl : NP -> CN -> Cl ; -- 14. John is an old man mkCl : NP -> NP -> Cl ; -- 15. John is the man mkCl : NP -> Adv -> Cl ; -- 16. John is here
As the general rule, a clause can be built from a subject noun phrase and a verb phrase.
mkCl : NP -> VP -> Cl ; -- 17. John walks here
Subjectless verb phrases are used for impersonal actions.
mkCl : V -> Cl ; -- 18. it rains mkCl : VP -> Cl ; -- 19. it is raining
Existentials are a special form of clauses.
mkCl : N -> Cl ; -- 20. there is a house mkCl : CN -> Cl ; -- 21. there is an old houses mkCl : NP -> Cl ; -- 22. there are five houses
There are also special forms in which a noun phrase or an adverb is emphasized.
mkCl : NP -> RS -> Cl ; -- 23. it is John that walks mkCl : Adv -> S -> Cl -- 24. it is here John walks } ;
Generic clauses are one with an impersonal subject.
genericCl : VP -> Cl ; -- 25. one walks
A verb phrase is formed from a verb with appropriate arguments.
mkVP : overload { mkVP : V -> VP ; -- 1. walk mkVP : V2 -> NP -> VP ; -- 2. love her mkVP : V3 -> NP -> NP -> VP ; -- 3. send it to her mkVP : VV -> VP -> VP ; -- 4. want to walk mkVP : VS -> S -> VP ; -- 5. know that she walks mkVP : VQ -> QS -> VP ; -- 6. ask if she walks mkVP : VA -> AP -> VP ; -- 7. become old mkVP : V2A -> NP -> AP -> VP ; -- 8. paint it red
The verb can also be a copula (be), and the relevant argument is then the complement adjective or noun phrase.
mkVP : A -> VP ; -- 9. be warm mkVP : AP -> VP ; -- 12. be very warm mkVP : A -> NP -> VP ; -- 10. be older than her mkVP : A2 -> NP -> VP ; -- 11. be married to her mkVP : N -> VP ; -- 13. be a man mkVP : CN -> VP ; -- 14. be an old man mkVP : NP -> VP ; -- 15. be the man mkVP : Adv -> VP ; -- 16. be here
A verb phrase can be modified with a postverbal or a preverbal adverb.
mkVP : VP -> Adv -> VP ; -- 17. sleep here mkVP : AdV -> VP -> VP -- 18. always sleep } ;
Two-place verbs can be used reflexively.
reflexiveVP : V2 -> VP ; -- 19. love itself
Two-place verbs can also be used in the passive, with or without an agent.
passiveVP : overload { passiveVP : V2 -> VP ; -- 20. be loved passiveVP : V2 -> NP -> VP ; -- 21. be loved by her } ;
A verb phrase can be turned into the progressive form.
progressiveVP : VP -> VP ; -- 22. be sleeping
Imperatives are formed from verbs and their arguments; as the general rule, from verb phrases.
mkImp : overload { mkImp : V -> Imp ; -- go mkImp : V2 -> NP -> Imp ; -- take it mkImp : VP -> Imp -- go there now } ;
A noun phrases can be built from a determiner and a common noun (CN
) .
For determiners, the special cases of quantifiers, numerals, integers,
and possessive pronouns are provided. For common nouns, the
special case of a simple common noun (N
) is always provided.
mkNP : overload { mkNP : Det -> N -> NP ; -- 1. the first man mkNP : Det -> CN -> NP ; -- 2. the first old man mkNP : QuantSg -> N -> NP ; -- 3. this man mkNP : QuantSg -> CN -> NP ; -- 4. this old man mkNP : QuantPl -> N -> NP ; -- 5. these men mkNP : QuantPl -> CN -> NP ; -- 6. these old men mkNP : Numeral -> N -> NP ; -- 7. twenty men mkNP : Numeral -> CN -> NP ; -- 8. twenty old men mkNP : Int -> N -> NP ; -- 9. 45 men mkNP : Int -> CN -> NP ; -- 10. 45 old men mkNP : Num -> N -> NP ; -- 11. almost twenty men mkNP : Num -> CN -> NP ; -- 12. almost twenty old men mkNP : Pron -> N -> NP ; -- 13. my man mkNP : Pron -> CN -> NP; -- 14. my old man
Proper names and pronouns can be used as noun phrases.
mkNP : PN -> NP ; -- 15. John mkNP : Pron -> NP ; -- 16. he
A noun phrase once formed can be prefixed by a predeterminer and suffixed by a past participle or an adverb.
mkNP : Predet -> NP -> NP ; -- 17. only John mkNP : NP -> V2 -> NP ; -- 18. John killed mkNP : NP -> Adv -> NP ; -- 19. John in Paris
A conjunction can be formed both from two noun phrases and a longer list of them.
mkNP : Conj -> NP -> NP -> NP ; -- 20. John and I mkNP : Conj -> ListNP -> NP ; -- 21. John, I, and that mkNP : DConj -> NP -> NP -> NP ; -- 22. either John or I mkNP : DConj -> ListNP -> NP -- 23. either John, I, or that } ;
A determiner is either a singular or a plural one. Both have a quantifier and an optional ordinal; the plural determiner also has an optional numeral.
mkDet : overload { mkDet : QuantSg -> Det ; -- 1. this mkDet : QuantSg -> (Ord) -> Det ; -- 2. this first mkDet : QuantPl -> Det ; -- 3. these mkDet : QuantPl -> (Num) -> (Ord) -> Det ; -- 4. these five best
Quantifiers that have both singular and plural forms are by default used as singular determiners. If a numeral is added, the plural form is chosen.
mkDet : Quant -> Det ; -- 5. this mkDet : Quant -> Num -> Det ; -- 6. these five
Numerals, their special cases integers and digits, and possessive pronouns can be used as determiners.
mkDet : Num -> Det ; -- 7. almost twenty mkDet : Numeral -> Det ; -- 8. five mkDet : Int -> Det ; -- 9. 51 mkDet : Pron -> Det -- 10. my } ;
The definite and indefinite articles are commonly used determiners.
defSgDet : Det ; -- 11. the (house) defPlDet : Det ; -- 12. the (houses) indefSgDet : Det ; -- 13. a (house) indefPlDet : Det ; -- 14. (houses)
Definite and indefinite articles have both singular and plural forms (even though the plural indefinite is empty in most languages).
defQuant : Quant ; -- 1. the indefQuant : Quant ; -- 2. a
More quantifiers are available in the Structural
module.
From quantifiers that can have both forms, this constructor builds the singular form.
mkQuantSg : Quant -> QuantSg ; -- 1. this
The mass noun phrase constructor is treated as a singular quantifier.
massQuant : QuantSg ; -- 2. (mass terms)
More singular quantifiers are available in the Structural
module.
From quantifiers that can have both forms, this constructor builds the plural form.
mkQuantPl : Quant -> QuantPl ; -- 1. these
More plural quantifiers are available in the Structural
module.
Numerals can be formed from number words (Numeral
), their special case digits,
and from symbolic integers.
mkNum : overload { mkNum : Numeral -> Num ; -- 1. twenty mkNum : Int -> Num ; -- 2. 51
A numeral can be modified by an adnumeral.
mkNum : AdN -> Num -> Num -- 3. almost ten } ;
Just like cardinals, ordinals can be formed from number words (Numeral
)
and from symbolic integers.
mkOrd : overload { mkOrd : Numeral -> Ord ; -- 1. twentieth mkOrd : Int -> Ord ; -- 2. 51st
Also adjectives in the superlative form can appear on ordinal positions.
mkOrd : A -> Ord -- 3. best } ;
Comparison adverbs can be used as adnumerals.
mkAdN : CAdv -> AdN ; -- 1. more than
Digits and some round numbers are here given as shorthands.
n1_Numeral : Numeral ; -- 1. one n2_Numeral : Numeral ; -- 2. two n3_Numeral : Numeral ; -- 3. three n4_Numeral : Numeral ; -- 4. four n5_Numeral : Numeral ; -- 5. five n6_Numeral : Numeral ; -- 6. six n7_Numeral : Numeral ; -- 7. seven n8_Numeral : Numeral ; -- 8. eight n9_Numeral : Numeral ; -- 9. nine n10_Numeral : Numeral ; -- 10. ten n20_Numeral : Numeral ; -- 11. twenty n100_Numeral : Numeral ; -- 12. hundred n1000_Numeral : Numeral ; -- 13. thousand
See Numeral
for the full set of constructors, or use Int
for other numbers.
mkCN : overload {
The most frequent way of forming common noun phrases is from atomic nouns N
.
mkCN : N -> CN ; -- 1. house
Common noun phrases can be formed from relational nouns by providing arguments.
mkCN : N2 -> NP -> CN ; -- 2. mother of John mkCN : N3 -> NP -> NP -> CN ; -- 3. distance from this city to Paris
Relational nouns can also be used without their arguments.
mkCN : N2 -> CN ; -- 4. son mkCN : N3 -> CN ; -- 5. flight
A common noun phrase can be modified by adjectival phrase. We give special cases of this, where one or both of the arguments are atomic.
mkCN : A -> N -> CN ; -- 6. big house mkCN : A -> CN -> CN ; -- 7. big blue house mkCN : AP -> N -> CN ; -- 8. very big house mkCN : AP -> CN -> CN ; -- 9. very big blue house
A common noun phrase can be modified by a relative clause or an adverb.
mkCN : N -> RS -> CN ; -- 10. house that John loves mkCN : CN -> RS -> CN ; -- 11. big house that John loves mkCN : N -> Adv -> CN ; -- 12. house in the city mkCN : CN -> Adv -> CN ; -- 13. big house in the city
For some nouns it makes sense to modify them by sentences, questions, or infinitives. But syntactically this is possible for all nouns.
mkCN : CN -> S -> CN ; -- 14. rule that John walks mkCN : CN -> QS -> CN ; -- 15. question if John walks mkCN : CN -> VP -> CN ; -- 16. reason to walk
A noun can be used in apposition to a noun phrase, especially a proper name.
mkCN : N -> NP -> CN ; -- 17. king John mkCN : CN -> NP -> CN -- 18. old king John } ;
mkAP : overload {
Adjectival phrases can be formed from atomic adjectives by using the positive form or the comparative with a complement
mkAP : A -> AP ; -- 1. old mkAP : A -> NP -> AP ; -- 2. older than John
Relational adjectives can be used with a complement or a reflexive
mkAP : A2 -> NP -> AP ; -- 3. married to her mkAP : A2 -> AP ; -- 4. married to myself
Some adjectival phrases can take as complements sentences, questions, or infinitives. Syntactically this is possible for all adjectives.
mkAP : AP -> S -> AP ; -- 5. probable that John walks mkAP : AP -> QS -> AP ; -- 6. uncertain if John walks mkAP : AP -> VP -> AP ; -- 7. ready to go
An adjectival phrase can be modified by an adadjective.
mkAP : AdA -> A -> AP ; -- 8. very old mkAP : AdA -> AP -> AP ; -- 9. very very old
Conjunction can be formed from two or more adjectival phrases.
mkAP : Conj -> AP -> AP -> AP ; -- 10. old and big mkAP : Conj -> ListAP -> AP ; -- 11. old, big, and warm mkAP : DConj -> AP -> AP -> AP ; -- 12. either old or big mkAP : DConj -> ListAP -> AP -- 13. either old, big, or warm } ;
mkAdv : overload {
Adverbs can be formed from adjectives.
mkAdv : A -> Adv ; -- 1. warmly
Prepositional phrases are treated as adverbs.
mkAdv : Prep -> NP -> Adv ; -- 2. with John
Subordinate sentences are treated as adverbs.
mkAdv : Subj -> S -> Adv ; -- 3. when John walks
An adjectival adverb can be compared to a noun phrase or a sentence.
mkAdv : CAdv -> A -> NP -> Adv ; -- 4. more warmly than John mkAdv : CAdv -> A -> S -> Adv ; -- 5. more warmly than John walks
Adverbs can be modified by adadjectives.
mkAdv : AdA -> Adv -> Adv ; -- 6. very warmly
Conjunction can be formed from two or more adverbial phrases.
mkAdv : Conj -> Adv -> Adv -> Adv ; -- 7. here and now mkAdv : Conj -> ListAdv -> Adv ; -- 8. with John, here and now mkAdv : DConj -> Adv -> Adv -> Adv ; -- 9. either here or now mkAdv : DConj -> ListAdv -> Adv -- 10. either here, now, or with John } ;
mkQS : overload {
Just like a sentence S
is built from a clause Cl
,
a question sentence QS
is built from
a question clause QCl
by fixing tense, anteriority and polarity.
Any of these arguments can be omitted, which results in the
default (present, simultaneous, and positive, respectively).
mkQS : QCl -> QS ; -- 1. who walks mkQS : (Tense) -> (Ant) -> (Pol) -> QCl -> QS ; -- 2. who wouldn't have walked
Since 'yes-no' question clauses can be built from clauses (see below), we give a shortcut for building a question sentence directly from a clause, using the defaults present, simultaneous, and positive.
mkQS : Cl -> QS -- 3. does John walk } ;
mkQCl : overload {
'Yes-no' question clauses are built from 'declarative' clauses.
mkQCl : Cl -> QCl ; -- 1. does John walk
'Wh' questions are built from interrogative pronouns in subject or object position. The former uses a verb phrase; we don't give shortcuts for verb-argument sequences as we do for clauses. The latter uses the 'slash' category of objectless clauses (see below); we give the common special case with a two-place verb.
mkQCl : IP -> VP -> QCl ; -- 2. who walks mkQCl : IP -> NP -> V2 -> QCl ; -- 3. whom does John love mkQCl : IP -> Slash -> QCl ; -- 4. whom does John love today
Adverbial 'wh' questions are built with interrogative adverbials, with the special case of prepositional phrases with interrogative pronouns.
mkQCl : IAdv -> Cl -> QCl ; -- 5. why does John walk mkQCl : Prep -> IP -> Cl -> QCl ; -- 6. with who does John walk
An interrogative adverbial can serve as the complement of a copula.
mkQCl : IAdv -> NP -> QCl ; -- 7. where is John
Existentials are a special construction.
mkQCl : IP -> QCl -- 8. what is there } ;
mkIP : overload {
Interrogative pronouns can be formed much like noun phrases, by using interrogative determiners.
mkIP : IDet -> N -> IP ; -- 1. which city mkIP : IDet -> (Num) -> (Ord) -> CN -> IP ; -- 2. which five best cities
An interrogative pronoun can be modified by an adverb.
mkIP : IP -> Adv -> IP -- 3. who in Paris } ;
More interrogative pronouns and determiners can be found in Structural
.
In addition to the interrogative adverbs defined in the Structural
lexicon, they
can be formed as prepositional phrases from interrogative pronouns.
mkIAdv : Prep -> IP -> IAdv ; -- 1. in which city
More interrogative adverbs are given in Structural
.
Just like a sentence S
is built from a clause Cl
,
a relative sentence RS
is built from
a relative clause RCl
by fixing the tense, anteriority and polarity.
Any of these arguments
can be omitted, which results in the default (present, simultaneous,
and positive, respectively).
mkRS : overload { mkRS : RCl -> RS ; -- 1. that walk mkRS : (Tense) -> (Ant) -> (Pol) -> RCl -> RS -- 2. that wouldn't have walked } ;
mkRCl : overload {
Relative clauses are built from relative pronouns in subject or object position. The former uses a verb phrase; we don't give shortcuts for verb-argument sequences as we do for clauses. The latter uses the 'slash' category of objectless clauses (see below); we give the common special case with a two-place verb.
mkRCl : RP -> VP -> RCl ; -- 1. that walk mkRCl : RP -> NP -> V2 -> RCl ; -- 2. which John loves mkRCl : RP -> Slash -> RCl ; -- 3. which John loves today
There is a simple 'such that' construction for forming relative clauses from clauses.
mkRCl : Cl -> RCl -- 4. such that John loves her } ;
There is an atomic relative pronoun
which_RP : RP ; -- 1. which
A relative pronoun can be made into a kind of a prepositional phrase.
mkRP : Prep -> NP -> RP -> RP ; -- 2. all the houses in which
mkSlash : overload {
Objectless sentences are used in questions and relative clauses. The most common way of constructing them is by using a two-place verb with a subject but without an object.
mkSlash : NP -> V2 -> Slash ; -- 1. (whom) John loves
The two-place verb can be separated from the subject by a verb-complement verb.
mkSlash : NP -> VV -> V2 -> Slash ; -- 2. (whom) John wants to see
The missing object can also be the noun phrase in a prepositional phrase.
mkSlash : Cl -> Prep -> Slash ; -- 3. (with whom) John walks
An objectless sentence can be modified by an adverb.
mkSlash : Slash -> Adv -> Slash -- 4. (whom) John loves today } ;
The rules in this section are very uniform: a list can be built from two or more expressions of the same category.
mkListS : overload { mkListS : S -> S -> ListS ; -- 1. he walks, I run mkListS : S -> ListS -> ListS -- 2. John walks, I run, you sleep } ;
mkListAdv : overload { mkListAdv : Adv -> Adv -> ListAdv ; -- 1. here, now mkListAdv : Adv -> ListAdv -> ListAdv -- 2. to me, here, now } ;
mkListAP : overload { mkListAP : AP -> AP -> ListAP ; -- 1. old, big mkListAP : AP -> ListAP -> ListAP -- 2. old, big, warm } ;
mkListNP : overload { mkListNP : NP -> NP -> ListNP ; -- 1. John, I mkListNP : NP -> ListNP -> ListNP -- 2. John, I, that } ;