equal
deleted
inserted
replaced
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 PPAbstractParserTest subclass:#PPCTokenizingTest |
5 PPAbstractParserTest subclass:#PPCTokenizingTest |
6 instanceVariableNames:'parser result context node compiler id node2 id2 id1 node1 node3 |
6 instanceVariableNames:'parser result context node compiler id node2 id2 id1 node1 node3 |
7 arguments configuration' |
7 options configuration' |
8 classVariableNames:'' |
8 classVariableNames:'' |
9 poolDictionaries:'' |
9 poolDictionaries:'' |
10 category:'PetitCompiler-Tests-Core-Tokenizing' |
10 category:'PetitCompiler-Tests-Core-Tokenizing' |
11 ! |
11 ! |
12 |
12 |
20 ^ result := super assert: p parse: whatever end: end |
20 ^ result := super assert: p parse: whatever end: end |
21 ! |
21 ! |
22 |
22 |
23 cleanClass |
23 cleanClass |
24 | parserClass scannerClass | |
24 | parserClass scannerClass | |
25 parserClass := (Smalltalk at: arguments parserName ifAbsent: [nil]). |
25 parserClass := (Smalltalk at: options parserName ifAbsent: [nil]). |
26 parserClass notNil ifTrue:[ |
26 parserClass notNil ifTrue:[ |
27 parserClass removeFromSystem |
27 parserClass removeFromSystem |
28 ]. |
28 ]. |
29 |
29 |
30 scannerClass := (Smalltalk at: arguments scannerName ifAbsent: [nil]). |
30 scannerClass := (Smalltalk at: options scannerName ifAbsent: [nil]). |
31 scannerClass notNil ifTrue:[ |
31 scannerClass notNil ifTrue:[ |
32 scannerClass removeFromSystem |
32 scannerClass removeFromSystem |
33 ]. |
33 ]. |
34 |
34 |
35 "Modified: / 24-07-2015 / 19:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
35 "Modified: / 24-07-2015 / 19:50:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
42 parse: whatever |
42 parse: whatever |
43 ^ result := super parse: whatever. |
43 ^ result := super parse: whatever. |
44 ! |
44 ! |
45 |
45 |
46 setUp |
46 setUp |
47 arguments := PPCArguments default |
47 options := PPCCompilationOptions default |
48 profile: true; |
48 profile: true; |
49 yourself. |
49 yourself. |
50 |
50 |
51 configuration := PPCTokenizingConfiguration new |
51 configuration := PPCTokenizingConfiguration new |
52 arguments: arguments; |
52 options: options; |
53 yourself. |
53 yourself. |
54 |
54 |
55 self cleanClass. |
55 self cleanClass. |
|
56 |
|
57 "Modified: / 24-08-2015 / 23:40:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
56 ! |
58 ! |
57 |
59 |
58 tearDown |
60 tearDown |
59 "self cleanClass" |
61 "self cleanClass" |
60 ! |
62 ! |
334 |
336 |
335 self assert: parser fail: 'ac'. |
337 self assert: parser fail: 'ac'. |
336 ! |
338 ! |
337 |
339 |
338 testCompileTokenComplex2 |
340 testCompileTokenComplex2 |
339 | a b argumentsWith | |
341 | a b optionsWith | |
340 "based on the PPSmalltlakGrammar>>blockArgumentsWith" |
342 "based on the PPSmalltlakGrammar>>blockArgumentsWith" |
341 a := $| asParser smalltalkToken |
343 a := $| asParser smalltalkToken |
342 yourself. |
344 yourself. |
343 b := $] asParser smalltalkToken |
345 b := $] asParser smalltalkToken |
344 yourself. |
346 yourself. |
345 argumentsWith := (a / b and ==> [:t | ]) wrapped |
347 optionsWith := (a / b and ==> [:t | ]) wrapped |
346 name: 'argumentsWith'; |
348 name: 'optionsWith'; |
347 yourself. |
349 yourself. |
348 |
350 |
349 parser := argumentsWith compileWithConfiguration: configuration. |
351 parser := optionsWith compileWithConfiguration: configuration. |
350 self assert: parser parse: '|'. |
352 self assert: parser parse: '|'. |
351 |
353 |
352 self assert: parser parse: ']' end: 0. |
354 self assert: parser parse: ']' end: 0. |
353 ! |
355 ! |
354 |
356 |
479 self assert: (parser scanner class methodDictionary includesKey: #scan_fooToken). |
481 self assert: (parser scanner class methodDictionary includesKey: #scan_fooToken). |
480 ! |
482 ! |
481 |
483 |
482 testWhitespace |
484 testWhitespace |
483 | token ws trimmingToken | |
485 | token ws trimmingToken | |
484 configuration arguments inline: false. |
486 configuration options inline: false. |
485 |
487 |
486 token := 'foo' asParser token. |
488 token := 'foo' asParser token. |
487 ws := #blank asParser star name: 'consumeWhitespace'; yourself. |
489 ws := #blank asParser star name: 'consumeWhitespace'; yourself. |
488 trimmingToken := ((ws, token, ws) ==> #second) |
490 trimmingToken := ((ws, token, ws) ==> #second) |
489 propertyAt: 'trimmingToken' put: true; |
491 propertyAt: 'trimmingToken' put: true; |
498 self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 3. |
500 self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 3. |
499 ! |
501 ! |
500 |
502 |
501 testWhitespace2 |
503 testWhitespace2 |
502 | token ws trimmingToken | |
504 | token ws trimmingToken | |
503 configuration arguments inline: false. |
505 configuration options inline: false. |
504 |
506 |
505 token := 'foo' asParser token. |
507 token := 'foo' asParser token. |
506 ws := #blank asParser star name: 'consumeWhitespace'; yourself. |
508 ws := #blank asParser star name: 'consumeWhitespace'; yourself. |
507 trimmingToken := ((ws, token, ws) ==> #second) |
509 trimmingToken := ((ws, token, ws) ==> #second) |
508 propertyAt: 'trimmingToken' put: true; |
510 propertyAt: 'trimmingToken' put: true; |
518 self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 4. |
520 self assert: (context invocations select: [:e | e = #scan_consumeWhitespace ]) size = 4. |
519 ! |
521 ! |
520 |
522 |
521 testWhitespace3 |
523 testWhitespace3 |
522 | token ws trimmingToken | |
524 | token ws trimmingToken | |
523 configuration arguments inline: false. |
525 configuration options inline: false. |
524 |
526 |
525 token := 'foo' asParser token. |
527 token := 'foo' asParser token. |
526 ws := #blank asParser star name: 'consumeWhitespace'; yourself. |
528 ws := #blank asParser star name: 'consumeWhitespace'; yourself. |
527 trimmingToken := ((ws, token, ws) ==> #second) |
529 trimmingToken := ((ws, token, ws) ==> #second) |
528 propertyAt: 'trimmingToken' put: true; |
530 propertyAt: 'trimmingToken' put: true; |