Operator Grammar

[…] we require that all arguments be de­ limited by at least one token; such a grammar Floyd [1963] calls an operator grammar. (Pratt, Top Down Operator Precedence, p. 46.)

FLOYD, Robert W., 1963. Syntactic analysis and operator precedence. Journal of the ACM (JACM). 1963. Vol. 10, no. 3, p. 316–333.

Three increasingly restricted types of formal grammar are phrase structure grammars, operator grammars and precedence grammars. Precedence grammars form models of mathematical and algorithmic languages which may be analyzed mechanically by a simple procedure based on a matrix representation of a precedence relation between character pairs.

ChatGPT September 25 Version

A "matrix representation of a precedence relation between character pairs" is a way of organizing information to define the relative order or priority of different characters. This representation uses a two-dimensional grid (matrix) where each cell indicates whether one character has a higher precedence than another. Here's a breakdown of this concept: 1. **Matrix**: A matrix is a grid-like arrangement of elements. In this context, it's a 2D array where each element represents a relationship between two characters. 2. **Precedence Relation**: Precedence refers to the priority or order in which things should be considered or evaluated. In the context of characters, it means determining which character should come before or after another. 3. **Character Pairs**: Each cell in the matrix corresponds to a pair of characters. For example, if you have a list of characters (e.g., A, B, C, D), then the matrix will have rows and columns representing each character, and each cell (i, j) will indicate the relation between character i and character j. 4. **True/False Values**: The cells of the matrix contain Boolean values (True or False). These values indicate whether character i has higher precedence than character j. For example, if matrix[1][2] is True, it means character at index 1 has higher precedence than character at index 2. 5. **Transitive Relation**: The matrix must satisfy the transitive property. If A has higher precedence than B, and B has higher precedence than C, then A must also have higher precedence than C. 6. **Reflexive Property**: The matrix is often symmetric, meaning if A has higher precedence than B, then B will have lower precedence than A. This is because precedence is typically a symmetric relation. For example, consider the characters A, B, C, and D. If we have the following matrix:

[[ False, True, False, True ], [ False, False, True, True ], [ True, False, False, True ], [ False, False, False, False ]]

This matrix indicates: - A has higher precedence than B. - B has higher precedence than C and D. - C has higher precedence than A. - D has no defined precedence relation with any other character. This information can be used to determine if a given string of characters follows the specified precedence relations. For example, in the string "ABCD", the characters maintain the specified precedence relations.

~

2D array (spreadsheet) demo. page Matrix is a grid-like arrangement of elements. In this context, it's a 2D array where each element represents a relationship between two characters.