number subgrammar
For computer applications of Lojban, there needs to be a formal grammar of numbers. I started from xorxes' grammar below, and revised it in places and made it into a PEG grammar.
I intend to meet all the rules in chapter 18 of CLL, except the one where it contradicts Lojban for Beginners, and LfB has the more useful reading. Namely, you can have a decimal point inside a "digit" (segment) of a mixed-base number like a time.
This involves defining 14 new selma'o. SA is not handled yet (what should it do inside a number?) Also, letters mixed with numbers are not handled, but I consider this a feature and not a bug.
The "number" rule in the existing grammar is replaced, and these rules are inserted:
digit <- NO / TUhO
digits <- digit+
thousand <- digits? KIhO
whole <- thousand+ digits? / digits
approx <- whole / MAhU
after-decimal <- whole? ( RAhE whole? / JIhI approx? )?
approx-decimal <- (whole? PI)? approx
decimal2 <- whole (PI after-decimal / JIhI approx-decimal)? / PAI
decimal1 <- MAhU? decimal2 / MAhU
decimal <- decimal1 CEhI?
digitplace <- decimal PIhE?
tuple <- digitplace+
real <- decimal / tuple / indef
indef <- PI? RO / TUhO
fraction <- real? FIhU fraction? / real
complex <- fraction? KAhO fraction? / fraction
quantity <- real / fraction / DAhA quantity
range <- DAhA? SUhO quantity?
number <- indef number / range+ / complex / quantity
NO <- pre-cmavo NO-words post-cmavo
NO-words <- "no" / "pa" / "re" / "ci" / "vo" / "mu" / "xa" / "ze" / "bi" / "so" / "dau" / "fei" / "gai" / "jau" / "rei" / "vai" / "0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9"
MAhU <- pre-cmavo MAhU-words post-cmavo
MAhU-words <- "ma'u" / "ni'u"
SUhO <- pre-cmavo SUhO-words post-cmavo
SUhO-words <- "su'e" / "su'o" / "me'i" / "za'u"
TUhO <- pre-cmavo TUhO-words post-cmavo
TUhO-words <- "tu'o" / "xo"
PAI <- pre-cmavo PAI-words post-cmavo
PAI-words <- "pai" / "te'o" / "ci'i"
CEhI <- pre-cmavo CEhI-words post-cmavo
CEhI-words <- "ce'i"
KIhO <- pre-cmavo KIhO-words post-cmavo
KIhO-words <- "ki'o"
PI <- pre-cmavo PI-words post-cmavo
PI-words <- "pi"
PIhE <- pre-cmavo PIhE-words post-cmavo
PIhE-words <- "pi'e"
RAhE <- pre-cmavo RAhE-words post-cmavo
RAhE-words <- "ra'e"
RO <- pre-cmavo RO-words post-cmavo
RO-words <- "ro" / "so'a" / "so'e" / "so'i" / "so'o" / "so'u" / "rau" / "du'e" / "mo'a" / "no'o"
JIhI <- pre-cmavo JIhI-words post-cmavo
JIhI-words <- "ji'i"
KAhO <- pre-cmavo KAhO-words post-cmavo
KAhO-words <- "ka'o"
DAhA <- pre-cmavo DAhA-words post-cmavo
DAhA-words <- "da'a"
FIhU <- pre-cmavo FIhU-words post-cmavo
FIhU-words <- "fi'u"
mi'e rab.spir
Grammar proposed by xorxes (work in progress):
number <- quantifier / complex
quantifier <- quantity* FIhU quantity* / quantity+ / PI quantity / real CEhI
quantity <- SUhO* RO / SUhO+ digits? / digits
complex <- real? KAhO real? / real
real <- SUhO* MAhU? (decimal / fraction / aleph / digits / PAI)
decimal <- digits? PI digits? (RAhE digits)?
fraction <- digits? FIhU digits?
aleph <- CIhI digits*
digits <- NO+ / TUhO
New selma'o
<tab class=wikitable> NO no, pa, re, ci, vo, mu, xa, ze, bi, so, dau, fei, gai, jau, rei, vai, ki'o, pi'e RO ro, so'a, so'e, so'i, so'o, so'u, rau, du'e, mo'a, no'o SUhO su'o, su'e, me'i, za'u, ji'i, da'a MAhU ma'u, ni'u TUhO tu'o, xo CIhI ci'i PAI pai, te'o FIhU fi'u KAhO ka'o PI pi RAhE ra'e CEhI ce'i </tab>
Notes:
- I made da'a a SUhO. For da'a in front of a number I propose the following interpretation: ta mitre li da'a cipimu, that is all but 3.5 meters long, i.e. that is 3.5 meters short of what it ought to be or something like that.
- I made ji'i a SUhO because it is also used to indicate a range. This means that I don't use the position of ji'i as an indicator of the magnitude of fuzziness.
- Any SUhO in front of a quantity returns another quantity, so they can be added indefinitely, even though in usage they probably won't be. For example, za'u za'u za'u pa, more than more than more than one is equivalent to su'o vo, at least four (when dealing with integers/quantifiers).
- pi'e and ki'o can mingle freely with digits, collapsing digits between pi'e or ki'os, or between these and pi into a single macro-digit. ki'o is the special case of pi'e for base 1000. Digits after pi are decimal unless there is at least one ki'o or pi'e after pi.
- Two quantities in a row give the intersection if it exists, else the union. They group from left to right.