mercurial/HGCommandParser.st
author vranyj1@bd9d3459-6c23-4dd9-91de-98eeebb81177
Fri, 09 Nov 2012 12:09:13 +0000
changeset 38 c3d02ed6a645
parent 36 41cb88196e69
child 39 10e693b3e034
permissions -rw-r--r--
- HGWorkingCopyFile changed: #status - HGCommandParser changed: #nextLine #nextSpace - HGTests changed: #test_01a - HGStatus added: #theOnlyInstance - HGCommand class definition added: #initialize changed: #execute

"{ Package: 'stx:libscm/mercurial' }"

Object subclass:#HGCommandParser
	instanceVariableNames:'stream'
	classVariableNames:''
	poolDictionaries:''
	category:'SCM-Mercurial-Internal'
!


!HGCommandParser class methodsFor:'instance creation'!

on: aStream
    ^self new stream: aStream

    "Created: / 23-10-2012 / 11:07:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCommandParser methodsFor:'accessing'!

stream
    ^ stream
!

stream:something
    stream := something.
! !

!HGCommandParser methodsFor:'error reporting'!

parseStatus
    | c |
    stream skipSeparators.
    c := stream peek.
    self halt.

    "Created: / 22-10-2012 / 21:43:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCommandParser methodsFor:'parsing'!

parseCommandStatus
    | statusesAndPaths |
    statusesAndPaths := OrderedCollection new.
    [ stream atEnd ] whileFalse:[
        | status path |

        status := HGStatus forCode: self next.
        self nextSpace.
        path := self nextLine.
        statusesAndPaths add: { status . path }
    ].
    ^ statusesAndPaths

    "Created: / 23-10-2012 / 10:57:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCommandParser methodsFor:'parsing-utils'!

next
    ^stream next.

    "Created: / 23-10-2012 / 10:57:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

nextLine
    ^stream nextLine

    "Created: / 23-10-2012 / 11:05:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 09-11-2012 / 12:02:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

nextSpace
    | c |
    ((c := stream next) ~= Character space) ifTrue:[
        self error:'Space expected. ''', c , ''' found!!'
    ]

    "Created: / 23-10-2012 / 10:58:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 09-11-2012 / 11:59:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!HGCommandParser class methodsFor:'documentation'!

version_SVN
    ^ '$Id::                                                                                                                        $'
! !