Skip to content

Commit

Permalink
Merge pull request #34 from moosetechnology/differential-validator
Browse files Browse the repository at this point in the history
changed comparison of ASTs to give more indo
  • Loading branch information
NicolasAnquetil authored Nov 22, 2023
2 parents 1ac2da5 + 81d72bc commit 0c29e2c
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/FAST-Core-Tools/FASTDifferentialValidator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,28 @@ FASTDifferentialValidator >> childrenNodes: astNode [

{ #category : #utilities }
FASTDifferentialValidator >> compare: ast1 to: ast2 [
"comparing the two lists of children may seem a bit complicate, but it is trying
to give more info on when the children starts to differ"

| children1 children2 size1 size2 |

(ast1 class = ast2 class)
ifFalse: [ self ast: ast1 differ: ast2 ].

((self childrenNodes: ast1) size = (self childrenNodes: ast2) size)
ifFalse: [ self ast: ast1 differ: ast2 ].
children1 := self childrenNodes: ast1.
children2 := self childrenNodes: ast2.

size1 := children1 size.
size2 := children2 size.

1 to: size1 do: [ :i |
(size2 < i)
ifTrue: [ self ast: (children1 at: i) differ: nil ]
ifFalse: [ self compare: (children1 at: i) to: (children2 at: i) ]
].

(self childrenNodes: ast1)
with: (self childrenNodes: ast2)
do: [ :a :b | self compare: a to: b ]
(children2 size > children1 size)
ifTrue: [self ast: nil differ: (children2 at: (children1 size + 1)) ]
]

{ #category : #utilities }
Expand Down

0 comments on commit 0c29e2c

Please sign in to comment.