Chapter 21. Formal Grammars

The picture for chapter 21

21.1. EBNF Grammar of Lojban

Lojban Machine Grammar, EBNF Version, Final Baseline

This EBNF document is explicitly dedicated to the public domain by its author, The Logical Language Group, Inc. Contact that organization at: 2904 Beau Lane, Fairfax VA 22031 USA 703-385-0273 (intl: +1 703 385 0273)

Explanation of notation: All rules have the form:

name number= bnf-expression

which means that the grammatical construct name is defined by bnf-expression. The number cross-references this grammar with the rule numbers in the YACC grammar. The names are the same as those in the YACC grammar, except that subrules are labeled with A, B, C, ... in the YACC grammar and with 1, 2, 3, ... in this grammar. In addition, rule 971 is simple_tag in the YACC grammar but stag in this grammar, because of its frequent appearance.

  1. Names in lower case are grammatical constructs.

  2. Names in UPPER CASE are selma'o (lexeme) names, and are terminals.

  3. Concatenation is expressed by juxtaposition with no operator symbol.

  4. | represents alternation (choice).

  5. [] represents an optional element.

  6. & represents and/or (A & B is the same as A | B | A B).

  7. ... represents optional repetition of the construct to the left. Left-grouping is implied; right-grouping is shown by explicit self-referential recursion with no ...

  8. () serves to indicate the grouping of the other operators. Otherwise, ... binds closer than &, which binds closer than |.

  9. # is shorthand for [free ...], a construct which appears in many places.

  10. // encloses an elidable terminator, which may be omitted (without change of meaning) if no grammatical ambiguity results.

text 0=

[NAI ...] [CMENE ... # | (indicators & free ...)] [joik-jek] text-1

text-1 2=

[(I [jek | joik] [[stag] BO] #) ... | NIhO ... #] [paragraphs]

paragraphs 4=

paragraph [NIhO ... # paragraphs]

paragraph 10=

(statement | fragment) [I # [statement | fragment]] ...

statement 11=

statement-1 | prenex statement

statement-1 12=

statement-2 [I joik-jek [statement-2]] ...

statement-2 13=

statement-3 [I [jek | joik] [stag] BO # [statement-2]]

statement-3 14=

sentence | [tag] TUhE # text-1 /TUhU#/

fragment 20=

ek # | gihek # | quantifier | NA # | terms /VAU#/ | prenex | relative-clauses | links | linkargs

prenex 30=

terms ZOhU #

sentence 40=

[terms [CU #]] bridi-tail

subsentence 41=

sentence | prenex subsentence

bridi-tail 50=

bridi-tail-1 [gihek [stag] KE # bridi-tail /KEhE#/ tail-terms]

bridi-tail-1 51=

bridi-tail-2 [gihek # bridi-tail-2 tail-terms] ...

bridi-tail-2 52=

bridi-tail-3 [gihek [stag] BO # bridi-tail-2 tail-terms]

bridi-tail-3 53=

selbri tail-terms | gek-sentence

gek-sentence 54=

gek subsentence gik subsentence tail-terms | [tag] KE # gek-sentence /KEhE#/ | NA # gek-sentence

tail-terms 71=

[terms] /VAU#/

terms 80=

terms-1 ...

terms-1 81=

terms-2 [PEhE # joik-jek terms-2] ...

terms-2 82=

term [CEhE # term] ...

term 83=

sumti | (tag | FA #) (sumti | /KU#/) | termset | NA KU #

termset 85=

NUhI # gek terms /NUhU#/ gik terms /NUhU#/ | NUhI # terms /NUhU#/

sumti 90=

sumti-1 [VUhO # relative-clauses]

sumti-1 91=

sumti-2 [(ek | joik) [stag] KE # sumti /KEhE#/]

sumti-2 92=

sumti-3 [joik-ek sumti-3] ...

sumti-3 93=

sumti-4 [(ek | joik) [stag] BO # sumti-3]

sumti-4 94=

sumti-5 | gek sumti gik sumti-4

sumti-5 95=

[quantifier] sumti-6 [relative-clauses] | quantifier selbri /KU#/ [relative-clauses]

sumti-6 97=

(LAhE # | NAhE BO #) [relative-clauses] sumti /LUhU#/ | KOhA # | lerfu-string /BOI#/ | LA # [relative-clauses] CMENE ... # | (LA | LE) # sumti-tail /KU#/ | LI # mex /LOhO#/ | ZO any-word # | LU text /LIhU#/ | LOhU any-word ... LEhU # | ZOI any-word anything any-word #

sumti-tail 111=

[sumti-6 [relative-clauses]] sumti-tail-1 | relative-clauses sumti-tail-1

sumti-tail-1 112=

[quantifier] selbri [relative-clauses] | quantifier sumti

relative-clauses 121=

relative-clause [ZIhE # relative-clause] ...

relative-clause 122=

GOI # term /GEhU#/ | NOI # subsentence /KUhO#/

selbri 130=

[tag] selbri-1

selbri-1 131=

selbri-2 | NA # selbri

selbri-2 132=

selbri-3 [CO # selbri-2]

selbri-3 133=

selbri-4 ...

selbri-4 134=

selbri-5 [joik-jek selbri-5 | joik [stag] KE # selbri-3 /KEhE#/] ...

selbri-5 135=

selbri-6 [(jek | joik) [stag] BO # selbri-5]

selbri-6 136=

tanru-unit [BO # selbri-6] | [NAhE #] guhek selbri gik selbri-6

tanru-unit 150=

tanru-unit-1 [CEI # tanru-unit-1] ...

tanru-unit-1 151=

tanru-unit-2 [linkargs]

tanru-unit-2 152=

BRIVLA # | GOhA [RAhO] # | KE # selbri-3 /KEhE#/ | ME # sumti /MEhU#/ [MOI #] | (number | lerfu-string) MOI # | NUhA # mex-operator | SE # tanru-unit-2 | JAI # [tag] tanru-unit-2 | any-word (ZEI any-word) ... | NAhE # tanru-unit-2 | NU [NAI] # [joik-jek NU [NAI] #] ... subsentence /KEI#/

linkargs 160=

BE # term [links] /BEhO#/

links 161=

BEI # term [links]

quantifier 300=

number /BOI#/ | VEI # mex /VEhO#/

mex 310=

mex-1 [operator mex-1] ... | FUhA # rp-expression

mex-1 311=

mex-2 [BIhE # operator mex-1]

mex-2 312=

operand | [PEhO #] operator mex-2 ... /KUhE#/

rp-expression 330=

rp-operand rp-operand operator

rp-operand 332=

operand | rp-expression

operator 370=

operator-1 [joik-jek operator-1 | joik [stag] KE # operator /KEhE#/] ...

operator-1 371=

operator-2 | guhek operator-1 gik operator-2 | operator-2 (jek | joik) [stag] BO # operator-1

operator-2 372=

mex-operator | KE # operator /KEhE#/

mex-operator 374=

SE # mex-operator | NAhE # mex-operator | MAhO # mex /TEhU#/ | NAhU # selbri /TEhU#/ | VUhU #

operand 381=

operand-1 [(ek | joik) [stag] KE # operand /KEhE#/]

operand-1 382=

operand-2 [joik-ek operand-2] ...

operand-2 383=

operand-3 [(ek | joik) [stag] BO # operand-2]

operand-3 385=

quantifier | lerfu-string /BOI#/ | NIhE # selbri /TEhU#/ | MOhE # sumti /TEhU#/ | JOhI # mex-2 ... /TEhU#/ | gek operand gik operand-3 | (LAhE # | NAhE BO #) operand /LUhU#/

number 812=

PA [PA | lerfu-word] ...

lerfu-string 817=

lerfu-word [PA | lerfu-word] ...

lerfu-word 987=

BY | any-word BU | LAU lerfu-word | TEI lerfu-string FOI

ek 802=

[NA] [SE] A [NAI]

gihek 818=

[NA] [SE] GIhA [NAI]

jek 805=

[NA] [SE] JA [NAI]

joik 806=

[SE] JOI [NAI] | interval | GAhO interval GAhO

interval 932=

[SE] BIhI [NAI]

joik-ek 421=

joik # | ek #

joik-jek 422=

joik # | jek #

gek 807=

[SE] GA [NAI] # | joik GI # | stag gik

guhek 808=

[SE] GUhA [NAI] #

gik 816=

GI [NAI] #

tag 491=

tense-modal [joik-jek tense-modal] ...

stag 971=

simple-tense-modal [(jek | joik) simple-tense-modal] ...

tense-modal 815=

simple-tense-modal # | FIhO # selbri /FEhU#/

simple-tense-modal 972=

[NAhE] [SE] BAI [NAI] [KI] | [NAhE] (time [space] | space [time]) & CAhA [KI] | KI | CUhE

time 1030=

ZI & time-offset ... & ZEhA [PU [NAI]] & interval-property ...

time-offset 1033=

PU [NAI] [ZI]

space 1040=

VA & space-offset ... & space-interval & (MOhI space-offset)

space-offset 1045=

FAhA [NAI] [VA]

space-interval 1046=

((VEhA & VIhA) [FAhA [NAI]]) & space-int-props

space-int-props 1049=

(FEhE interval-property) ...

interval-property 1051=

number ROI [NAI] | TAhE [NAI] | ZAhO [NAI]

free 32=

SEI # [terms [CU #]] selbri /SEhU/ | SOI # sumti [sumti] /SEhU/ | vocative [relative-clauses] selbri [relative-clauses] /DOhU/ | vocative [relative-clauses] CMENE ... # [relative-clauses] /DOhU/ | vocative [sumti] /DOhU/ | (number | lerfu-string) MAI | TO text /TOI/ | XI # (number | lerfu-string) /BOI/ | XI # VEI # mex /VEhO/

vocative 415=

(COI [NAI]) ... & DOI

indicators 411=

[FUhE] indicator ...

indicator 413=

(UI | CAI) [NAI] | Y | DAhO | FUhO

The following rules are non-formal:

word 1100=

[BAhE] any-word [indicators]

any-word =

any single word (no compound cmavo)

anything =

any text at all, whether Lojban or not

null 1101=

any-word SI | utterance SA | text SU

FAhO is a universal terminator and signals the end of parsable input.

21.2. EBNF Cross-Reference

A

BNF rule #802 802

BAI

BNF rule #972 972

BAhE

BNF rule #1100 1100

BE

BNF rule #160 160

BEI

BNF rule #161 161

BEhO

BNF rule #160 160

BIhE

BNF rule #311 311

BIhI

BNF rule #932 932

BO

BNF rule #5252, BNF rule #383383, BNF rule #385385, BNF rule #371371, BNF rule #135135, BNF rule #136136, BNF rule #1313, BNF rule #9393, BNF rule #9797, BNF rule #22

BOI

BNF rule #3232, BNF rule #385385, BNF rule #300300, BNF rule #9797

BRIVLA

BNF rule #152 152

BU

BNF rule #987 987

BY

BNF rule #987 987

CAI

BNF rule #413 413

CAhA

BNF rule #972 972

CEI

BNF rule #150 150

CEhE

BNF rule #82 82

CMENE

BNF rule #3232, BNF rule #9797, BNF rule #00

CO

BNF rule #132 132

COI

BNF rule #415 415

CU

BNF rule #3232, BNF rule #4040

CUhE

BNF rule #972 972

DAhO

BNF rule #413 413

DOI

BNF rule #415 415

DOhU

BNF rule #32 32

FA

BNF rule #83 83

FAhA

BNF rule #10461046, BNF rule #10451045

FEhE

BNF rule #1049 1049

FEhU

BNF rule #815 815

FIhO

BNF rule #815 815

FOI

BNF rule #987 987

FUhA

BNF rule #310 310

FUhE

BNF rule #411 411

FUhO

BNF rule #413 413

GA

BNF rule #807 807

GAhO

BNF rule #806 806

GEhU

BNF rule #122 122

GI

BNF rule #807807, BNF rule #816816

GIhA

BNF rule #818 818

GOI

BNF rule #122 122

GOhA

BNF rule #152 152

GUhA

BNF rule #808 808

I

BNF rule #1010, BNF rule #1212, BNF rule #1313, BNF rule #22

JA

BNF rule #805 805

JAI

BNF rule #152 152

JOI

BNF rule #806 806

JOhI

BNF rule #385 385

KE

BNF rule #5050, BNF rule #5454, BNF rule #381381, BNF rule #372372, BNF rule #370370, BNF rule #134134, BNF rule #9191, BNF rule #152152

KEI

BNF rule #152 152

KEhE

BNF rule #5050, BNF rule #5454, BNF rule #381381, BNF rule #372372, BNF rule #370370, BNF rule #134134, BNF rule #9191, BNF rule #152152

KI

BNF rule #972 972

KOhA

BNF rule #97 97

KU

BNF rule #9595, BNF rule #9797, BNF rule #8383

KUhE

BNF rule #312 312

KUhO

BNF rule #122 122

LA

BNF rule #97 97

LAU

BNF rule #987 987

LAhE

BNF rule #385385, BNF rule #9797

LE

BNF rule #97 97

LEhU

BNF rule #97 97

LI

BNF rule #97 97

LIhU

BNF rule #97 97

LOhO

BNF rule #97 97

LOhU

BNF rule #97 97

LU

BNF rule #97 97

LUhU

BNF rule #385385, BNF rule #9797

MAI

BNF rule #32 32

MAhO

BNF rule #374 374

ME

BNF rule #152 152

MEhU

BNF rule #152 152

MOI

BNF rule #152 152

MOhE

BNF rule #385 385

MOhI

BNF rule #1040 1040

NA

BNF rule #802802, BNF rule #2020, BNF rule #5454, BNF rule #818818, BNF rule #805805, BNF rule #131131, BNF rule #8383

NAI

BNF rule #802802, BNF rule #807807, BNF rule #818818, BNF rule #816816, BNF rule #808808, BNF rule #413413, BNF rule #10511051, BNF rule #932932, BNF rule #805805, BNF rule #806806, BNF rule #972972, BNF rule #10461046, BNF rule #10451045, BNF rule #152152, BNF rule #00, BNF rule #10331033, BNF rule #10301030, BNF rule #415415

NAhE

BNF rule #374374, BNF rule #385385, BNF rule #136136, BNF rule #972972, BNF rule #9797, BNF rule #152152

NAhU

BNF rule #374 374

NIhE

BNF rule #385 385

NIhO

BNF rule #44, BNF rule #22

NOI

BNF rule #122 122

NU

BNF rule #152 152

NUhA

BNF rule #152 152

NUhI

BNF rule #85 85

NUhU

BNF rule #85 85

PA

BNF rule #817817, BNF rule #812812

PEhE

BNF rule #81 81

PEhO

BNF rule #312 312

PU

BNF rule #10331033, BNF rule #10301030

RAhO

BNF rule #152 152

ROI

BNF rule #1051 1051

SA

BNF rule #1101 1101

SE

BNF rule #802802, BNF rule #807807, BNF rule #818818, BNF rule #808808, BNF rule #932932, BNF rule #805805, BNF rule #806806, BNF rule #374374, BNF rule #972972, BNF rule #152152

SEI

BNF rule #32 32

SEhU

BNF rule #32 32

SI

BNF rule #1101 1101

SOI

BNF rule #32 32

SU

BNF rule #1101 1101

TAhE

BNF rule #1051 1051

TEI

BNF rule #987 987

TEhU

BNF rule #374374, BNF rule #385385

TO

BNF rule #32 32

TOI

BNF rule #32 32

TUhE

BNF rule #14 14

TUhU

BNF rule #14 14

UI

BNF rule #413 413

VA

BNF rule #10451045, BNF rule #10401040

VAU

BNF rule #2020, BNF rule #7171

VEI

BNF rule #3232, BNF rule #300300

VEhA

BNF rule #1046 1046

VEhO

BNF rule #3232, BNF rule #300300

VIhA

BNF rule #1046 1046

VUhO

BNF rule #90 90

VUhU

BNF rule #374 374

XI

BNF rule #32 32

Y

BNF rule #413 413

ZAhO

BNF rule #1051 1051

ZEI

BNF rule #152 152

ZEhA

BNF rule #1030 1030

ZI

BNF rule #10331033, BNF rule #10301030

ZIhE

BNF rule #121 121

ZO

BNF rule #97 97

ZOI

BNF rule #97 97

ZOhU

BNF rule #30 30

any-word

BNF rule #987987, BNF rule #11011101, BNF rule #9797, BNF rule #152152, BNF rule #11001100

anything

BNF rule #97 97

bridi-tail

BNF rule #5050, BNF rule #4040

bridi-tail-1

BNF rule #50 50

bridi-tail-2

BNF rule #5151, BNF rule #5252

bridi-tail-3

BNF rule #52 52

ek

BNF rule #2020, BNF rule #421421, BNF rule #383383, BNF rule #381381, BNF rule #9191, BNF rule #9393

fragment

BNF rule #10 10

free

BNF rule #0 0

gek

BNF rule #5454, BNF rule #385385, BNF rule #9494, BNF rule #8585

gek-sentence

BNF rule #5353, BNF rule #5454

gihek

BNF rule #5151, BNF rule #5252, BNF rule #5050, BNF rule #2020

gik

BNF rule #5454, BNF rule #807807, BNF rule #385385, BNF rule #371371, BNF rule #136136, BNF rule #9494, BNF rule #8585

guhek

BNF rule #371371, BNF rule #136136

indicator

BNF rule #411 411

indicators

BNF rule #00, BNF rule #11001100

interval

BNF rule #806 806

interval-property

BNF rule #10491049, BNF rule #10301030

jek

BNF rule #422422, BNF rule #371371, BNF rule #135135, BNF rule #971971, BNF rule #1313, BNF rule #22

joik

BNF rule #807807, BNF rule #421421, BNF rule #422422, BNF rule #383383, BNF rule #381381, BNF rule #371371, BNF rule #370370, BNF rule #134134, BNF rule #135135, BNF rule #971971, BNF rule #1313, BNF rule #9191, BNF rule #9393, BNF rule #22

joik-ek

BNF rule #382382, BNF rule #9292

joik-jek

BNF rule #370370, BNF rule #134134, BNF rule #1212, BNF rule #491491, BNF rule #152152, BNF rule #8181, BNF rule #00

lerfu-string

BNF rule #3232, BNF rule #987987, BNF rule #385385, BNF rule #9797, BNF rule #152152

lerfu-word

BNF rule #817817, BNF rule #987987, BNF rule #812812

linkargs

BNF rule #2020, BNF rule #151151

links

BNF rule #2020, BNF rule #160160, BNF rule #161161

mex

BNF rule #3232, BNF rule #374374, BNF rule #300300, BNF rule #9797

mex-1

BNF rule #311311, BNF rule #310310

mex-2

BNF rule #311311, BNF rule #312312, BNF rule #385385

mex-operator

BNF rule #374374, BNF rule #372372, BNF rule #152152

number

BNF rule #3232, BNF rule #10511051, BNF rule #300300, BNF rule #152152

operand

BNF rule #312312, BNF rule #385385, BNF rule #381381, BNF rule #332332

operand-1

BNF rule #381 381

operand-2

BNF rule #382382, BNF rule #383383

operand-3

BNF rule #383383, BNF rule #385385

operator

BNF rule #311311, BNF rule #312312, BNF rule #310310, BNF rule #372372, BNF rule #370370, BNF rule #330330

operator-1

BNF rule #371371, BNF rule #370370

operator-2

BNF rule #371 371

paragraph

BNF rule #4 4

paragraphs

BNF rule #44, BNF rule #22

prenex

BNF rule #2020, BNF rule #1111, BNF rule #4141

quantifier

BNF rule #2020, BNF rule #385385, BNF rule #9595, BNF rule #112112

relative-clause

BNF rule #121 121

relative-clauses

BNF rule #2020, BNF rule #3232, BNF rule #9595, BNF rule #9797, BNF rule #112112, BNF rule #111111, BNF rule #9090

rp-expression

BNF rule #310310, BNF rule #332332

rp-operand

BNF rule #330 330

selbri

BNF rule #5353, BNF rule #3232, BNF rule #374374, BNF rule #385385, BNF rule #131131, BNF rule #136136, BNF rule #9595, BNF rule #112112, BNF rule #815815

selbri-1

BNF rule #130 130

selbri-2

BNF rule #131131, BNF rule #132132

selbri-3

BNF rule #132132, BNF rule #134134, BNF rule #152152

selbri-4

BNF rule #133 133

selbri-5

BNF rule #134134, BNF rule #135135

selbri-6

BNF rule #135135, BNF rule #136136

sentence

BNF rule #1414, BNF rule #4141

simple-tense-modal

BNF rule #971971, BNF rule #815815

space

BNF rule #972 972

space-int-props

BNF rule #1046 1046

space-interval

BNF rule #1040 1040

space-offset

BNF rule #1040 1040

stag

BNF rule #5252, BNF rule #5050, BNF rule #807807, BNF rule #383383, BNF rule #381381, BNF rule #371371, BNF rule #370370, BNF rule #134134, BNF rule #135135, BNF rule #1313, BNF rule #9191, BNF rule #9393, BNF rule #22

statement

BNF rule #1010, BNF rule #1111

statement-1

BNF rule #11 11

statement-2

BNF rule #1212, BNF rule #1313

statement-3

BNF rule #13 13

subsentence

BNF rule #5454, BNF rule #122122, BNF rule #4141, BNF rule #152152

sumti

BNF rule #3232, BNF rule #385385, BNF rule #9191, BNF rule #9494, BNF rule #9797, BNF rule #112112, BNF rule #152152, BNF rule #8383

sumti-1

BNF rule #90 90

sumti-2

BNF rule #91 91

sumti-3

BNF rule #9292, BNF rule #9393

sumti-4

BNF rule #9393, BNF rule #9494

sumti-5

BNF rule #94 94

sumti-6

BNF rule #9595, BNF rule #111111

sumti-tail

BNF rule #97 97

sumti-tail-1

BNF rule #111 111

tag

BNF rule #5454, BNF rule #130130, BNF rule #1414, BNF rule #152152, BNF rule #8383

tail-terms

BNF rule #5151, BNF rule #5252, BNF rule #5353, BNF rule #5050, BNF rule #5454

tanru-unit

BNF rule #136 136

tanru-unit-1

BNF rule #150 150

tanru-unit-2

BNF rule #151151, BNF rule #152152

tense-modal

BNF rule #491 491

term

BNF rule #160160, BNF rule #161161, BNF rule #122122, BNF rule #8282

terms

BNF rule #2020, BNF rule #3232, BNF rule #3030, BNF rule #4040, BNF rule #7171, BNF rule #8585

terms-1

BNF rule #80 80

terms-2

BNF rule #81 81

termset

BNF rule #83 83

text

BNF rule #3232, BNF rule #11011101, BNF rule #9797

text-1

BNF rule #1414, BNF rule #00

time

BNF rule #972 972

time-offset

BNF rule #1030 1030

utterance

BNF rule #1101 1101

vocative

BNF rule #32 32