equal
deleted
inserted
replaced
1 "{ Package: 'stx:goodies/petitparser/compiler/tests' }" |
1 "{ Package: 'stx:goodies/petitparser/compiler/tests' }" |
2 |
2 |
3 "{ NameSpace: Smalltalk }" |
3 "{ NameSpace: Smalltalk }" |
4 |
4 |
5 PPAbstractParserTest subclass:#PPCCodeGeneratorTest |
5 PPAbstractParserTest subclass:#PPCCodeGeneratorTest |
6 instanceVariableNames:'visitor node result compiler parser context configuration |
6 instanceVariableNames:'visitor node result compiler parser context configuration options' |
7 arguments' |
|
8 classVariableNames:'' |
7 classVariableNames:'' |
9 poolDictionaries:'' |
8 poolDictionaries:'' |
10 category:'PetitCompiler-Tests-Visitors' |
9 category:'PetitCompiler-Tests-Visitors' |
11 ! |
10 ! |
12 |
11 |
16 context |
15 context |
17 ^ context := PPCProfilingContext new |
16 ^ context := PPCProfilingContext new |
18 ! |
17 ! |
19 |
18 |
20 setUp |
19 setUp |
21 arguments := PPCArguments default |
20 options := PPCCompilationOptions default |
22 profile: true; |
21 profile: true; |
23 codeGenerator: PPCCodeGenerator. |
22 codeGenerator: PPCCodeGenerator. |
24 |
23 |
25 configuration := PPCPluggableConfiguration on: [ :_self | |
24 configuration := PPCPluggableConfiguration on: [ :_self | |
26 _self cacheFirstFollow. |
25 _self cacheFirstFollow. |
27 _self check. |
26 _self check. |
28 _self generate. |
27 _self generate. |
29 ]. |
28 ]. |
30 configuration arguments: arguments. |
29 configuration options: options. |
|
30 |
|
31 "Modified: / 24-08-2015 / 23:40:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
31 ! |
32 ! |
32 |
33 |
33 tearDown |
34 tearDown |
34 | class | |
35 | class | |
35 |
36 |
923 |
924 |
924 "Created: / 22-05-2015 / 11:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
925 "Created: / 22-05-2015 / 11:47:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
925 ! |
926 ! |
926 |
927 |
927 testStarAnyNode |
928 testStarAnyNode |
928 arguments cacheFirstFollow: false. |
929 options cacheFirstFollow: false. |
929 node := PPCStarAnyNode new |
930 node := PPCStarAnyNode new |
930 child: PPCNilNode new; |
931 child: PPCNilNode new; |
931 yourself. |
932 yourself. |
932 self compileTree: node. |
933 self compileTree: node. |
933 |
934 |
935 self assert: parser parse: 'a' to: #($a). |
936 self assert: parser parse: 'a' to: #($a). |
936 self assert: parser parse: '' to: #(). |
937 self assert: parser parse: '' to: #(). |
937 ! |
938 ! |
938 |
939 |
939 testStarCharSetPredicateNode |
940 testStarCharSetPredicateNode |
940 arguments cacheFirstFollow: false. |
941 options cacheFirstFollow: false. |
941 node := PPCStarCharSetPredicateNode new |
942 node := PPCStarCharSetPredicateNode new |
942 predicate: (PPCharSetPredicate on: [:e | e = $a ]); |
943 predicate: (PPCharSetPredicate on: [:e | e = $a ]); |
943 child: PPCSentinelNode new; |
944 child: PPCSentinelNode new; |
944 yourself. |
945 yourself. |
945 |
946 |
952 self assert: context invocationCount = 1. |
953 self assert: context invocationCount = 1. |
953 |
954 |
954 ! |
955 ! |
955 |
956 |
956 testStarMessagePredicateNode |
957 testStarMessagePredicateNode |
957 arguments cacheFirstFollow: false. |
958 options cacheFirstFollow: false. |
958 node := PPCStarMessagePredicateNode new |
959 node := PPCStarMessagePredicateNode new |
959 message: #isLetter; |
960 message: #isLetter; |
960 child: PPCSentinelNode new; |
961 child: PPCSentinelNode new; |
961 yourself. |
962 yourself. |
962 |
963 |
1030 |
1031 |
1031 node := PPCTokenStarMessagePredicateNode new |
1032 node := PPCTokenStarMessagePredicateNode new |
1032 message: #isLetter; |
1033 message: #isLetter; |
1033 child: PPCSentinelNode new; |
1034 child: PPCSentinelNode new; |
1034 yourself. |
1035 yourself. |
1035 arguments cacheFirstFollow: false. |
1036 options cacheFirstFollow: false. |
1036 arguments guards: false. |
1037 options guards: false. |
1037 self compileTree: node. |
1038 self compileTree: node. |
1038 |
1039 |
1039 self assert: parser class methodDictionary size = 1. |
1040 self assert: parser class methodDictionary size = 1. |
1040 |
1041 |
1041 self assert: parser parse: 'foo' to: parser. |
1042 self assert: parser parse: 'foo' to: parser. |
1055 child: PPCSentinelNode new; |
1056 child: PPCSentinelNode new; |
1056 yourself. |
1057 yourself. |
1057 node := PPCForwardNode new |
1058 node := PPCForwardNode new |
1058 child: starNode; |
1059 child: starNode; |
1059 yourself. |
1060 yourself. |
1060 arguments cacheFirstFollow: false. |
1061 options cacheFirstFollow: false. |
1061 self compileTree: node. |
1062 self compileTree: node. |
1062 |
1063 |
1063 self assert: parser class methodDictionary size = 2. |
1064 self assert: parser class methodDictionary size = 2. |
1064 |
1065 |
1065 self assert: parser parse: ' a' to: parser end: 3. |
1066 self assert: parser parse: ' a' to: parser end: 3. |
1076 markForInline; |
1077 markForInline; |
1077 yourself. |
1078 yourself. |
1078 node := PPCForwardNode new |
1079 node := PPCForwardNode new |
1079 child: starNode; |
1080 child: starNode; |
1080 yourself. |
1081 yourself. |
1081 arguments cacheFirstFollow: false. |
1082 options cacheFirstFollow: false. |
1082 self compileTree: node. |
1083 self compileTree: node. |
1083 |
1084 |
1084 self assert: parser class methodDictionary size = 1. |
1085 self assert: parser class methodDictionary size = 1. |
1085 |
1086 |
1086 self assert: parser parse: ' a' to: context end: 3. |
1087 self assert: parser parse: ' a' to: context end: 3. |