equal
deleted
inserted
replaced
25 ^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self message = aParser message ] |
25 ^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self message = aParser message ] |
26 ! ! |
26 ! ! |
27 |
27 |
28 !PPLimitedRepeatingParser methodsFor:'*petitanalyzer-transforming'! |
28 !PPLimitedRepeatingParser methodsFor:'*petitanalyzer-transforming'! |
29 |
29 |
30 replace:aParser with:anotherParser |
30 replace: aParser with: anotherParser |
31 super replace:aParser with:anotherParser. |
31 super replace: aParser with: anotherParser. |
32 limit == aParser ifTrue:[limit := anotherParser]. |
32 limit == aParser ifTrue: [ limit := anotherParser ] |
33 ! ! |
33 ! ! |
34 |
34 |
35 !PPListParser methodsFor:'*petitanalyzer-matching'! |
35 !PPListParser methodsFor:'*petitanalyzer-matching'! |
36 |
36 |
37 copyInContext: aDictionary seen: aSeenDictionary |
37 copyInContext: aDictionary seen: aSeenDictionary |
65 |
65 |
66 match: aParser inContext: aDictionary seen: anIdentitySet |
66 match: aParser inContext: aDictionary seen: anIdentitySet |
67 ^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self literal = aParser literal and: [ self message = aParser message ] ] |
67 ^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self literal = aParser literal and: [ self message = aParser message ] ] |
68 ! ! |
68 ! ! |
69 |
69 |
|
70 !PPNotParser methodsFor:'*petitanalyzer-private'! |
|
71 |
|
72 firstSets: aFirstDictionary into: aSet |
|
73 |
|
74 ! ! |
|
75 |
|
76 !PPNotParser methodsFor:'*petitanalyzer-testing'! |
|
77 |
|
78 isFirstSetTerminal |
|
79 ^ true |
|
80 ! ! |
|
81 |
70 !PPOptionalParser methodsFor:'*petitanalyzer-testing'! |
82 !PPOptionalParser methodsFor:'*petitanalyzer-testing'! |
71 |
83 |
72 isNullable |
84 isNullable |
73 ^ true |
85 ^ true |
74 ! ! |
86 ! ! |
198 "Answer a dictionary with all the parsers reachable from the receiver as key and their first-set as value. The first-set of a parser is the list of terminal parsers that begin the parser derivable from that parser." |
210 "Answer a dictionary with all the parsers reachable from the receiver as key and their first-set as value. The first-set of a parser is the list of terminal parsers that begin the parser derivable from that parser." |
199 |
211 |
200 | firstSets | |
212 | firstSets | |
201 firstSets := IdentityDictionary new. |
213 firstSets := IdentityDictionary new. |
202 self allParsersDo: [ :each | |
214 self allParsersDo: [ :each | |
203 firstSets at: each put: (each isTerminal |
215 firstSets at: each put: (each isFirstSetTerminal |
204 ifTrue: [ IdentitySet with: each ] |
216 ifTrue: [ IdentitySet with: each ] |
205 ifFalse: [ IdentitySet new ]). |
217 ifFalse: [ IdentitySet new ]). |
206 each isNullable |
218 each isNullable |
207 ifTrue: [ (firstSets at: each) add: PPSentinel instance ] ]. |
219 ifTrue: [ (firstSets at: each) add: PPSentinel instance ] ]. |
208 [ | changed tally | |
220 [ | changed tally | |
293 ifTrue: [ ^ self ]. |
305 ifTrue: [ ^ self ]. |
294 aSet add: each. |
306 aSet add: each. |
295 each name isNil ifTrue: [ |
307 each name isNil ifTrue: [ |
296 aBlock value: each. |
308 aBlock value: each. |
297 each innerChildrenDo: aBlock seen: aSet ] ] |
309 each innerChildrenDo: aBlock seen: aSet ] ] |
|
310 ! ! |
|
311 |
|
312 !PPParser methodsFor:'*petitanalyzer-testing'! |
|
313 |
|
314 isFirstSetTerminal |
|
315 "Answer true if the receiver is a terminal or leaf parser, that means it does not delegate to any other parser." |
|
316 |
|
317 ^ self children isEmpty |
298 ! ! |
318 ! ! |
299 |
319 |
300 !PPParser methodsFor:'*petitanalyzer-testing'! |
320 !PPParser methodsFor:'*petitanalyzer-testing'! |
301 |
321 |
302 isNullable |
322 isNullable |
453 |
473 |
454 match: aParser inContext: aDictionary seen: anIdentitySet |
474 match: aParser inContext: aDictionary seen: anIdentitySet |
455 ^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self size = aParser size ] |
475 ^ (super match: aParser inContext: aDictionary seen: anIdentitySet) and: [ self size = aParser size ] |
456 ! ! |
476 ! ! |
457 |
477 |
|
478 !PPRepeatingParser methodsFor:'*petitanalyzer-private'! |
|
479 |
|
480 followSets: aFollowDictionary firstSets: aFirstDictionary into: aSet |
|
481 | firstSet | |
|
482 super followSets: aFollowDictionary firstSets: aFirstDictionary into: aSet. |
|
483 |
|
484 firstSet := aFirstDictionary at: self. |
|
485 self children do: [:p | (aFollowDictionary at: p) addAll: (firstSet reject: [:each | each isNullable]) ] |
|
486 ! ! |
|
487 |
458 !PPRepeatingParser methodsFor:'*petitanalyzer-testing'! |
488 !PPRepeatingParser methodsFor:'*petitanalyzer-testing'! |
459 |
489 |
460 isNullable |
490 isNullable |
461 ^ min = 0 |
491 ^ min = 0 |
462 ! ! |
492 ! ! |