Was there similar material for my college degree.
I suggest NOT using the operator priority function, even if it looks simpler than syntactic sugar.
Most of the languages ββthat will be described by EBNF use many operators with various functions that are better described and updated using EBNF expressions instead of operator precedence.
Some operators are unary prefix, some unary posfix, some are binary (aka "infix"), some binary are evaluated from left to right, and some are evaluated from right to left. Some characters are operators in a certain context and are used as other tokens, in another context - an example of "+", "-", which can be binary operators ("x - y"), unary prefix operators ("x - -y" )) or part of the literal ("x + -5").
In my experience, it is more βsafeβ to describe them with EBNF expressions. If the programming language that you describe is very small, with very few and similar syntax operators (example: all binary or all prefix unary).
Only my 2 cents.
source share