Abstract

In this paper, the problem of developing language extensions of Planning C (a dialect of C++) is considered. The review of existing external programs and solutions built into languages that allow translating new constructions introduced into the language into the output code is carried out. Based on the analysis, it is concluded that the most natural solution built into the language will be some combination of improved regular expressions (to highlight new constructions) with code generators based on procedural and syntactic macros. At the same time, it is advisable to use elements of direct logical programming (both in macros and in regular, more precisely, regular-logical expressions). The proposed approach makes it possible to more flexibly allocate replaceable constructs in comparison with template approaches and more simply replace them with output code in comparison with approaches based on manipulations with the syntax tree. The syntax and semantics of the proposed solutions are described. A preprocessing scheme is proposed that implements the selection of initial constructions by scanners (groups of parameterized regular logical expressions) and their replacement with output code implemented by deductive macromodules (with possible multiple matching). This scheme allows you to work with arbitrary input and output syntaxes and provides prompt input of new constructions into Planning C, which is especially valuable, for example, when prototyping new extensions. The paper contains information about the successful testing of the proposed approaches (on the development of a number of syntactically non-trivial extensions of Planning C).

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call