Browse Prior Art Database

Validating Branching in a Two Pass Basic Translator

IP.com Disclosure Number: IPCOM000089138D
Original Publication Date: 1977-Sep-01
Included in the Prior Art Database: 2005-Mar-04
Document File: 1 page(s) / 12K

Publishing Venue

IBM

Related People

Panttaja, JT: AUTHOR [+3]

Abstract

In a BASIC program, a branch statement (FOR, GOSUB, GOTO, IF or NEXT) may only transfer control to a statement in the same program unit as the branch statement. A method is described for validating the use of these statements in a two-pass BASIC translator. Pass 1: A pointer structure is created for the program associating each statement in the program with its line number. Each time a DEF statement is encountered, a similar pointer structure is created for that defined function, and all lines through the associated FNEND statement (only the DEF statement for a single-line defined function) are moved to that pointer structure. The defined function is then processed. A copy of the DEF statement is left in the main program.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 80% of the total text.

Page 1 of 1

Validating Branching in a Two Pass Basic Translator

In a BASIC program, a branch statement (FOR, GOSUB, GOTO, IF or NEXT) may only transfer control to a statement in the same program unit as the branch statement. A method is described for validating the use of these statements in a two-pass BASIC translator. Pass 1: A pointer structure is created for the program associating each statement in the program with its line number. Each time a DEF statement is encountered, a similar pointer structure is created for that defined function, and all lines through the associated FNEND statement (only the DEF statement for a single-line defined function) are moved to that pointer structure. The defined function is then processed. A copy of the DEF statement is left in the main program. After the defined function pointer structure has been processed, a statement number vector is built for the defined function, and control is returned to processing the main program. After the main program has been processed, a statement number vector is built for the main program. Each time a FOR or NEXT statement is encountered, appropriate entries are maintained in a FOR/NEXT table to allow checking for valid nesting and to reference the statement number during pass 2. Pass 2: At the beginning of processing, the main program pointer structure and statement number vector are located. Each time a DEF statement is encountered, the information for the main program is stacked, and the defined func...