PPPluggableParser.st
changeset 0 739fe9b7253e
child 4 90de244a7fa2
equal deleted inserted replaced
-1:000000000000 0:739fe9b7253e
       
     1 "{ Package: 'squeak:petitparser' }"
       
     2 
       
     3 PPParser subclass:#PPPluggableParser
       
     4 	instanceVariableNames:'block'
       
     5 	classVariableNames:''
       
     6 	poolDictionaries:''
       
     7 	category:'PetitParser-Parsers'
       
     8 !
       
     9 
       
    10 PPPluggableParser comment:'A pluggable parser that passes the parser stream into a block. This enables users to perform manual parsing or to embed other parser frameworks into PetitParser.
       
    11 Instance Variables:
       
    12 	block	<BlockClosure>	The pluggable one-argument block.
       
    13 '
       
    14 !
       
    15 
       
    16 
       
    17 !PPPluggableParser class methodsFor:'instance creation'!
       
    18 
       
    19 on: aBlock
       
    20 	^ self new initializeOn: aBlock
       
    21 ! !
       
    22 
       
    23 !PPPluggableParser methodsFor:'accessing'!
       
    24 
       
    25 block
       
    26 	"Answer the pluggable block."
       
    27 
       
    28 	^ block
       
    29 ! !
       
    30 
       
    31 !PPPluggableParser methodsFor:'initialization'!
       
    32 
       
    33 initializeOn: aBlock
       
    34 	block := aBlock
       
    35 ! !
       
    36 
       
    37 !PPPluggableParser methodsFor:'parsing'!
       
    38 
       
    39 parseOn: aStream
       
    40 	| position result |
       
    41 	position := aStream position.
       
    42 	result := block value: aStream.
       
    43 	result isPetitFailure
       
    44 		ifTrue: [ aStream position: position ].
       
    45 	^ result
       
    46 ! !
       
    47 
       
    48 !PPPluggableParser class methodsFor:'documentation'!
       
    49 
       
    50 version_SVN
       
    51     ^ '$Id: PPPluggableParser.st,v 1.1 2011-08-18 18:56:17 cg Exp $'
       
    52 ! !