What's ProgressParser

ProgressParser is an extended version of CommandExtractor used to parse 4GL source code. ProgressParser, however, can recognize some commands like ASSIGNs, FORs, DOs, IFs, etc.

Extracted Statements
Line Type Code
1 Comment
/***********************************************
** This is a sample source code for testing 
** parser.
** Author: Flavio Eduardo de Córdova
***********************************************/
6 Define
DEFINE TEMP-TABLE ttLogging     NO-UNDO
    FIELD custName          AS CHARACTER
    FIELD callDuration      AS DECIMAL
    INDEX custName
        custName.
12 Define
DEFINE TEMP-TABLE ttSumary      NO-UNDO
    FIELD custName          AS CHARACTER
    FIELD totalDuration     AS DECIMAL.
16 Run
RUN generateRandomData.
17 Run
RUN sumarize.
18 Run
RUN cleanUp.
21 Procedure
PROCEDURE generateRandomData PRIVATE:
22 Preprocessor
    &SCOPED-DEFINE EXTENT_SIZE  5
23 Define
    DEFINE VARIABLE cAvailableCustomers     AS CHARACTER EXTENT {&EXTENT_SIZE} NO-UNDO
            INITIAL ["~"cust1~"", '"cust2"', "'cust3'", '~'cust4~'', "cust5"].
26 Define
    DEFINE VARIABLE iEntries        AS INTEGER          NO-UNDO.
28 Named Block
    generation:
29 Do
    DO iEntries = 1 TO 100:
30 Create
        CREATE ttLogging.
31 Assign
        ASSIGN
            ttLogging.custName     = cAvailableCustomers[(iEntries MOD {&EXTENT_SIZE}) + 1]
            ttLogging.callDuration = RANDOM(1, 1500) / 100.
34 End
    END.
35 End
END.
37 Procedure
PROCEDURE sumarize PRIVATE:
38 Define
    DEFINE BUFFER ttLoggingBuffer   FOR ttLogging.
39 For
    FOR EACH ttLoggingBuffer
        BREAK BY ttLoggingBuffer.custName:
41 If
        IF FIRST-OF(ttLoggingBuffer.custName) THEN
41 Do
        DO:
42 Create
            CREATE ttSumary.
43 Assign
            ttSumary.custName = ttLoggingBuffer.custName.
44 End
        END.
45 Assign
        ttSumary.totalDuration = ttSumary.totalDuration + ttLoggingBuffer.callDuration.
46 End
    END.
47 End
END.
49 Procedure
PROCEDURE cleanUp PRIVATE:
50 For
    FOR EACH ttSumary
        EXCLUSIVE-LOCK:
52 Delete
        DELETE ttSumary.
53 End
    END.
55 For
    FOR EACH ttLogging
        EXCLUSIVE-LOCK:
57 Delete
        DELETE ttLogging.
58 End
    END.
59 End
END.

Sample Code


The table below shows the Java code used to extract Progress statements:

ProgressParser sample code
import net.cordova.justus.progressparser.*;
import java.io.*;

public class MyTest implements CommandListener {
	public static void main(String args[]) {
		File f = new File(args[0]);
		try {
			ProgressParser extractor = new ProgressParser(f);
			extractor.addCommandListener(new MyTest());
			extractor.analiseCode();
		}
		catch(Exception e) {
			Sysout.err.println("Error: " + e.getMessage());
		}
	}
	
	public void commandRead(ProgressStatement command) {
		System.out.println(command);
	}
}