uwol / proleap-vb6-parser

ProLeap ANTLR4-based parser for Visual Basic 6.0
MIT License
79 stars 26 forks source link

On Local Error not supported #6

Closed zbagz closed 7 years ago

zbagz commented 7 years ago

MyModule.bas

Private Sub MyFirstSub()
On Local Error GoTo ErrHandler

    MsgBox "MyFirstSub"
    Exit Sub

ErrHandler:
End Sub

Private Sub MySecondSub()
    MsgBox "MySecondSub"
End Sub

VB6Parser

Program program = new io.proleap.vb6.asg.runner.impl.VbParserRunnerImpl().analyzeDirectory(inputDirectory);

for (Statement statement: program.getModule("MyModule").getStatements()) {
    System.out.println(statement.getStatementType().toString() + ": " + ((Procedure)statement).getName());
}

Result

Parsing file MyModule.bas.
Found declared module name MyModule.
Collecting types in file MyModule.bas.
Analyzing declaration of module MyModule.
line 5:9 no viable alternative at input 'On Local Error'
line 5:3 mismatched input 'Local' expecting <EOF>
Analyzing expressions of module MyModule.
call to unknown element VB_Name
Analyzing type assignments of module MyModule.
Analyzing type assignments of module MyModule.
Analyzing type assignments of module MyModule.
Analyzing type assignments of module MyModule.
Sub: MyFirstSub

Expected Result

Sub: MyFirstSub
Sub: MySecondSub
uwol commented 7 years ago

Correct, the grammar is missing ON LOCAL ERROR. I modified the grammar file and added a unit test based on your code snippet.

So it should work now. Please let me know, if not. Thanks for issuing!

zbagz commented 7 years ago

This is now fixed. Thank you Ulrich.