GRAMMAR meko.

 # MEERTENS/KOSTER Affix Grammar for Basic English
 # original version 1962, resuscitated 1991/1992.
 # This grammar is just a relatively large example
 # not intended as a contribution to linguistics.
 # Adapted to AGFL VERSION 2.3 in December 2003
 # by C.H.A. Koster. Have fun with it!

LEXICON smallex
DEFINES
    ADJE(COMP),
    ADVB,
    ART(NUMB),
    AUXV(TIME),
    COP I, COP S, COP P,
    DET(NUMB),
    NOUN(NUMB,CASE),
    PERS PRON(NUMB,PERS,CASE),
    POSS PRON,
    PREPOS, PREPOS(PREP),
    REL PRON(CASE),
    TO BE(TENS),
    TO BE(TIME,NUMB,PERS),
    TO HAVE(TENS),
    TO HAVE(TIME,NUMB,PERS),
    VERB I(TRAN,PREP),
    VERB S(TRAN,PREP),
    VERB PAPL(TRAN,PREP),
    VERB PAST(TRAN,PREP),
    VERB PRPL(TRAN,PREP).

ROOT root.

root:
    noun phrase(NUMB,PERS,CASE).

#--------------------------META SYNTAX-------------------------#

NUMB:: sing | plur.

PERS:: first | secnd | third.

CASE:: nom | gen | dat | acc.

TRAX:: trav | ditr.

TRAN:: TRAX | intr.

PREP:: none | to | from | at.

TENS:: infi | prpl | papl.

TIME:: prst | past.

COMP:: abso | comp | supl.

sentence:
    question;
    statement;
    order;
    SVCO phrase,coordinator,sentence.

statement:
    SVCO phrase,[ "." ].

question:
    vSvCO phrase,[ "?" ];
    localisator,vSvCO phrase,[ "?" ];
    object question,vSvCnO phrase,[ "?" ];
    PREPOS(PREP),object question,vSvOnC phrase(PREP),[ "?" ];
    xSvCO phrase,[ "?" ].

order: VCO phrase(plur,secnd),[ "!" ].

coordinator:
    "and"; "or"; ",".

localisator:
    "when"; "where"; "why".

object question:
    "what",[ object without determiner ];
    "which",object without determiner;
    "whose",object without determiner.

circumstance:
    "here"; "there"; "everywhere";
    modifier;
    subordinator,SVCO phrase;
    localisator,SVCO phrase.

subordinator:
    "if"; "since"; "because"; "although".

#--------------------------SENTENCE PHRASE---------------------#

SVCO phrase:
    [ circumstance ],subject(NUMB,PERS),VCO phrase(NUMB,PERS).

SVOnC phrase(PREP):
    subject(NUMB,PERS),VOnC phrase(PREP,NUMB,PERS).

SVCnO phrase:
    subject(NUMB,PERS),VCnO phrase(NUMB,PERS).

#--------------------------NOUN PHRASE-------------------------#

subject(NUMB,PERS):
    noun phrase(NUMB,PERS,nom).

noun phrase(NUMB,PERS,CASE):
    noun part(NUMB,PERS,CASE),rel phrase/
       "(", noun part,rel phrase, ")";
    noun part(NUMB,PERS,CASE)/
       "(", noun part, ")".
noun phrase(plur,PERS,CASE):
    noun part(NUMB,PERS,CASE),coordinator,
       noun phrase(NUMB1,PERS1,CASE)/
        "(", noun part,coordinator,noun phrase, ")".

noun part(NUMB,third,CASE):
    [ ART(NUMB) ],noun group(NUMB,CASE),
       (participle(TRAN,PREP,papl),CnO phrase(TRAN,PREP);
        circumstance; );
    DET(NUMB),[  "of" ],noun group(NUMB,CASE),
       (participle(TRAN,PREP,papl),CnO phrase(TRAN,PREP);
        circumstance; );
    noun group(sing,gen),noun group(NUMB,CASE),
       (participle(TRAN,PREP,papl),CnO phrase(TRAN,PREP);
        circumstance; );
    number(NUMB),noun group(NUMB,CASE),
       (participle(TRAN,PREP,papl),CnO phrase(TRAN,PREP);
        circumstance; );
    POSS PRON,noun group(NUMB,CASE),
       (participle(TRAN,PREP,papl),CnO phrase(TRAN,PREP);
        circumstance; ).
noun part(sing,third,CASE):
    "what",SVCnO phrase;
    "that",SVCO phrase;
    [ "not" ],participle(TRAN,PREP,prpl),CO phrase(TRAN,PREP);
    "to",infinitive(TRAN,PREP),CO phrase(TRAN,PREP).
noun part(NUMB,PERS,CASE):
    number(NUMB),"of ",noun part(NUMB,PERS,CASE);
    PERS PRON(NUMB,PERS,CASE).
noun part(sing,third,CASE):
  proper name.

proper name:
  name prefix,proper name;
  $MATCH("[A-Z][a-z]*"),[proper name].

name prefix: "Mr."; "Mrs."; "Miss."; "Ms.";
  $MATCH("[A-Z]\.").

noun group(NUMB,CASE):
    adjective phrase,noun group(NUMB,CASE);
    participle(TRAN,PREP,prpl | papl),noun group(NUMB,CASE);
    NOUN(NUMB,CASE);
    NOUN(NUMB1,nom),NOUN(NUMB,CASE).

rel phrase:
    REL PRON(nom),VCO phrase(NUMB,PERS);
    REL PRON(gen),oSVC phrase;
    PREPOS(PREP),REL PRON(dat),SVOnC phrase(PREP);
    REL PRON(dat),SVOnC phrase(PREP),PREPOS(PREP);
    REL PRON(dat),SVOnC phrase(to);
    SVOnC phrase(PREP),PREPOS(PREP);
    [ REL PRON(acc) ],SVCnO phrase.

oSVC phrase:
    object without determiner,SVCnO phrase.

object compl(PREP):
    PREPOS(PREP),noun phrase(NUMB,PERS,dat).

indirect object(PREP):
    PREPOS(PREP),noun phrase(NUMB,PERS,dat).
indirect object(to):
    noun phrase(NUMB,PERS,dat).

modifier:
    PREPOS,(noun phrase(NUMB,PERS,dat); number(NUMB)).

object without determiner:
    noun group(NUMB,acc).

object:
    noun phrase(NUMB,PERS,acc).

object(trav|ditr):
    noun phrase(NUMB,PERS,acc).

predicate:
    adjective phrase;
    noun phrase(NUMB,PERS,nom);
    circumstance;
    participle(TRAN,PREP,papl),CO phrase(TRAN,PREP).


#--------------------------VERB PHRASE-------------------------#

VOnC phrase(PREP,NUMB,PERS):
    verb phrase(TRAN,PREP,TIME,NUMB,PERS),OnC phrase(TRAN);
    to be(TIME,NUMB,PERS),[ predicate ],[ circumstance ].

VCnO phrase(NUMB,PERS):
    verb phrase(TRAX,PREP,TIME,NUMB,PERS),
       CnO phrase(TRAX,PREP);
    to be(TIME,NUMB,PERS),[ circumstance ].

VCO phrase(NUMB,PERS):
    verb phrase(TRAN,PREP,TIME,NUMB,PERS),CO phrase(TRAN,PREP);
    to be(TIME,NUMB,PERS),[ predicate ],[ circumstance ].

CO phrase(intr,PREP):
    [ circumstance ].
CO phrase(trav,PREP):
    object,[ circumstance ].
CO phrase(ditr,PREP):
    indirect object(PREP),object,[ circumstance ];
    object,object compl(PREP),[ circumstance ].

CnO phrase(intr|trav,PREP): [ circumstance ].
CnO phrase(ditr,PREP): object compl(PREP),[ circumstance ].

verb phrase(TRAN,PREP,TIME,NUMB,PERS):
    [ adverb ],verb form(TRAN,PREP,TIME,NUMB,PERS);
    TO BE(TIME,NUMB,PERS),participle(TRAN,PREP,prpl);
    copula(TIME,NUMB,PERS),"to",infinitive(TRAN,PREP);
    auxv(TIME,NUMB,PERS),infinitive(TRAN,PREP);
    TO HAVE(TIME,NUMB,PERS),participle(TRAN,PREP,papl);
    TO HAVE(TIME,NUMB,PERS),[ adverb ],TO BE(papl),
       participle(TRAN,PREP,prpl).
verb phrase(intr,PREP,TIME,NUMB,PERS):
    TO BE(TIME,NUMB,PERS),participle(trav,PREP,papl);
    TO HAVE(TIME,NUMB,PERS),[ adverb ],TO BE(papl),
       participle(trav,PREP,papl).

xSvCO phrase:
    TO BE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(TRAN,PREP,prpl),CO phrase(TRAN,PREP);
    TO BE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(trav,PREP,papl),CO phrase(intr,PREP);
    TO HAVE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(TRAN,PREP,papl),CO phrase(TRAN,PREP);
    TO HAVE(TIME,NUMB,PERS),subject(NUMB,PERS),[ adverb ],
       TO BE(papl),participle(TRAN,PREP,prpl),CO phrase(TRAN,PREP);
    TO HAVE(TIME,NUMB,PERS),subject(NUMB,PERS),[ adverb ],
       TO BE(papl),participle(trav,PREP,papl),CO phrase(intr,PREP).

vSvCO phrase:
    auxv(TIME,NUMB,PERS),subject(NUMB,PERS),infinitive(TRAN,PREP),
       CO phrase(TRAN,PREP);
    to be(TIME,NUMB,PERS),subject(NUMB,PERS),[ predicate ],
       [ circumstance ].

vSvCnO phrase:
    auxv(TIME,NUMB,PERS),subject(NUMB,PERS),
       infinitive(TRAX,PREP),CnO phrase(TRAX,PREP);
    TO BE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(TRAX,PREP,prpl),CnO phrase(TRAN,PREP);
    TO HAVE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(TRAX,PREP,papl),CnO phrase(TRAN,PREP).

vSvOnC phrase(PREP):
    auxv(TIME,NUMB,PERS),subject(NUMB,PERS),infinitive(TRAN,PREP),
       [ object(TRAN) ],[ PREPOS(PREP) ],[ circumstance ];
    TO BE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(TRAN,PREP,prpl),OnC phrase(TRAN);
    TO HAVE(TIME,NUMB,PERS),subject(NUMB,PERS),
       participle(TRAN,PREP,papl),OnC phrase(TRAN).

OnC phrase(TRAN):
    [ object(TRAN) ],[ circumstance ].

#--------------------------ADJECTIVE PHRASE--------------------#

adjective phrase:
    [ adverb ],ADJE(abso);
    "so",adjective phrase,[ "that",SVCO phrase ];
    "as",ADJE(abso),"as",noun phrase(NUMB,PERS,CASE);
    "more",ADJE(abso),[ "than",noun phrase(NUMB,PERS,CASE) ];
    ADJE(COMP),[ "than",noun phrase(NUMB,PERS,CASE) ];
    "most",ADJE(abso);
    ADJE(supl).

adverb:
    ADVB.

#--------------------------NUMBERS-----------------------------#

number(sing): "one".
number(sing): "1".

number(plur):
    "zero";
    thousands;
    hundreds;
    tens, [ digits ];
    twens;
    mores.
number (plur):
    $MATCH("[123456789][0123456789]\[ 1,\ ]");
    $MATCH("[23456789]").

thousands:
    [ singles ],"thousand",(hundreds; tens; singles; ).

hundreds:
    [ singles ],"hundred",([ "and" ],tens; [ "and" ],singles; ).

tens:
    "twenty"; "thirty"; "fourty"; "fifty"; "sixty";
    "seventy"; "eighty"; "ninety".

singles:
    digits;
    twens.

twens:
    "ten"; "eleven"; "twelve"; "thirteen"; "fourteen";
    "fifteen"; "sixteen"; "seventeen"; "eighteen"; "nineteen".

digits:
    "one";
    mores.

mores:       "two"; "three"; "four"; "five";
    "six"; "seven"; "eight"; "nine".

#--------------------------MORPHOLOGY--------------------------#
# or,rather,interface to the lexicon #

auxv(TIME,NUMB,PERS):
    AUXV(TIME),[ "not" ].

verb form(TRAN,PREP,prst,NUMB,first | secnd):
    VERB I(TRAN,PREP).
verb form(TRAN,PREP,prst,sing,third):
    VERB S(TRAN,PREP).
verb form(TRAN,PREP,prst,plur,third):
    VERB I(TRAN,PREP).
verb form(TRAN,PREP,past,NUMB,PERS):
    VERB PAST(TRAN,PREP).

verb form(TRAN,PREP,prpl):
    VERB PRPL(TRAN,PREP).
verb form(TRAN,PREP,papl):
    VERB PAPL(TRAN,PREP).

copula(prst,NUMB,first | secnd): COP I.
copula(prst,sing,third): COP S.
copula(prst,plur,third): COP I.
copula(past,NUMB,PERS): COP P.
copula(infi): COP I.

infinitive(TRAN,PREP):
    adverb,infinitive(TRAN,PREP).
infinitive(TRAN,PREP):
    VERB I(TRAN,PREP);
    copula(infi),"to",infinitive(TRAN,PREP);
    TO BE(infi),participle(TRAN,PREP,prpl);
    TO HAVE(infi),participle(TRAN,PREP,papl);
    TO HAVE(infi),TO BE(papl),participle(TRAN,PREP,prpl).
infinitive(intr,PREP):
    TO BE(infi),participle(trav,PREP,papl);
    TO HAVE(infi),TO BE(papl),participle(trav,PREP,papl).

participle(TRAN,PREP,TENS):
    [ adverb ],verb form(TRAN,PREP,TENS).
participle(TRAN,PREP,prpl):
    TO HAVE(prpl),verb form(TRAN,PREP,papl).

to be(TIME,NUMB,PERS):
    TO BE(TIME,NUMB,PERS),[ "not" ];
    copula(TIME,NUMB,PERS),[ "not" ],"to",TO BE(infi);
    auxv(TIME,NUMB,PERS),[ "not" ],[ copula(infi),"to" ],
       (TO BE(infi);
        TO HAVE(infi),TO BE(papl)).

