A Software Module for Working with Context-Free Grammars

  • Mikhail Zhegalin Saint Petersburg Electrotechnical University, 5, building 3, st. Professora Popova, 197022, Saint Petersburg, Russia
  • Vladislav Yandrinski Saint Petersburg Electrotechnical University, 5, building 3, st. Professora Popova, 197022, Saint Petersburg, Russia
Keywords: learning module, grammars, Earley's algorithm, context-free grammars, grammar comparison

Abstract

The article presents the development of an educational software module to support the initial stage of learning formal grammars. The developed module allows the student or teacher to describe a given language through context-free grammar. In the process of completing a grammar assignment, the module provides an interactive response to the differences between the constructed grammar and the reference one. The main technical problem that the authors solved is related to the fact that there is no algorithm for determining the equivalence of two context-free grammars. Therefore, the module must generate in real time a sufficiently large number of words of a language of different lengths in order to detect differences between the proposed grammar and the reference one with a high probability. In the work, several word generation algorithms were analyzed, after which the algorithm most appropriate to the conditions of use of the module was selected. The developed module can be used for conducting Olympiads in discrete mathematics and computer science for schoolchildren and students, as well as to support students’ independent work on the topic "Formal languages and grammars".

Author Biographies

Mikhail Zhegalin, Saint Petersburg Electrotechnical University, 5, building 3, st. Professora Popova, 197022, Saint Petersburg, Russia

4th year Student of the bachelor’s degree program of the Сomputer Science Department, Saint Petersburg Electrotechnical University, michael.zhegalin.univ@gmail.com

Vladislav Yandrinski, Saint Petersburg Electrotechnical University, 5, building 3, st. Professora Popova, 197022, Saint Petersburg, Russia

Студент 4 курса кафедры вычислительной техники СПбГЭТУ «ЛЭТИ», yandrinsky@gmail.com

References

N. Chomsky, “Syntactic Structures,” New in linguistics, vol. 2, pp. 412–527, 1962 (in Russian).

B. K. Martynenko, Languages and translations, St. Petersburg, Russia: SPbGU Publ., 2013 (in Russian).

Jetbrains MPS, “Meta Programming System,” in www.jetbrains.com, 2024. [Online]. Available: https://www.jetbrains.com/mps/

Xtext Eclipse, “Language Engineering For Everyone!,” in eclipse.dev, 2024. [Online]. Available: https://eclipse.dev/Xtext/

ANTLR, “Quick Start,” in www.antlr.org, 2024. [Online]. Available: https://www.antlr.org

“Extended Backus–Naur Form,” in ru.wikipedia.org, 2024 (in Russian). [Online]. Available: https://ru.wikipedia.org/w/index.php?title=Расширенная_форма_Бэкуса_—_Наура&stable=1

N. Wirth, Algorithms and Data Structures, Мoscow: DMK press, 2010 (in Russian).

ITMO University, “Cocke-Younger-Kasami algorithm,” in neerc.ifmo.ru, 2022 (in Russian). [Online]. Available: https://neerc.ifmo.ru/wiki/index.php?title=Алгоритм_Кока-ЯнгераКасами_разбора_грамматики_в_НФХ

ITMO University, “Chomsky normal form,” in neerc.ifmo.ru, 2022 (in Russian). [Online]. Available: https://neerc.ifmo.ru/wiki/index.php?title=Нормальная_форма_Хомского

A. Sorokin, Earley algorithm, in homepage.mi-ras.ru, 2013 (in Russian). [Online]. Available: https://homepage.mi-ras.ru/~sk/lehre/fivt2013/Earley.pdf

Published
2024-08-30
How to Cite
Zhegalin, M., & Yandrinski, V. (2024). A Software Module for Working with Context-Free Grammars. Computer Tools in Education, (2), 72-84. https://doi.org/10.32603/2071-2340-2024-2-72-84
Section
Computer science