compiler/PPTokenizingCompiledParser.st
changeset 464 f6d77fee9811
parent 459 4751c407bb40
child 502 1e45d3c96ec5
equal deleted inserted replaced
459:4751c407bb40 464:f6d77fee9811
    10 !
    10 !
    11 
    11 
    12 !PPTokenizingCompiledParser methodsFor:'tokenizing'!
    12 !PPTokenizingCompiledParser methodsFor:'tokenizing'!
    13 
    13 
    14 consume: tokenType
    14 consume: tokenType
    15     (self currentTokenTypeIs: tokenType) ifTrue: [ 
    15     (self perform: tokenType) ifTrue: [ 
    16         | retval |
       
    17         retval := currentTokenValue.
       
    18         currentTokenType := nil.
    16         currentTokenType := nil.
    19         ^ retval
    17         ^ currentTokenValue.
    20     ] ifFalse: [ 
    18     ].	
    21         "self error: 'expected: ', tokenType storeString, ' got ', currentTokenType storeString."
    19     "self error: 'expected: ', tokenType storeString, ' got ', currentTokenType storeString."
    22         self error.
    20     self error.
    23     ]
       
    24 !
    21 !
    25 
    22 
    26 consumeWhitespace
    23 consumeWhitespace
    27     self shouldBeImplemented 
    24     self shouldBeImplemented 
    28 !
    25 !
    32     ^ currentTokenType
    29     ^ currentTokenType
    33 !
    30 !
    34 
    31 
    35 currentTokenTypeIs: tokenType
    32 currentTokenTypeIs: tokenType
    36     "if the type is read"
    33     "if the type is read"
       
    34     self halt: 'deprecated'.
    37     currentTokenType isNil ifFalse: [ ^ currentTokenType = tokenType ].
    35     currentTokenType isNil ifFalse: [ ^ currentTokenType = tokenType ].
    38     
    36     
    39     "if not, try to read the token"
    37     "if not, try to read the token"
    40     self perform: tokenType.
    38     ^ self perform: tokenType.
    41     error ifTrue: [  
       
    42         ^ error := false.
       
    43     ].
       
    44     ^ true
       
    45 !
    39 !
    46 
    40 
    47 currentTokenValue
    41 currentTokenValue
    48     currentTokenType isNil ifTrue: [ self nextToken ].
    42     currentTokenType isNil ifTrue: [ self nextToken ].
    49     ^ currentTokenType
    43     ^ currentTokenType
    63     error := false.
    57     error := false.
    64     currentTokenType := nil.
    58     currentTokenType := nil.
    65 
    59 
    66     self consumeWhitespace.
    60     self consumeWhitespace.
    67     retval := self perform: startSymbol.
    61     retval := self perform: startSymbol.
    68     self consumeWhitespace.
    62 "	self consumeWhitespace."
    69 
    63 
    70     (retval isPetitFailure) ifTrue: [ aPPContext noteFailure: failure ].
    64     (retval isPetitFailure) ifTrue: [ aPPContext noteFailure: failure ].
    71     error ifTrue: [ aPPContext noteFailure: failure. retval := failure ].
    65     error ifTrue: [ aPPContext noteFailure: failure. retval := failure ].
    72     
    66     
    73 "	aPPContext position: context position."
    67 "	aPPContext position: context position."