I have an EBNF grammar and want to convert it to PEG (https://github.com/anatoo/PHPPEG):
query = { word | wildcard }
word = ( [apostrophe] ( letter { alpha } ) ) | ” , ”
letter = ” a ” | ... | ” z ” | ” A ” | ... | ” Z ”
alpha = letter | ” 0 ” | ... | ” 9 ”
apostrophe = ” ’ ”
wildcard = ” ? ” | ” * ” | synonyms | multiset | optionset
synonyms = ” ~ ” word
multiset = ” { ” word { word } ” } ”
optionset = ” [ ” word { word } ” ] ”
Can anyone explain how to convert from one to another, or if there's somewhere where I can read about it?
Thanks!
• the question mark (?), which matches exactly one word;
• the asterisk (*), which matches any sequence of words;
• the tilde sign in front of a word (∼<word>), which matches any of the word’s synonyms;
• the multiset operator ({<words>}), which matches any ordering of the enumerated words; and,
• the optionset operator ([<words>]), which matches any one word from a list of options.