[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lojban] Computer grammar question: non-left recursive RPN?




Le 7 nov. 04, à 09:18, Robin Lee Powell a écrit :

Lojban has a reverse polish (i.e. postfix math) mode built in.

The ABNF form of this rule is:

rp-expression = rp-operand rp-operand operator

rp-operand = operand / rp-expression

which does exactly what you'd expect.

I can't figure out a way to convert this into a version without left
recursion.  I've got:

rp-expression = operand rp-expression-tail
rp-expression-tail = rp-expression operator rp-expression-tail / ()

(where () is the empty production), but I'm not at all certain it's
equivalent, and the parse trees it produces look very wrong (i.e.
not left recursive at all).

Help?


(I assume from the ABNF grammar above that a RP expression has at least 2 operands and 1 operator)


What about :

rp-expression = operand operand rp-tail
rp-tail = operand rp-tail / operator

?

--
Raphaël

Attachment: PGP.sig
Description: =?ISO-8859-1?Q?Ceci_est_une_signature_=E9lectronique_PGP?=