Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extended BNF grammar optional [...] notation

Tags:

ebnf

I read somewhere [x],y in this notation, x is optional, but I could not understand what is meant by optional. Does it means, there can be y or x,y or something else? Can anyone give some example about this?

like image 770
user2586173 Avatar asked Dec 16 '25 17:12

user2586173


1 Answers

Yes.

Documentation about []:

Optional: The items between [ and ] are optional. All or none of the items in the brackets are included.

In EBNF [] stands for optional parameters that can be ommitted, so [x],y defines the possibilities y and xy.

Example:

Bicycle_Accessories = saddle [bell | horn] {water_bottle_holders}

defines next possibilities:

saddle 
saddle bell 
saddle horn 
saddle water_bottle_holder 
saddle bell water_bottle_holder 
saddle bell water_bottle_holder water_bottle_holder 
like image 72
m0nhawk Avatar answered Dec 20 '25 17:12

m0nhawk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!