Alternative grammar for Jevko

Darius J Chuck

2021-12-10 12:00

In the previous article Jevko has been defined as follows:

Value = *(Subvalue / Primitive)
Primitive = 1*Symbol
Subvalue = "[" Value "]"
Symbol = Escape / %x0-5a / %x5e-d7ff / %xe000-10ffff
Escape = "\" ("\" / "[" / "]")

This grammar is technically ambiguous. This ambiguity can be removed by allowing Primitive to be empty:

Primitive = *Symbol

and then redefining Value and Subvalue as follows:

Value = *Subvalue Primitive
Subvalue = Primitive "[" Value "]"

Which removes the ambiguity, leaving us with the following grammar:

Value = *Subvalue Primitive
Primitive = *Symbol
Subvalue = Primitive "[" Value "]"
Symbol = Escape / %x0-5a / %x5e-d7ff / %xe000-10ffff
Escape = "\" ("\" / "[" / "]")

This is the correct interpretation of the original grammar.

Appendix

An equivalent grammar can be written in 2 lines:

Value = *(*Symbol "[" Value "]") *Symbol
Symbol = %x0-5a / "\" %x5b-5d / %x5e-d7ff / %xe000-10ffff