Some source programming languages support the use of Goto statements/keywords. Goto
statements are jump statements used to jump from one point in the code to another. Some target
programming languages do not support Goto statements, thereby posing a challenge for the
direct translation of Goto statements when converting from a source language that supports such
statements. Translation of Goto statements using standard constructs such as loops and closures
that are provided in most programming languages can enable automatic migration of code that
includes Goto statements.
DESCRIPTION
This disclosure describes techniques for automatic replacement of Goto statements in
program code with equivalent constructs. The techniques can be utilized, for example, during
migration of code from one programming language that supports Goto statements to another
programming language that does not support Goto statements. An automated tool can implement
the described techniques to convert code written in a particular language that supports a Goto
statement, e.g., Basic, Visual Basic, etc. to a different programming language that may not
support Goto statement use, e.g., JavaScript.
When a file that includes program code that is to be converted is received, certain
conditions are verified to determine whether the file can actually be successfully converted. For
example, it is verified that all ON statements in the code only include Error and Goto Keywords,
that all label declarations occur after the Goto keywords, that all Goto calls have valid label
names (e.g., all utilized labels are declared within a function where they are utilized), that label
declarations are included at a top-level in a corresponding function, etc. If the conditions are not
met and it is determined that the file is not convertible, a suitable message (e.g., “File not
supported”) is provided to the user that attempts code conversion.
3
Defensive Publications Series, Art. 3762 [2020]
https://www.tdcommons.org/dpubs_series/3762