Error Parsing code

Cringer

ProgressTalk.com Moderator
Staff member
I'm trying to parse some code using v11.2.1, and I've come across an issue. My code to load is:

Code:
  INPUT FROM VALUE(tt-Program.FullPath).
  ImportBlock:
  REPEAT:
    lv-LineNumber = lv-LineNumber + 1.
    lv-Import = ?.
    IMPORT DELIMITER " " lv-Import. 
  END.

This works really well except for when it encounters a scenario like this:

Code:
    ASSIGN tt-SaaList.PrevTenderBasketKey       = lb-SelectedRecordTenderIssue.TenderBasketKey
           tt-SaaList.PrevSupplierShapedDate    = lb-SelSupplierAgreementAdmin.SaaSupplierShapedDate 
           .

At which point the lone . on a line makes the REPEAT block drop out, thus losing the rest of the import. I don't get any errors. It just breaks the REPEAT. Does anyone have any ideas how I can get around this?
 

tamhas

ProgressTalk.com Sponsor
Does anyone have any ideas how I can get around this?

Don't try to use ABL for parsing? Why do you think there is Proparse?

But, the usual solution is to import the whole line using unformatted, and then apply exception tests, such as for an isolated period, and then to break it up into tokens.
 

TomBascom

Curmudgeon
Or... use COPY-LOB to load it into a LONGCHAR then use ENTRY() with the delimiter set to newline to extract lines. Then use ENTRY() again on each line...

But -- parsing Progress 4GL with 4GL? You didn't strike me as a glutton for punishment but I may need to revise that ;)
 

RealHeavyDude

Well-Known Member
I am with Tamhas and Tom on this. It appears to me that your import is way to restrictive to cope with all the different things you may find in ABL code. Importing the file line by line unformatted and then inspect what you got is the way to go. But, just lastly I changed my habit ( old habits die hard ... ) of using streams to using LONGCHARS and COPY-LOB for importing and exporting, whenever it suits my needs.

Heavy Regards, RealHeavyDude.
 

Cringer

ProgressTalk.com Moderator
Staff member
Don't try to use ABL for parsing? Why do you think there is Proparse?

But, the usual solution is to import the whole line using unformatted, and then apply exception tests, such as for an isolated period, and then to break it up into tokens.

Thanks tamhas. I realise ABL isn't the best tool. Actually all I'm trying to do is to enhance our compiler to work out where icode is used so that it will compile all code it's included in.
 

Cringer

ProgressTalk.com Moderator
Staff member
Or... use COPY-LOB to load it into a LONGCHAR then use ENTRY() with the delimiter set to newline to extract lines. Then use ENTRY() again on each line...

But -- parsing Progress 4GL with 4GL? You didn't strike me as a glutton for punishment but I may need to revise that ;)

lol Tom - I'm certainly a glutton for punishment! :D Not sure where you got the converse idea from. I'm a mod here for starters ;) :p
I'll have a look into COPY-LOB. Is it quicker than imports? Or just more reliable?
 

tamhas

ProgressTalk.com Sponsor
That is the sort of task a real parser would be both much faster at and more reliable.
 

Cringer

ProgressTalk.com Moderator
Staff member
It is? Oops. What method would you use? I won't mention that I was pointed in the direction of REPEAT by a very experienced programmer... lol :)
 

RealHeavyDude

Well-Known Member
To be honest, I used to use REPEAT for reading files line by line too. The only thing that springs to my mind is that just using REPEAT the default block-based error handling will kick in - which behavior might not be so obvious. Of course one should pimp it with structured error handling.

Heavy Regards, RealHeavyDude.
 

TomBascom

Curmudgeon
Ok, I may have been a bit grouchy and over-stated the applicability to your case ;)

REPEAT does two things that I don't like: 1) It has default error handling properties that foul up when the last line doesn't have a newline and 2) it has record and transaction scoping properties that aren't needed for this usage.

I would use DO WHILE TRUE. I almost always do -- it makes me explicitly handle things. Which I like much better.
 
Top