Precedence Table Construction Algorithm for CFGs Regardless of Being OPGs

Autor: Leonardo Lizcano, Eduardo Angulo, José Márquez
Jazyk: angličtina
Rok vydání: 2024
Předmět:
Zdroj: Algorithms, Vol 17, Iss 8, p 345 (2024)
Druh dokumentu: article
ISSN: 1999-4893
DOI: 10.3390/a17080345
Popis: Operator precedence grammars (OPG) are context-free grammars (CFG) that are characterized by the absence of two adjacent non-terminal symbols in the body of each production (right-hand side). Operator precedence languages (OPL) are deterministic and context-free. Three possible precedence relations between pairs of terminal symbols are established for these languages. Many CFGs are not OPGs because the operator precedence cannot be applied to them as they do not comply with the basic rule. To solve this problem, we have conducted a thorough redefinition of the Left and Right sets of terminals that are the basis for calculating the precedence relations, and we have defined a new Leftmost set. The algorithms for calculating them are also described in detail. Our work’s most significant contribution is that we establish precedence relationships between terminals by overcoming the basic rule of not having two consecutive non-terminals using an algorithm that allows building the operator precedence table for a CFG regardless of whether it is an OPG. The paper shows the complexities of the proposed algorithms and possible exceptions to the proposed rules. We present examples by using an OPG and two non-OPGs to illustrate the operation of the proposed algorithms. With these, the operator precedence table is built, and bottom-up parsing is carried out correctly.
Databáze: Directory of Open Access Journals
Nepřihlášeným uživatelům se plný text nezobrazuje