Actually, if only you named the property TParseTreeNode.ChildNodes[] something more conventional, such as TParseTreeNode.Items[], you would not need TSourceTokenList at all.
TSourceToken and TSourceTokenList would be one simple class.
Any reason not to?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That would compile, maybe even run a bit faster, but fails the semantic test. It is not true that a Source Token is a kind of list. An interior parse tree node *has* child nodes; but a leaf, a source token, doesn't.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Putting aside all my objections to TObjectList for now ;-), here are a few suggestions:
TSourceTokenList derives from TObjectList. Good.
TSourceToken derives from TParseTreeNode. Fine.
TParseTreeNode derives from TObject. Objection.
If you derived TParseTreeNode from TObjectList, then you could have a better lineage; suct that:
TParseTreeNode = Class(TObjectList)
TSourceToken = Class(TParseTreeNode)
TSourceTokenList = Class(TSourceToken)
Actually, if only you named the property TParseTreeNode.ChildNodes[] something more conventional, such as TParseTreeNode.Items[], you would not need TSourceTokenList at all.
TSourceToken and TSourceTokenList would be one simple class.
Any reason not to?
That would compile, maybe even run a bit faster, but fails the semantic test. It is not true that a Source Token is a kind of list. An interior parse tree node *has* child nodes; but a leaf, a source token, doesn't.
What /semantic/ test? Which hat did that came out of :-)
TSourceToken is a special case of TSourceTokenList when it does not have any child nodes. Is that not?
So, instead of thinking TSourceToken as something distinct, think of it in that context and you'll see what I mean.
IOW, if it will make you feel more comfortable, look at it like this:
TParseTreeNode = Class(TObjectList)
TSourceTokenList = Class(TParseTreeNode)
TSourceToken = Class(TSourceToken)
and then fold TSourceTokenList and TSourceToken into one single class --and call it TSourceTreeNode if you like.
BTW, this is the same thing I said in the earlier thread except the wording.
TParseTreeNode = Class(TObjectList)
TSourceTokenList = Class(TParseTreeNode)
TSourceToken = Class(TSourceTokenList)
TSourceToken + TSourceTokenList --> TSourceTreeNode