The application discloses a
COBOL-to-
Java program
conversion method and
system based on a
syntax tree, belongs to the technical field of
computer program language conversion, and comprises the following steps: obtaining a
COBOL source program file to be converted and configuration rules; performing
lexical analysis and
syntax analysis to generate an
abstract syntax tree; converting
COBOL syntax elements into corresponding
Java semantic representations according to pre-defined
semantic mapping rules; establishing an accurate access chain of a main program and COPYBOOK internal variables through variable
path tracking; detecting and solving naming conflicts of COBOL different-level same-name variables based on a scope tree, and renaming variables by adding a parent class name prefix; and generating the converted
Java semantic representations into a Java
source code file. The application realizes high-fidelity and high-
automation COBOL-to-Java conversion, significantly reduces the migration cost of a
legacy system, and generates code with strong
readability and excellent performance.