17 set add: self. |
17 set add: self. |
18 ^ self children anySatisfy: [:e | e acceptsEpsilonOpenSet: set ]. |
18 ^ self children anySatisfy: [:e | e acceptsEpsilonOpenSet: set ]. |
19 ! |
19 ! |
20 |
20 |
21 compileWith: compiler effect: effect id: id |
21 compileWith: compiler effect: effect id: id |
22 | firsts guard | |
22 | firsts guard whitespaceConsumed | |
23 |
23 |
|
24 whitespaceConsumed := false. |
24 firsts := (self firstSetSuchThat: [ :e | (e isKindOf: PPCTrimmingTokenNode) or: [ e isTerminal ] ]). |
25 firsts := (self firstSetSuchThat: [ :e | (e isKindOf: PPCTrimmingTokenNode) or: [ e isTerminal ] ]). |
25 |
26 |
26 compiler startMethod: id. |
27 compiler startMethod: id. |
27 compiler addVariable: 'element'. |
28 compiler addVariable: 'element'. |
28 |
29 |
29 "If we start with trimming token, we should invoke the whitespace parser" |
30 "If we start with trimming token, we should invoke the whitespace parser" |
30 (firsts allSatisfy: [ :e | e isKindOf: PPCTrimmingTokenNode ]) ifTrue: [ |
31 (firsts allSatisfy: [ :e | e isKindOf: PPCTrimmingTokenNode ]) ifTrue: [ |
31 firsts anyOne compileWhitespace: compiler. |
32 firsts anyOne compileWhitespace: compiler. |
|
33 whitespaceConsumed := true. |
32 ]. |
34 ]. |
33 |
35 |
34 (1 to: children size) do: [ :idx | |child| |
36 (1 to: children size) do: [ :idx | |child allowGuard | |
35 child := children at: idx. |
37 child := children at: idx. |
36 |
38 " allowGuard := ((child isKindOf: PPCTrimmingTokenNode) and: [ whitespaceConsumed not ]) not. |
37 (compiler guards and: [ (guard := PPCGuard on: child) makesSense ]) ifTrue: [ |
39 " |
|
40 allowGuard := whitespaceConsumed. |
|
41 |
|
42 (allowGuard and: [compiler guards and: [ (guard := PPCGuard on: child) makesSense ]]) ifTrue: [ |
38 guard id: (compiler idFor: guard prefixed: #guard). |
43 guard id: (compiler idFor: guard prefixed: #guard). |
39 guard compileGuard: compiler. |
44 guard compileGuard: compiler. |
40 compiler add: ' ifTrue: [ '. |
45 compiler add: ' ifTrue: [ '. |
41 compiler indent. |
46 compiler indent. |
42 compiler add: 'self clearError.'. |
47 compiler add: 'self clearError.'. |