I have created a simple markup language that consists of simpe tags to write my blog texts. I write my blog post in that language and convert them into Html by a compiler.
User can specify the document language and that if the document supports the multilanguage? The document can only have two language "Turkish (tr)" and "English (en)".
According to that, the document looks like the followings.
#lang en
#mul yes
And other tags and content...
#lang tr
#mul yes
And other tags and content...
#lang en
#mul no
And other tags and content...
And the grammar for it is as the following using EBNF notation.
YesNo = "yes" | "no"
Doclanguage = #lang "tr" | "en"
Multilingual = #mul YesNo
DocumentHeader = Doclanguage Multilingual
However, I want Doclanguage and Multilingual to be independent of the order. Obviously, one can transform the grammar to the below.
YesNo = "yes" | "no"
Doclanguage = #lang "tr" | "en"
Multilingual = #mul YesNo
DocumentHeader = Doclanguage Multilingual | Multilingual Doclanguage
But what if I have more than two nonterminal at the header? Say four or more, for example. When the case being that, it is also hard to write parsing function for such a grammar. Is there way of writing such a grammar more structurely?