Parse program which is having table definition

Hi,

i am using a program to parse a 4GL progress code, it works fine when there is no table definition is used but fails if i use a table refrence, gives me below error -

---------------------------
Error (Press HELP to view stack trace)
---------------------------
org.prorefactor.refactor.RefactorException: testparse_table.p:1: Unknown table name: customer
---------------------------
OK Help
---------------------------

i am having sports database connected on editor. below is the code i am using to parse and my pf file is using sports db -

using org.prorefactor.refactor.* from assembly.
using org.prorefactor.treeparser.* from assembly.
using org.prorefactor.core.* from assembly.
using java.io.* from assembly.

def var filename as char init "testparse_table.p".
def var indent as int no-undo.

def var outed as char view-as editor large scrollbar-vertical size 78 by 22.
display outed with frame f1 no-box no-labels.

def var prsession as class org.prorefactor.refactor.RefactorSession.

prsession = org.prorefactor.refactor.RefactorSession:getInstance().

def var javafile as class java.io.File.
javafile = new java.io.File(filename).
if (not javafile:exists()) then do:
message "Could not find file: " + fileName view-as alert-box.
return.
end.
def var pu as class org.prorefactor.treeparser.ParseUnit.
pu = new ParseUnit(javafile).
pu:treeParser01().

run walker(pu:getTopNode()).
enable outed with frame f1.
wait-for "endkey" of default-window.

procedure walker:
def input param node as class JPNode.
if (node eq ?) then
return.
outed:insert-string(fill(" ", indent) + node:ToString() + "~r~n") in frame f1.
indent = indent + 1.
run walker(node:firstChild()).
indent = indent - 1.
run walker(node:nextSibling()).
end procedure.

Any idea, why i am getting this error, am i missing some configuration?

Regards,
Ganesh


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
tamhas's picture

You need to load the schema.

You need to load the schema. E.g.,

method public void Initialize():
/* Initialize for Proparse */
if chSchemaDirectory = "" then chSchemaDirectory = session:temp-directory.
if chSchemaDumpFile = "" then chSchemaDumpFile = "proparse.schema":U.
chSchemaDumpFile = chSchemaDirectory + "/" + chSchemaDumpFile.

obSetEnvironment = new SetEnvironment().
obSetEnvironment:Initialize().

obSetSchemaFromFile = new SetSchemaFromFile().
obSetSchemaFromFile:chSchemaDirectory = chSchemaDirectory.
obSetSchemaFromFile:chLogicalDataBaseList = chLogicalDataBaseList.
obSetSchemaFromFile:chAliasList = chAliasList.
obSetSchemaFromFile:lgDeletePPSchemaFile = false.
obSetSchemaFromFile:Initialize().

end method.

method void DoParse():
define variable obJavaFile as java.io.File no-undo.
define variable obParseUnit as ParseUnit no-undo.
define variable minWhich as integer no-undo.

obJavaFile = new java.io.File(chCompileUnitToScan).
obParseUnit = new ParseUnit(obJavaFile).
obParseUnit:treeParser01().


schema load worked

Thomas,

Thank you for your response. i did used above code but couldn’t find SetEnvironment, SetSchemaFromFile etc. methods, i believe you created these methods your own, so i tried with Prolint code snippet i.e. -

DEF VAR proparseSchema AS CLASS org.prorefactor.core.schema.Schema NO-UNDO.
proparseSchema = org.prorefactor.core.schema.Schema:getInstance().
proparseSchema:loadSchema("prorefactor/projects/prorefactor.schema").

and for creating schema, i used prorefactor code, i.e. -

run prorefactor/configure.p.

After this setup i ran my parsing program, and it worked.

Thank you for quick response.

Ganesh Chandra


tamhas's picture

Yes, sorry, those are

Yes, sorry, those are classes from the Proparse utilities in ABL2DB
http://www.oehive.org/node/2294


Thanks, i'll have a

Thanks, i'll have a look.

Ganesh Chandra