compiler/PPCTrimmingTokenNode.st
changeset 414 0eaf09920532
parent 393 00381102a9b5
child 421 7e08b31e0dae
equal deleted inserted replaced
413:5389e6fbb3bc 414:0eaf09920532
    67 	^ children at: 1
    67 	^ children at: 1
    68 !
    68 !
    69 
    69 
    70 whitespace: anObject
    70 whitespace: anObject
    71 	(anObject name isNil and: [ self child name isNotNil ]) ifTrue: [ 
    71 	(anObject name isNil and: [ self child name isNotNil ]) ifTrue: [ 
    72 		anObject name: self child name, '_water'.
    72 		anObject name: self child name, '_ws'.
    73 	].
    73 	].
    74 	children at: 1 put: anObject
    74 	children at: 1 put: anObject
    75 ! !
    75 ! !
    76 
    76 
    77 !PPCTrimmingTokenNode methodsFor:'analyzing'!
    77 !PPCTrimmingTokenNode methodsFor:'analyzing'!
    98 ! !
    98 ! !
    99 
    99 
   100 !PPCTrimmingTokenNode methodsFor:'as yet unclassified'!
   100 !PPCTrimmingTokenNode methodsFor:'as yet unclassified'!
   101 
   101 
   102 compileWith: compiler effect: effect id: id
   102 compileWith: compiler effect: effect id: id
   103 	|  guardSetId guardSet |
   103 	|  guard |
   104 
   104 
   105 	compiler startMethod: id.
   105 	compiler startMethod: id.
   106 	compiler startTokenMode.
       
   107 	compiler addVariable: 'start'.
   106 	compiler addVariable: 'start'.
   108 	compiler addVariable: 'end'.
   107 	compiler addVariable: 'end'.
   109 	
   108 	
   110 	self compileWhitespace: compiler.
   109 	self compileWhitespace: compiler.
   111 
   110 
   112 	(compiler guards and: [ (guardSet := compiler guardCharSet: self) isNil not ]) ifTrue: [ 	
   111 	(compiler guards and: [(guard := PPCGuard on: self) makesSense]) ifTrue: [ 
   113 		guardSetId := id, '_guard'.
       
   114 		compiler addConstant: guardSet as: guardSetId.
       
   115 		compiler add: 'context atEnd ifTrue: [ ^ self error ].'.
   112 		compiler add: 'context atEnd ifTrue: [ ^ self error ].'.
   116 		compiler add: '(', guardSetId, ' value: context peek) ifFalse: [ ^ self error ].'.
   113 		guard id: id, '_guard'.
       
   114 		guard compileGuard: compiler.
       
   115 		compiler addOnLine: 'ifFalse: [ ^ self error ].'
   117 	].
   116 	].
   118 
   117 
   119 	compiler add: 'start := context position + 1.'.
   118 	compiler add: 'start := context position + 1.'.
   120 	compiler call: (self child compileWith: compiler).
   119 	compiler call: (self child compileWith: compiler).
   121 	compiler add: 'error ifTrue: [ ^ self ].'.	
   120 	compiler add: 'error ifTrue: [ ^ self ].'.	
   125 
   124 
   126 	compiler add: '^ ', tokenClass asString, ' on: (context collection) 
   125 	compiler add: '^ ', tokenClass asString, ' on: (context collection) 
   127 																start: start  
   126 																start: start  
   128 																stop: end
   127 																stop: end
   129 																value: nil'.
   128 																value: nil'.
   130 	compiler stopTokenMode.
       
   131  ^ compiler stopMethod.	
   129  ^ compiler stopMethod.	
   132 !
   130 !
   133 
   131 
   134 prefix
   132 prefix
   135 	^ #token
   133 	^ #token