author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 28 Jul 2015 07:16:10 +0100 | |
changeset 507 | c5773c25eedc |
parent 406 | c05417ade8ac |
permissions | -rw-r--r-- |
4 | 1 |
"{ Package: 'stx:goodies/petitparser' }" |
0 | 2 |
|
3 |
PPDelegateParser subclass:#PPRepeatingParser |
|
4 |
instanceVariableNames:'min max' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'PetitParser-Parsers' |
|
8 |
! |
|
9 |
||
10 |
||
11 |
!PPRepeatingParser class methodsFor:'instance creation'! |
|
12 |
||
13 |
on: aParser |
|
14 |
^ (super on: aParser) setMin: 0 max: SmallInteger maxVal |
|
15 |
! |
|
16 |
||
17 |
on: aParser max: aMaxInteger |
|
18 |
^ (self on: aParser) setMin: 0 max: aMaxInteger |
|
19 |
! |
|
20 |
||
21 |
on: aParser min: aMinInteger |
|
52 | 22 |
^ (self on: aParser) setMin: aMinInteger max: SmallInteger maxVal |
0 | 23 |
! |
24 |
||
25 |
on: aParser min: aMinInteger max: aMaxInteger |
|
26 |
^ (self on: aParser) setMin: aMinInteger max: aMaxInteger |
|
27 |
! ! |
|
28 |
||
179 | 29 |
|
30 |
||
31 |
||
406
c05417ade8ac
Removed PPRepeatingParser>>parseOn: - class is now abstract
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
378
diff
changeset
|
32 |
|
0 | 33 |
!PPRepeatingParser methodsFor:'accessing'! |
34 |
||
35 |
max |
|
36 |
"Answer the maximum number of repetitions." |
|
37 |
||
38 |
^ max |
|
39 |
! |
|
40 |
||
41 |
min |
|
42 |
"Answer the minimum number of repetitions." |
|
52 | 43 |
|
0 | 44 |
^ min |
45 |
! ! |
|
46 |
||
47 |
!PPRepeatingParser methodsFor:'initialization'! |
|
48 |
||
179 | 49 |
initialize |
50 |
super initialize. |
|
51 |
self setMin: 0; setMax: SmallInteger maxVal |
|
52 |
! |
|
53 |
||
54 |
setMax: anInteger |
|
55 |
max := anInteger |
|
56 |
! |
|
57 |
||
58 |
setMin: anInteger |
|
59 |
min := anInteger |
|
60 |
! |
|
61 |
||
0 | 62 |
setMin: aMinInteger max: aMaxInteger |
63 |
min := aMinInteger. |
|
64 |
max := aMaxInteger |
|
65 |
! ! |
|
66 |
||
67 |
!PPRepeatingParser methodsFor:'printing'! |
|
68 |
||
69 |
printOn: aStream |
|
70 |
super printOn: aStream. |
|
71 |
aStream nextPutAll: ' ['; print: min; nextPutAll: ', '; nextPutAll: (max = SmallInteger maxVal |
|
72 |
ifTrue: [ '*' ] ifFalse: [ max printString ]); nextPut: $] |
|
73 |
! ! |
|
74 |
||
75 |
!PPRepeatingParser class methodsFor:'documentation'! |
|
76 |
||
52 | 77 |
version |
179 | 78 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPRepeatingParser.st,v 1.4 2014-03-04 14:33:24 cg Exp $' |
52 | 79 |
! |
80 |
||
81 |
version_CVS |
|
179 | 82 |
^ '$Header: /cvs/stx/stx/goodies/petitparser/PPRepeatingParser.st,v 1.4 2014-03-04 14:33:24 cg Exp $' |
52 | 83 |
! |
84 |
||
0 | 85 |
version_SVN |
179 | 86 |
^ '$Id: PPRepeatingParser.st,v 1.4 2014-03-04 14:33:24 cg Exp $' |
0 | 87 |
! ! |
179 | 88 |