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 |
PPLiteralParser comment:'Abstract literal parser that parses some kind of literal type (to be specified by subclasses).
|
|
11 |
Instance Variables:
|
4
|
12 |
literal <Object> The literal object to be parsed.
|
|
13 |
message <String> The error message to be generated.
|
0
|
14 |
'
|
|
15 |
!
|
|
16 |
|
|
17 |
|
|
18 |
!PPLiteralParser class methodsFor:'instance creation'!
|
|
19 |
|
|
20 |
on: anObject
|
|
21 |
^ self on: anObject message: anObject printString , ' expected'
|
|
22 |
!
|
|
23 |
|
|
24 |
on: anObject message: aString
|
|
25 |
^ self new initializeOn: anObject message: aString
|
|
26 |
! !
|
|
27 |
|
|
28 |
!PPLiteralParser methodsFor:'accessing'!
|
|
29 |
|
|
30 |
literal
|
|
31 |
"Answer the parsed literal."
|
|
32 |
|
|
33 |
^ literal
|
|
34 |
!
|
|
35 |
|
|
36 |
message
|
|
37 |
"Answer the failure message."
|
4
|
38 |
|
0
|
39 |
^ message
|
|
40 |
! !
|
|
41 |
|
|
42 |
!PPLiteralParser methodsFor:'initialization'!
|
|
43 |
|
|
44 |
initializeOn: anObject message: aString
|
|
45 |
literal := anObject.
|
|
46 |
message := aString
|
|
47 |
! !
|
|
48 |
|
|
49 |
!PPLiteralParser methodsFor:'operators'!
|
|
50 |
|
|
51 |
caseInsensitive
|
|
52 |
"Answer a parser that can parse the receiver case-insensitive."
|
4
|
53 |
|
0
|
54 |
self subclassResponsibility
|
|
55 |
! !
|
|
56 |
|
|
57 |
!PPLiteralParser methodsFor:'printing'!
|
|
58 |
|
|
59 |
printNameOn: aStream
|
|
60 |
super printNameOn: aStream.
|
|
61 |
aStream nextPutAll: ', '; print: literal
|
|
62 |
! !
|
|
63 |
|
|
64 |
!PPLiteralParser class methodsFor:'documentation'!
|
|
65 |
|
|
66 |
version_SVN
|
4
|
67 |
^ '$Id: PPLiteralParser.st,v 1.2 2012-01-13 11:22:50 cg Exp $'
|
0
|
68 |
! !
|