PPStream.st
changeset 405 0470a5e6e712
parent 388 74c9c229033b
child 421 7e08b31e0dae
equal deleted inserted replaced
404:8da796db7f95 405:0470a5e6e712
     4 	instanceVariableNames:''
     4 	instanceVariableNames:''
     5 	classVariableNames:''
     5 	classVariableNames:''
     6 	poolDictionaries:''
     6 	poolDictionaries:''
     7 	category:'PetitParser-Core'
     7 	category:'PetitParser-Core'
     8 !
     8 !
       
     9 
     9 
    10 
    10 
    11 
    11 !PPStream methodsFor:'accessing'!
    12 !PPStream methodsFor:'accessing'!
    12 
    13 
    13 collection
    14 collection
    36 	"The receiver does not check for invalid arguments passed to this method, as it is solely used with valid indexes for backtracking."
    37 	"The receiver does not check for invalid arguments passed to this method, as it is solely used with valid indexes for backtracking."
    37 
    38 
    38 	position := anInteger
    39 	position := anInteger
    39 !
    40 !
    40 
    41 
       
    42 size
       
    43 	"
       
    44 		The same implementation as a ReadStream. Implemented here for compatibility with Smalltalk/X
       
    45 		that has different implementation in a ReadStream
       
    46 	"
       
    47 	^readLimit
       
    48 !
       
    49 
    41 uncheckedPeek
    50 uncheckedPeek
    42 	"An unchecked version of peek that throws an error if we try to peek over the end of the stream, even faster than #peek."
    51 	"An unchecked version of peek that throws an error if we try to peek over the end of the stream, even faster than #peek."
    43 
    52 
    44 	^ collection at: position + 1
    53 	^ collection at: position + 1
    45 ! !
    54 ! !
    62 ! !
    71 ! !
    63 
    72 
    64 !PPStream methodsFor:'queries'!
    73 !PPStream methodsFor:'queries'!
    65 
    74 
    66 insideCRLF
    75 insideCRLF
    67         (position < 1) ifTrue: [ ^ false ].
    76 	(position < 1) ifTrue: [ ^ false ].
    68         
    77 	
    69         ^ (self peek = (Character codePoint: 10)) and: [ self peekBack = (Character codePoint: 13) ]
    78 	^ (self peek = (Character codePoint: 10)) and: [ self peekBack = (Character codePoint: 13) ]
       
    79 !
    70 
    80 
    71     "Modified: / 03-10-2014 / 23:52:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    81 isEndOfLine
       
    82 	self atEnd ifTrue: [ ^ true ].
       
    83 	self insideCRLF ifTrue: [ ^ false ].
       
    84 	^ (self peek = (Character codePoint: 13) or: [ self peek = (Character codePoint: 10)]).
    72 !
    85 !
    73 
    86 
    74 isStartOfLine
    87 isStartOfLine
    75         (position = 0) ifTrue: [ ^ true ].
    88 	(position = 0) ifTrue: [ ^ true ].
    76 
    89 
    77         self insideCRLF ifTrue: [ ^ false ].
    90 	self insideCRLF ifTrue: [ ^ false ].
    78         
    91 	
    79         ^ (self peekBack = (Character codePoint: 13)) or: [ self peekBack = (Character codePoint: 10)].
    92 	^ (self peekBack = (Character codePoint: 13)) or: [ self peekBack = (Character codePoint: 10)].
    80 
       
    81     "Modified: / 03-10-2014 / 23:52:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    82 !
       
    83 
       
    84 size
       
    85     ^ readLimit
       
    86     "DO NOT REMOVE this method event though in Pharo it is the same as
       
    87      inherited. This is required for Smalltalk/X compatibility"
       
    88 
       
    89     "Created: / 08-10-2014 / 12:25:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    90 ! !
    93 ! !
    91 
    94 
    92 !PPStream class methodsFor:'documentation'!
    95 !PPStream class methodsFor:'documentation'!
    93 
    96 
    94 version
    97 version