10 ! |
10 ! |
11 |
11 |
12 !PPJavaTokenParser methodsFor:'parsing'! |
12 !PPJavaTokenParser methodsFor:'parsing'! |
13 |
13 |
14 parseComments: anArray on: aStream |
14 parseComments: anArray on: aStream |
15 |
15 |
16 | start comments | |
16 | start comments | |
17 comments := anArray. |
17 comments := anArray. |
18 [ |
18 [ |
19 | peekTwice | |
19 | peekTwice | |
20 [ aStream atEnd not and: [ aStream peek isSeparator ] ] |
20 [ aStream atEnd not and: [ aStream peek isSeparator ] ] |
21 whileTrue: [ aStream next ]. |
21 whileTrue: [ aStream next ]. |
22 peekTwice := aStream peekTwice. |
22 peekTwice := aStream peekTwice. |
23 ((peekTwice first = $/) and: |
23 ((peekTwice first = $/) and: |
24 [ (peekTwice second = $*) or: [peekTwice second = $/]])] whileTrue: [ |
24 [ (peekTwice second = $*) or: [peekTwice second = $/]])] whileTrue: [ |
25 " |
25 " |
26 Transcript show: ('position ', aStream position asString, ' char ', aStream next asString); cr. |
26 Transcript show: ('position ', aStream position asString, ' char ', aStream next asString); cr. |
27 " |
27 " |
28 aStream next. |
28 aStream next. |
29 start := aStream position. |
29 start := aStream position. |
30 (aStream next = $*) |
30 (aStream next = $*) |
31 ifTrue: [ aStream upToAll: '*/' ] |
31 ifTrue: [ aStream upToAll: '*/' ] |
32 ifFalse: [ |
32 ifFalse: [ |
33 | position | |
33 | position | |
34 position := aStream position. |
34 position := aStream position. |
35 aStream upToAnyOf: CharacterSet crlf]. |
35 aStream upToAnyOf: (String with: (Character codePoint: 13) with: (Character codePoint: 10))]. |
36 comments := comments copyWith: (start to: aStream position) ]. |
36 comments := comments copyWith: (start to: aStream position) ]. |
37 ^ comments |
37 ^ comments |
|
38 |
|
39 "Modified: / 21-04-2015 / 17:23:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
38 ! |
40 ! |
39 |
41 |
40 parseOn: aPPContext |
42 parseOn: aPPContext |
41 | token comments memento | |
43 | token comments memento | |
42 memento := aPPContext remember. |
44 memento := aPPContext remember. |