PetitCommonMark/software/petitcompiler/PEGFsaDeterminizator.class.st

59 lines
1.5 KiB
Smalltalk

Class {
#name : 'PEGFsaDeterminizator',
#superclass : 'PEGFsaAbstractDeterminizator',
#category : 'PetitCompiler-FSA'
}
{ #category : 'checking' }
PEGFsaDeterminizator >> checkPriorities [
self assert: ((fsa states select: [ :s | s hasPriority ]) allSatisfy: [ :s | s priority == 0 ]).
self assert: (fsa allTransitions allSatisfy: [ :s | s priority == 0 ]).
]
{ #category : 'determinization' }
PEGFsaDeterminizator >> determinize [
self checkPriorities.
super determinize.
]
{ #category : 'joining' }
PEGFsaDeterminizator >> joinInfo: info with: anotherInfo into: newInfo [
"nothing to do"
]
{ #category : 'joining' }
PEGFsaDeterminizator >> joinRetval: state with: anotherState into: newState [
"Different retvals cannot merge their info"
state retvalsAndInfosDo: [:retval :info |
retval isNil ifFalse: [
newState addInfo: info for: retval.
]
].
anotherState retvalsAndInfosDo: [:retval :info |
retval isNil ifFalse: [
self assert: (newState retvals includes: retval) not.
newState addInfo: info for: retval.
]
].
]
{ #category : 'joining' }
PEGFsaDeterminizator >> joinState: state with: anotherState [
self assert: state hasZeroPriorityOnly.
self assert: anotherState hasZeroPriorityOnly.
^ super joinState: state with: anotherState
]
{ #category : 'joining' }
PEGFsaDeterminizator >> joinTransitions: state with: anotherState into: newState [
newState transitions addAll: (state transitions collect: #copy).
newState transitions addAll: (anotherState transitions collect: #copy).
^ self
]