A random code generation method based on syntax tree layering model
Yu Pu, Hui Shu, Xiaobing Xiong, Fei Kang · 2021
Aiming at the problem that automatic code generation technology requires a lot of human intervention and cannot produce a lot of source code, a random code generation method based on syntax tree hierarchical model was proposed. In this technique, the syntax elements in the code abstract syntax tree are divided into five layers according to different degrees of refinement by constructing a hierarchical syntax tree model, and the element composition expression is proposed to formally describe the structure of the code at the text level. Based on this approach, an automatic code generation framework is proposed. Supported by a corpus, the framework can generate multiple nested element formation expressions which are finally converted into usable source code by translators. Experiments from the three dimensions of code complexity, control flow and semantic similarity prove that this method can generate a large number of source code randomly, and the generated code has low similarity in control flow diagram and semantics.