5 and 5.5 came with the ConvSrc tool for moving to ABC. Inside CnvEng you’ll find the LexerClass class that I think was for parsing Clarion code. IIRC it had some bugs I fixed. it had improvements in 6.0 but SV did not include the source.
LexerClass CLASS,TYPE,MODULE('CNVENG')
TokenList &TokenQueue,PRIVATE
Init PROCEDURE
Kill PROCEDURE
FindToken FUNCTION(STRING Token,USHORT StartPos=1),USHORT
GetEndChrPos FUNCTION(USHORT TokenNumber),LONG
GetStartChrPos FUNCTION(USHORT TokenNumber),LONG
GetToken FUNCTION(USHORT TokenNumber),STRING
GetTokenCount FUNCTION(),USHORT
TakeLine PROCEDURE(*CSTRING TextLine)
TokenReplace FUNCTION(*CSTRING cLine,*CSTRING[] TokenSequence,*CSTRING Replacement,FileQueue FileList,<USHORT NumberTokens>),BYTE
ViewTokens PROCEDURE !Debug only
END
Attached is the original. It is a 16 bit hand code .PR project that will not compile in C8+. But the Lexer class may help you.
ConvSrc_55.zip (94.6 KB)
In 5.5 and 6 was an Example named CallTree that included ABSource.inc with ClarionSourceClass that appears to be for parsing code. I think it may be more limited to finding Procedures and Classes…
CallTree_c6.zip (35.1 KB)
ClarionSourceClass CLASS,TYPE,MODULE('ABSOURCE.CLW'),LINK('ABSOURCE.CLW',_ABCLinkMode_),DLL(_ABCDllMode_)
Continued BYTE,PRIVATE
DelimiterQ &DelimiterQueue,PROTECTED
Delimiters CSTRING(' ,.&()<<>[]{{}=~^+-*/%;?')
Debug BYTE
EndLabel USHORT
Label STRING(LabelLength)
Line CSTRING(2000) !copy of OriginalLine
LineLength USHORT
ModuleName STRING(LabelLength) !filled when TakeLine returns Source:DeclaresClass
OriginalLine &STRING,PRIVATE !source file record buffer
Parameters STRING(ParameterLength) !filled when TakeLine returns Source:DeclaresProcedure
ParentClass STRING(LabelLength) !filled when TakeLine returns Source:DeclaresClass
SourceType BYTE !see Source EQUATEs above.
StartScan USHORT
WordQ &WordQueue,PROTECTED
GetLeftDelimiter PROCEDURE,STRING
GetRightDelimiter PROCEDURE,STRING
GetLeftWord PROCEDURE,STRING
GetRightWord PROCEDURE,STRING
Init PROCEDURE(*STRING SourceLine) !SourceLine: Clarion source file record buffer
Kill PROCEDURE
LoadQueues PROCEDURE,PRIVATE !loads the WordQueue & DelimiterQueue
NextDataLabelPair PROCEDURE(*STRING DataType, *STRING Label),BYTE,PROC
!DataType: a variable to receive a datatype found in SourceCode
!Label: a variable to receive the label associated with the DataType
!Loads DataType and Label.
!Multiple calls to NextDataLabelPair progress from left to right.
!Returns True if pair found, otherwise returns false.
NextWord PROCEDURE,STRING,PROC
!Returns next chunk of text in the source line.
!Multiple calls to NextWord progress from left to right.
NextWordDotWordPair PROCEDURE(*STRING Word1, *STRING Word2),BYTE,PROC
!Word1: a variable to receive the word left of the next period
!Word2: a variable to receive the word right of the next period
!Multiple calls to NextWordDotWordPair progress from left to right.
!Returns True if pair found, otherwise returns false.
NextObjectReference PROCEDURE(*STRING Word1, *STRING Word2),BYTE,PROC
!Word1: a variable to receive the next SELF/PARENT[.property1.property2...] construction
!Word2: a variable to receive the property/method that terminates Word1
!Multiple calls to NextObjectReference progress from left to right.
!Returns True if pair found, otherwise returns false.
Reset PROCEDURE,PRIVATE
SetLabel PROCEDURE,PRIVATE
SetModule PROCEDURE,PRIVATE
SetParameters PROCEDURE,PRIVATE
SetParentClass PROCEDURE,PRIVATE
TakeLine PROCEDURE(<*STRING SourceCode>),BYTE,PROC
!SourceCode: an optional line of Clarion source code. If omitted, the object
!operates on the current line->SELF.OriginalLine
!Initial scan of source line, loads properties and returns one of the following:
!Source:IsBlank
!Source:IsComment
!Source:DeclaresProcedure (SELF.Label, SELF.Parameters,SELF.WordQ, SELF.DelimiterQ are loaded)
!Source:DeclaresClass (SELF.Label, SELF.ModuleName, SELF.ParentClass,SELF.WordQ, SELF.DelimiterQ are loaded)
!Source:Other (SELF.WordQ, SELF.DelimiterQ are loaded)
!e.g. CASE SourceObject.TakeLine
! OF Source:DeclaresClass
! DO SomethingWithLabelOrModule
! OF Source:DeclaresProcedure
! DO SomethingWithParameters
! END
END