I am interested in solving the problem of building a binary tree based on a regular expression containing letters of the Latin alphabet, parentheses, alternative, iteration and option (question mark). Associativity is taken into account, i.e. expressions of the form abc(a|b|) are correct. It is immediately demonstrated that the alternative may have empty arguments. Priorities are also taken into account: iteration has the highest priority, concatenation comes second, and the alternative is the weakest. I.e., a|ba|bca is read as (a)|(ba)|(b(c)a).
It is necessary to build a (binary) regular expression parsing tree that preserves its semantics. Node labels are concatenation, alternative (we resolve the option to alternative), iteration (iteration has only one child), empty label or letter (leaf labels).
...
, otherwise Markdown interprets the*
as an attempt to start/stop use of italics. $\endgroup$