4
|
1 |
"{ Package: 'stx:goodies/petitparser' }"
|
0
|
2 |
|
|
3 |
PPParser subclass:#PPLiteralParser
|
|
4 |
instanceVariableNames:'literal message'
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'PetitParser-Parsers'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!PPLiteralParser class methodsFor:'instance creation'!
|
|
12 |
|
|
13 |
on: anObject
|
171
|
14 |
|msg|
|
|
15 |
|
|
16 |
"portable - does not depend on character to print with a $"
|
|
17 |
msg := anObject isCharacter
|
|
18 |
ifTrue:[ '$',anObject asString]
|
|
19 |
ifFalse:[ anObject printString ].
|
|
20 |
^ self on: anObject message: msg , ' expected'
|
0
|
21 |
!
|
|
22 |
|
|
23 |
on: anObject message: aString
|
|
24 |
^ self new initializeOn: anObject message: aString
|
|
25 |
! !
|
|
26 |
|
171
|
27 |
!PPLiteralParser methodsFor:'*petitanalyzer-matching'!
|
|
28 |
|
|
29 |
match: aParser inContext: aDictionary seen: anIdentitySet
|
|
30 |
^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self literal = aParser literal and: [ self message = aParser message ] ]
|
|
31 |
! !
|
|
32 |
|
0
|
33 |
!PPLiteralParser methodsFor:'accessing'!
|
|
34 |
|
|
35 |
literal
|
|
36 |
"Answer the parsed literal."
|
|
37 |
|
|
38 |
^ literal
|
|
39 |
!
|
|
40 |
|
|
41 |
message
|
|
42 |
"Answer the failure message."
|
35
|
43 |
|
0
|
44 |
^ message
|
|
45 |
! !
|
|
46 |
|
|
47 |
!PPLiteralParser methodsFor:'initialization'!
|
|
48 |
|
|
49 |
initializeOn: anObject message: aString
|
|
50 |
literal := anObject.
|
|
51 |
message := aString
|
|
52 |
! !
|
|
53 |
|
|
54 |
!PPLiteralParser methodsFor:'operators'!
|
|
55 |
|
|
56 |
caseInsensitive
|
|
57 |
"Answer a parser that can parse the receiver case-insensitive."
|
35
|
58 |
|
0
|
59 |
self subclassResponsibility
|
|
60 |
! !
|
|
61 |
|
|
62 |
!PPLiteralParser methodsFor:'printing'!
|
|
63 |
|
|
64 |
printNameOn: aStream
|
171
|
65 |
super printNameOn: aStream.
|
|
66 |
literal isCharacter ifTrue:[
|
|
67 |
"/ portable - does not depend on character-print to print with $
|
|
68 |
aStream nextPutAll: ', $'; print: literal asString
|
|
69 |
] ifFalse:[
|
|
70 |
aStream nextPutAll: ', '; print: literal
|
|
71 |
].
|
0
|
72 |
! !
|
|
73 |
|
|
74 |
!PPLiteralParser class methodsFor:'documentation'!
|
|
75 |
|
35
|
76 |
version
|
171
|
77 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLiteralParser.st,v 1.4 2014-03-04 14:33:03 cg Exp $'
|
35
|
78 |
!
|
|
79 |
|
|
80 |
version_CVS
|
171
|
81 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPLiteralParser.st,v 1.4 2014-03-04 14:33:03 cg Exp $'
|
35
|
82 |
!
|
|
83 |
|
0
|
84 |
version_SVN
|
171
|
85 |
^ '$Id: PPLiteralParser.st,v 1.4 2014-03-04 14:33:03 cg Exp $'
|
0
|
86 |
! !
|
171
|
87 |
|