Mechanism for Expanding Programming Language Syntax at Compile Time

2025;
: pp. 15 - 23
1
Lviv Polytechnic National University, Electronic Computational Machines Department
2
Lviv Polytechnic National University, Computer Engineering Department

The article examines the issue of the flexibility of grammars with a fixed set of rules, which limits the ability to integrate specialized syntactic constructs. A model for extending such grammars is proposed, allowing for modular supplementation of the base system with new rules without compromising its integrity. This approach enables the syntactic system to adapt to new requirements, ensuring the automatic expansion of formal descriptions.
A mechanism for integrating new syntactic constructs has been developed, based on verifying their consistency using FIRST and FOLLOW set analysis. Additionally, methods for resolving ambiguities have been applied by utilizing the current parsing context, allowing the automatic determination of optimal rules for constructing an abstract syntax tree. This approach ensures the unambiguity and correctness of syntactic analysis, as even in cases of potential conflicts, the system eliminates ambiguity by considering local semantic and syntactic features.
This approach demonstrates the high adaptability and modularity of the grammar extension mechanism, which is of significant practical importance for the further evolution of compilation systems and the development of specialized dialects. The proposed methodology opens new perspectives for the creation of flexible and scalable syntactic analysis systems capable of responding promptly to changes in modern programming requirements.

  1. Koskimies K., Räihä K.-J., Sarjakoski M. Compiler construction using attribute grammars. 1982. Doi: https://doi.org/10.1145/800230.806991.
  2. Aasa A. Precedences in specifications and implementations of programming languages. 1995. Doi: http://dx.doi.org/10.1016/0304-3975(95)90680-J.
  3. Noonan R. E. Compiler construction usingmodern tools. 1986. Doi: https://doi.org/10.1145/5600.5697.
  4. 4. Guilan D., Suqing Z., Jinlan T., Weidu J. A study of compiler techniques for multiple targets in compiler infrastructures. 2002. Doi: https://doi.org/10.1145/571727.571735
  5. Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman, Compilers: Principles, Techniques, and Tools, 2nd edition, Addison Wesley, 2006.
  6. De Oliveira Guimarães, J. Learning compiler construction by examples. 2007. Doi: https://doi.org/10.1145/1345375.1345418.
  7. Demaille A., Levillain R., Perrot B. A set of tools to teach compiler construction. 2008. Doi: https://doi.org/10.1145/1384271.1384291.
  8. Grune D., van Reeuwijk K., Bal H. E., Jacobs C. J. H., Langendoen K. Modern Compiler Design. 2012. Doi:    https://doi.org/10.1007/978-1-4614-4699-6.
  9. Li H., Hu C., Zhang P., Xie L. Modular SDN Compiler Design with Intermediate Representation. Proceedings of the 2016 Conference on ACM SIGCOMM 2016 Conference - SIGCOMM ’16. 2016. Doi: https://doi.org/10.1145/2934872.2959061.
  10. Chen H., Ching W.-M., Hendren L. An ELI-to-C compiler: design, implementation, and performance.
  11. 2017. Doi: https://doi.org/10.1145/3091966.3091969.