compiler/PPCMessagePredicateNode.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 03 Nov 2014 12:46:42 +0000
changeset 410 779556be95f8
parent 392 9b297f0d949c
child 421 7e08b31e0dae
permissions -rw-r--r--
Portability fixes in PPPredicateTest>>charactersDo: / parsedCharacterSet: * It is my understanding that charactersDo: should iterate over all signle byte characters. If so, the method suffer from off-by-one error, it should generate characters with code points 0..255. 256 is actually a two-byte character. Method changed accordingly. * Use Character>>asString instead of `String>>with:` which is safer w.r.t. multi-byte characters. Under Smalltalk/X, String may contain only signle byte characters.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
391
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/petitparser/compiler' }"
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
PPCAbstractPredicateNode subclass:#PPCMessagePredicateNode
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
	instanceVariableNames:'message'
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
	classVariableNames:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	poolDictionaries:''
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	category:'PetitCompiler-Nodes'
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!PPCMessagePredicateNode methodsFor:'accessing'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
asInlined
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
	^ PPCInlineMessagePredicateNode new
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
		message: message;
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
		predicate: predicate;
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
		name: name;
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
		yourself
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
message
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
	
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
	^ message
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
message: anObject
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	message := anObject
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
!PPCMessagePredicateNode methodsFor:'as yet unclassified'!
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
bodyOfPredicate: compiler
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
	compiler addOnLine: '(context peek ', self message, ')'.
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
	compiler indent.
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
	compiler add: 'ifFalse: [ self error: ''predicate not found'' ]'.
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
	compiler add: 'ifTrue: [ context next ].'.
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
	compiler dedent.
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
! !
553a5456963b Ported PetitCompiler-(Tests).
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39