compiler/PPCDistinctResultStrategy.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 24 Nov 2015 19:37:14 +0100
changeset 553 d83cb4945d5e
parent 524 f6f68d32de73
permissions -rw-r--r--
Oops, forgot to export PETITCOMPILER_DATA_DIRECTORY variable ...so Smalltalk code could not read it. Also fixed test for "include" scripts so they are not downloaded again when already downloaded.

"{ 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.	
! !