compiler/PPCDistinctResultStrategy.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 24 Aug 2015 17:38:44 +0100
changeset 527 9b50ec9a6918
parent 524 f6f68d32de73
permissions -rw-r--r--
Added missing #new methods

"{ Package: 'stx:goodies/petitparser/compiler' }"

"{ NameSpace: Smalltalk }"

PPCScannerResultStrategy subclass:#PPCDistinctResultStrategy
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'PetitCompiler-Scanner'
!

!PPCDistinctResultStrategy methodsFor:'as yet unclassified'!

recordFailure: retval offset: offset
    offset == 0 ifTrue: [ 
        codeGen codeRecordDistinctMatch: nil.
        ^ self
    ].
    codeGen codeRecordDistinctMatch: nil offset: offset 
!

recordMatch: retval offset: offset
    offset == 0 ifTrue: [ 
        codeGen codeRecordDistinctMatch: retval.
        ^ self
    ].

    codeGen codeRecordDistinctMatch: retval offset: offset
!

reset
    ^ codeGen code: 'self resetDistinct.'.
!

returnFailure: retval offset: offset
    (offset == 0) ifFalse: [ 
        codeGen codeIf: 'currentChar isNil' then: nil else: [ 
         	codeGen code: ('context skip: -', offset asString); codeDot.
        ]
    ].

    codeGen codeReturn: [ codeGen codeRecordDistinctFailure: nil ].
!

returnMatch: retval offset: offset
    (offset == 0) ifFalse: [ 
        codeGen code: 'self back.'.
    ].

    codeGen codeReturn: [ codeGen codeRecordDistinctMatch: retval ].
!

returnResult: state
    codeGen codeNl.
    codeGen codeReturnDistinct.	
! !