PPListParser.st
author sr
Thu, 05 Jul 2018 09:23:25 +0200
changeset 626 5159b1039a8f
parent 169 cba3a51b9704
child 421 7e08b31e0dae
child 638 e41b42b3928f
permissions -rw-r--r--
order
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4
90de244a7fa2 move to package
Claus Gittinger <cg@exept.de>
parents: 0
diff changeset
     1
"{ Package: 'stx:goodies/petitparser' }"
0
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
PPParser subclass:#PPListParser
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	instanceVariableNames:'parsers'
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	classVariableNames:''
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	poolDictionaries:''
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	category:'PetitParser-Parsers'
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
!PPListParser class methodsFor:'instance creation'!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
with: aParser
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
	^ self withAll: (Array with: aParser)
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
with: aFirstParser with: aSecondParser
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	^ self withAll: (Array with: aFirstParser with: aSecondParser)
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
withAll: aCollection
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
	^ self basicNew setParsers: aCollection
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
! !
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
169
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    25
!PPListParser methodsFor:'*petitanalyzer-matching'!
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    26
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    27
copyInContext: aDictionary seen: aSeenDictionary
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    28
	| copy copies |
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    29
	aSeenDictionary at: self ifPresent: [ :value | ^ value ].
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    30
	copy := aSeenDictionary at: self put: self copy.
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    31
	copies := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    32
	parsers do: [ :each |
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    33
		| result |
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    34
		result := each 
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    35
			copyInContext: aDictionary
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    36
			seen: aSeenDictionary.
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    37
		result isCollection
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    38
			ifTrue: [ copies addAll: result ]
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    39
			ifFalse: [ copies add: result ] ].
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    40
	^ copy
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    41
		setParsers: copies;
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    42
		yourself
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    43
! !
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    44
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    45
!PPListParser methodsFor:'*petitanalyzer-transforming'!
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    46
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    47
replace: aParser with: anotherParser
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    48
	super replace: aParser with: anotherParser.
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    49
	parsers keysAndValuesDo: [ :index :parser |
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    50
		parser == aParser
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    51
			ifTrue: [ parsers at: index put: anotherParser ] ]
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    52
! !
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    53
0
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
!PPListParser methodsFor:'accessing'!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
children
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
	^ parsers
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
! !
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
!PPListParser methodsFor:'copying'!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
copyWith: aParser
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
	^ self species withAll: (parsers copyWith: aParser)
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
postCopy
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
	super postCopy.
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
	parsers := parsers copy
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
! !
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!PPListParser methodsFor:'initialization'!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
initialize
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
	super initialize.
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
	self setParsers: #()
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
setParsers: aCollection
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
	parsers := aCollection asArray
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
! !
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
!PPListParser class methodsFor:'documentation'!
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
56
e6c555201a3a Checkin from browser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    84
version
169
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    85
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPListParser.st,v 1.4 2014-03-04 14:32:58 cg Exp $'
56
e6c555201a3a Checkin from browser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    86
!
e6c555201a3a Checkin from browser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    87
e6c555201a3a Checkin from browser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    88
version_CVS
169
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    89
    ^ '$Header: /cvs/stx/stx/goodies/petitparser/PPListParser.st,v 1.4 2014-03-04 14:32:58 cg Exp $'
56
e6c555201a3a Checkin from browser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    90
!
e6c555201a3a Checkin from browser
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 4
diff changeset
    91
0
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
version_SVN
169
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    93
    ^ '$Id: PPListParser.st,v 1.4 2014-03-04 14:32:58 cg Exp $'
0
739fe9b7253e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
! !
169
Claus Gittinger <cg@exept.de>
parents: 56
diff changeset
    95