To answer your first question, yes, you can parse operator priorities as part of the language. If you are interested in this, you should study the Pratt guerrillas . This is usually a top-down parsing option, so it should be in the same performance area as other parsing options. In general, I think people are too concerned about the speed of parsing. The compiler will spend most of its time optimizing, and sweating a few milliseconds at the parsing stage does not seem to me necessary.
There is a magpie language that implements the Pratt parser. Therefore, the big advantage is that they defined all the operators for the language in the library instead of the main language. This makes the kernel language incredibly compact and extensible. However, the disadvantage is that other users always ask what the priority of a particular operator will be, since the usual built-in rules may not apply.
source share