How do I create operator precedence with regex in Python

  ebnf, operator-precedence, python, regex

I have a homework to do. It is about an EBNF created by our teacher, and we have to code a language from that EBNF.

My question is about how to create operator predecence, specially when dealing with parenthesis.

For example,


The order in that expression is from the inner parenthesis in the left (>1), then the parenthesis in the right (A), and lastly the outer expression (<1).

How should I start? Thank you, and I hope I am being clear

Source: Python Questions