Grammatical Restriction
A compiler-run function that enforces a set of rules regarding what method calls can be used as arguments for the named method(s).
The addition of restrictions to multiple methods within the same statement requires that the methods all have the same number of arguments.
Grammatical restrictions are parts of their methods, and the effect of multiple grammatical restrictions on a single method is cumulative.
Grammar: SET_OF_2-ARG_METHODS can’t have ‹DISALLOWED_LEFT_ARG_METHODS, DISALLOWED_RIGHT_ARG_METHODS>;
Example: {"_+_", "_-_"} can’t have <{}, {"_+_","_-_"}>;
In this example we effect the elimination of ambiguity for nested calls that do not use parentheses (such as 3 + 4 + 5
). Since calls to "_+_"
and "_-_"
are not allowed in their right argument positions, the compiler must necessarily evaluate the expression from left to right.