199
|
1 |
"{ Package: 'stx:goodies/petitparser/analyzer' }"
|
|
2 |
|
|
3 |
PPParser subclass:#PPPattern
|
|
4 |
instanceVariableNames:'verificationBlock'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitAnalyzer-Core'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPPattern class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
any
|
|
14 |
"Matches all parsers."
|
|
15 |
|
|
16 |
^ self on: [ :parser :context | true ]
|
|
17 |
!
|
|
18 |
|
|
19 |
class: aBehavior
|
|
20 |
"Matches parsers that are of the class aBehavior."
|
|
21 |
|
|
22 |
^ self on: [ :parser :context | parser class = aBehavior ]
|
|
23 |
!
|
|
24 |
|
|
25 |
kind: aBehavior
|
|
26 |
"Matches parsers that are of the class aBehavior or one of its subclasses."
|
|
27 |
|
|
28 |
^ self on: [ :parser :context | parser isKindOf: aBehavior ]
|
|
29 |
!
|
|
30 |
|
|
31 |
name: aString
|
|
32 |
"Matches parsers with the name aString."
|
|
33 |
|
|
34 |
^ self on: [ :parser :context | parser name = aString ]
|
|
35 |
!
|
|
36 |
|
|
37 |
new
|
|
38 |
self error: 'Use an explicit constructur on ' , self name
|
|
39 |
!
|
|
40 |
|
|
41 |
on: aBlock
|
|
42 |
"Matches parsers that satisfy an arbitrary condition in aBlock."
|
|
43 |
|
|
44 |
^ self basicNew initializeOn: aBlock
|
|
45 |
! !
|
|
46 |
|
|
47 |
!PPPattern methodsFor:'comparing'!
|
|
48 |
|
|
49 |
= aParser
|
|
50 |
^ self == aParser or: [ self name notNil and: [ self name = aParser name ] ]
|
|
51 |
!
|
|
52 |
|
|
53 |
hash
|
|
54 |
^ self identityHash
|
|
55 |
! !
|
|
56 |
|
|
57 |
!PPPattern methodsFor:'initialization'!
|
|
58 |
|
|
59 |
initializeOn: aBlock
|
|
60 |
verificationBlock := aBlock
|
|
61 |
! !
|
|
62 |
|
|
63 |
!PPPattern methodsFor:'matching'!
|
|
64 |
|
|
65 |
copyInContext: aDictionary seen: aSeenDictionary
|
|
66 |
^ aDictionary at: self
|
|
67 |
!
|
|
68 |
|
|
69 |
match: aParser inContext: aDictionary seen: anIdentitySet
|
|
70 |
(verificationBlock value: aParser value: aDictionary)
|
|
71 |
ifFalse: [ ^ false ].
|
|
72 |
^ (aDictionary at: self ifAbsentPut: [ aParser ])
|
|
73 |
match: aParser inContext: aDictionary seen: anIdentitySet
|
|
74 |
! !
|
|
75 |
|
|
76 |
!PPPattern methodsFor:'parsing'!
|
|
77 |
|
|
78 |
parseOn: aStream
|
|
79 |
"This is just a pattern used for matching. It should not be used in actual grammars."
|
|
80 |
|
|
81 |
self shouldNotImplement
|
|
82 |
! !
|
|
83 |
|
|
84 |
!PPPattern class methodsFor:'documentation'!
|
|
85 |
|
|
86 |
version
|
290
|
87 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/analyzer/PPPattern.st,v 1.2 2014-03-04 20:27:49 cg Exp $'
|
199
|
88 |
!
|
|
89 |
|
|
90 |
version_CVS
|
290
|
91 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/analyzer/PPPattern.st,v 1.2 2014-03-04 20:27:49 cg Exp $'
|
199
|
92 |
! !
|
|
93 |
|