I know the title is really bad but to be honest my question is a bit complex and I don't even know how to get a proper title :P
First of all, I will explain my situation. I am basically creating a parser that goes through code, Regex is mostly used in it. After that, I store all the data (or that's what I am planning to) in a tree of objects.
For understanding purposes, Here is the class where I store the code parts:
Public Class CodeParts
Public _fileName As String
Public Defines As New List(Of DefinesStruct)
Public Macros As New List(Of DefinesStruct)
Public Functions As New List(Of FunctionsStruct)
Public Stocks As New List(Of FunctionsStruct)
Public Publics As New List(Of FunctionsStruct)
Public Natives As New List(Of FunctionsStruct)
Public Enums As New List(Of EnumsStruct)
Public publicVariables As New List(Of VarStruct)
Public pawnDocs As New List(Of PawnDocParser)
Public Includes As New List(Of CodeParts)
'Helper Funcs.
Public Sub IsAlreadyParsed(ByRef res As Boolean, ByVal str As String, Optional parts As CodeParts = Nothing)
If parts Is Nothing Then parts = Me
For Each inc In parts.Includes
If inc._fileName = str Then res = True : Exit Sub
If inc.Includes.Count <> 0 Then
IsAlreadyParsed(res, str, inc)
End If
Next
End Sub
End Class
You can see the line where it is written:
Public Includes As New List(Of CodeParts)
Files can sometimes contain includes which goes to another file and therefore parse that file too.
And now enough explaining and lets goto the problem :P
Well basically, I need to have properties like Parent
and Root
Parent will just point to the object that the current object is a child of, Like just above it. And Root will goto the main object which have the Parent as Nothing since it doesn't have a parent.
Any help greatly appreciated and if something isn't clear, Just comment below :)