On Thu, Nov 7, 2019 at 6:49 AM Benoit <[email protected]> wrote:
> What do the colons and digits mean in " ((A:2) -> (B:1) : 1) " ? > They are annotating the precedence levels of subterms. It's basically a shorthand for the CFG rule expr(1) <- expr(2) "->" expr(1) where "expr(1)" is the nonterminal corresponding to expressions with precedence >= 1. > To have unambiguity, wouldn't it be easier, as Giovanni thought was the > case, that any natural number be the precedence of at most one operator > (even if this is more than needed for unambiguity) ? > That's a bit restrictive. For one thing, there are only 2048 precedence levels (or at least, no more than that many are required to exist), so you won't be able to have more than 2048 notations, and there are almost certainly going to be more than that many definitions. Besides this, it is not uncommon for multiple operators to "officially" live on the same precedence level. For example, + and - are generally at the same left assoc precedence level, so that a + b - c means (a + b) - c and a - b + c means (a - b) + c. If they live at different precedence levels this parse is not possible. In C/C++, most precedence levels have several operators in them: https://en.cppreference.com/w/c/language/operator_precedence How do you parse " a * b + c " if both laws have the same precedence ? > It is also generally agreed that * has higher precedence than + , so a * b + c means (a * b) + c and a + b * c means a + (b * c). When faced with two operators with the same precedence (including in particular two instances of the same operator), the associativity of the operator determines the bracketing. If it is left associative, then a o b o c o d means ((a o b) o c) o d, and if it is right associative it means a o (b o (c o d)). Mario -- You received this message because you are subscribed to the Google Groups "Metamath" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/metamath/CAFXXJSv9WkjbTN1nj3zUMSznSmpJ6hVvTxYMCkHuKeeW0_r7LQ%40mail.gmail.com.
