compiler/PPCTokenNode.st
changeset 414 0eaf09920532
parent 393 00381102a9b5
child 421 7e08b31e0dae
equal deleted inserted replaced
413:5389e6fbb3bc 414:0eaf09920532
    16 ! !
    16 ! !
    17 
    17 
    18 !PPCTokenNode methodsFor:'accessing'!
    18 !PPCTokenNode methodsFor:'accessing'!
    19 
    19 
    20 initialize
    20 initialize
    21     super initialize.
    21 	super initialize.
    22 
       
    23     "Modified: / 26-10-2014 / 01:34:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    24 !
    22 !
    25 
    23 
    26 rewrite: changeStatus
    24 rewrite: changeStatus
    27 	|  |
    25 	|  |
    28 	super rewrite: changeStatus.
    26 	super rewrite: changeStatus.
    47 
    45 
    48 compileWith: compiler effect: effect id: id
    46 compileWith: compiler effect: effect id: id
    49 	|    |
    47 	|    |
    50 
    48 
    51 	compiler startMethod: id.
    49 	compiler startMethod: id.
    52 	compiler startTokenMode.
       
    53 	compiler addVariable: 'start'.
    50 	compiler addVariable: 'start'.
    54 	compiler addVariable: 'end'.
    51 	compiler addVariable: 'end'.
    55 	
    52 	
    56 "
       
    57 	(compiler guards and: [ (guardSet := compiler guardCharSet: self) isNil not ]) ifTrue: [ 	
       
    58 		guardSetId := (compiler idFor: guardSet prefixed: #guard).
       
    59 		compiler addConstant: guardSet as: guardSetId.
       
    60 		compiler add: 'context atEnd ifTrue: [ ^ self error ].'.
       
    61 		compiler add: '(', guardSetId, ' value: context peek) ifFalse: [ ^ self error ].'.
       
    62 	].
       
    63 "
       
    64 	compiler add: 'start := context position + 1.'.
    53 	compiler add: 'start := context position + 1.'.
    65 	compiler call: (self child compileWith: compiler).
    54 	compiler call: (self child compileWith: compiler).
    66 	compiler add: 'error ifTrue: [ ^ self ].'.	
    55 	compiler add: 'error ifTrue: [ ^ self ].'.	
    67 	compiler add: 'end := context position.'.
    56 	compiler add: 'end := context position.'.
    68 	
    57 	
    69 	compiler add: '^ ', tokenClass asString, ' on: (context collection) 
    58 	compiler add: '^ ', tokenClass asString, ' on: (context collection) 
    70 																start: start  
    59 																start: start  
    71 																stop: end
    60 																stop: end
    72 																value: nil'.
    61 																value: nil'.
    73 	compiler stopTokenMode.
       
    74  ^ compiler stopMethod.	
    62  ^ compiler stopMethod.	
    75 !
    63 !
    76 
    64 
    77 prefix
    65 prefix
    78 	^ #token
    66 	^ #token