compiler/tests/PPCTokenizingTest.st
changeset 538 16e8536f5cfb
parent 537 fb212e14d1f4
--- a/compiler/tests/PPCTokenizingTest.st	Mon Sep 07 08:20:46 2015 +0100
+++ b/compiler/tests/PPCTokenizingTest.st	Mon Sep 07 11:53:38 2015 +0100
@@ -44,7 +44,7 @@
 !
 
 setUp
-    options := (PPCCompilationOptions default)
+    options := (PPCCompilationOptions new)
             profile:true;
             tokenize:true;
             yourself.
@@ -52,7 +52,7 @@
     compiler context options:options.
     self cleanClass.
 
-    "Modified: / 04-09-2015 / 16:21:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-09-2015 / 10:22:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 tearDown
@@ -67,7 +67,7 @@
     p1 := a1 star.
     p2 := a2.
     
-    parser := p1 / p2 compileUsingCompiler:compiler.
+    parser := compiler compile: (p1 / p2).
 
     self assert: parser parse: ''.
     self assert: result isEmpty.
@@ -87,8 +87,8 @@
 !
 
 testChoiceOrder
-    parser := (('a' asParser token , 'b' asParser token) / 'a' asParser token) 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile: (('a' asParser token , 'b' asParser token) / 'a' asParser token).
+
     
     self assert: parser parse: 'ab'.
     self assert: result first inputValue = 'a'.
@@ -98,7 +98,8 @@
     self assert: result inputValue = 'a'.
 
     self assert: parser fail: '_'.
-    
+
+    "Modified: / 07-09-2015 / 12:36:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testChoiceOrder2
@@ -106,7 +107,7 @@
     p1 := 'a' asParser token, 'b' asParser token.
     p2 := 'b' asParser token / 'a' asParser token.
     
-    parser := p1 / p2 compileUsingCompiler:compiler.
+    parser := compiler compile: (p1 / p2).
     
     self assert: parser parse: 'ab'.
     self assert: result first inputValue = 'a'.
@@ -130,7 +131,7 @@
     p1 := a1, 'b' asParser token.
     p2 := a2.
     
-    parser := p1 / p2 compileUsingCompiler:compiler.
+    parser := compiler compile: (p1 / p2).
     
     self assert: parser parse: 'ab'.
     self assert: result first inputValue = 'a'.
@@ -151,7 +152,7 @@
     p1 := a1, 'b' asParser token.
     p2 := 'b' asParser token / a2.
     
-    parser := p1 / p2 compileUsingCompiler:compiler.
+    parser := compiler compile: (p1 / p2).
     
     self assert: parser parse: 'ab'.
     self assert: result first inputValue = 'a'.
@@ -168,41 +169,42 @@
 !
 
 testCompileAnd
-    parser := (('foo' asParser token and) / ('bar' asParser token and)) 
-                    , 'bar' asParser token compileUsingCompiler:compiler.
+    parser := compiler compile:(('foo' asParser token and) / ('bar' asParser token and)) 
+                    , 'bar' asParser token.
     
     self assert: parser parse: 'bar'.
     self assert: result second inputValue = 'bar'.
+
+    "Modified: / 07-09-2015 / 12:36:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileChoice
-    parser := ('foo' asParser / 'bar' asParser) token 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser / 'bar' asParser) token.
+
+    self assert: parser parse: 'foo'.
+    self assert: result inputValue = 'foo'.
+    self assert: parser parse: 'bar'.
+    self assert: result inputValue = 'bar'.
+    self assert: parser fail: '_'.
+
+    "Modified: / 07-09-2015 / 12:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+testCompileChoice2
+    parser := compiler compile:('foo' asParser token trim / 'bar' asParser token trim).
     
     self assert: parser parse: 'foo'.
     self assert: result inputValue = 'foo'.
     self assert: parser parse: 'bar'.
     self assert: result inputValue = 'bar'.
     self assert: parser fail: '_'.
-    
-!
 
-testCompileChoice2
-    parser := ('foo' asParser token trim / 'bar' asParser token trim) 
-                    compileUsingCompiler:compiler.
-    
-    self assert: parser parse: 'foo'.
-    self assert: result inputValue = 'foo'.
-    self assert: parser parse: 'bar'.
-    self assert: result inputValue = 'bar'.
-    self assert: parser fail: '_'.
-    
+    "Modified: / 07-09-2015 / 12:36:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileComplex1
-    parser := ('foo' asParser token , 'bar' asParser token) 
-                    / ('foo' asParser token , 'baz' asParser token) 
-                        compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser token , 'bar' asParser token) 
+                    / ('foo' asParser token , 'baz' asParser token).
     
     self assert: parser parse: 'foobar'.
     self assert: result second inputValue = 'bar'.
@@ -211,30 +213,32 @@
     self assert: result second inputValue = 'baz'.
 
     self assert: parser fail: 'foobaq'.
-    
+
+    "Modified: / 07-09-2015 / 12:36:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileComplex2
-    parser := ('foo' asParser token , 'bar' asParser token) star , 'foo' asParser token 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile:('foo' asParser token , 'bar' asParser token) star , 'foo' asParser token.
     
     self assert: parser parse: 'foobarfoobarfoo'.
     self assert: parser parse: 'foo'.
 
     self assert: parser fail: 'bar'.
-    
+
+    "Modified: / 07-09-2015 / 12:37:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileComplex3
-    parser :=	(('foo' asParser token , 'bar' asParser token) star , 'foo' asParser token) 
-                    / ('foo' asParser token , 'baz' asParser token) 
-                        compileUsingCompiler:compiler.
+    parser := compiler compile: (('foo' asParser token , 'bar' asParser token) star , 'foo' asParser token) 
+                    / ('foo' asParser token , 'baz' asParser token).
+
     
     self assert: parser parse: 'foobarfoobarfoo'.
     self assert: parser parse: 'foo'.
 
     self assert: parser fail: 'bar'.
-    
+
+    "Modified: / 07-09-2015 / 12:37:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileEmptytoken
@@ -244,16 +248,18 @@
     epsilon := '' asParser token.
     
     self should: [
-        (start , epsilon , stop) compileUsingCompiler:compiler.
+        compiler compile: (start , epsilon , stop)
     ] raise: Exception.
-"	
+"       
     self assert: parser parse: '()'.
     self assert: parser fail: '('.
 "
+
+    "Modified: / 07-09-2015 / 12:40:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileLiteral
-    parser := 'foo' asParser token compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser token).
     
     self assert: parser parse: 'foo'.
     self assert: result inputValue = 'foo'.
@@ -261,17 +267,19 @@
 !
 
 testCompileSequence
-    parser := ('foo' asParser token) , ('bar' asParser token) 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser token) , ('bar' asParser token).
+
     
     self assert: parser parse: 'foobar'.
     self assert: result first inputValue = 'foo'.
     self assert: result second inputValue = 'bar'.
+
+    "Modified: / 07-09-2015 / 12:40:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileSequence2
-    parser := ('foo' asParser trimmingToken) , ('bar' asParser trimmingToken) 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser trimmingToken) , ('bar' asParser trimmingToken).
+
     
     self assert: parser parse: 'foobar'.
     self assert: result first inputValue = 'foo'.
@@ -284,11 +292,13 @@
     self assert: parser parse: '  foo  bar'.
     self assert: result first inputValue = 'foo'.
     self assert: result second inputValue = 'bar'.
+
+    "Modified: / 07-09-2015 / 12:40:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileSequence3
-    parser := 	('foo' asParser trimmingToken) , ('bar' asParser trimmingToken) 
-                     , ('baz' asParser trimmingToken) compileUsingCompiler:compiler.
+    parser :=   compiler compile: ('foo' asParser trimmingToken) , ('bar' asParser trimmingToken) 
+                     , ('baz' asParser trimmingToken).
     
     self assert: parser parse: 'foobarbaz'.
     self assert: result first inputValue = 'foo'.
@@ -298,10 +308,12 @@
     self assert: result first inputValue = 'foo'.
     self assert: result second inputValue = 'bar'.
     self assert: result third inputValue = 'baz'.
+
+    "Modified: / 07-09-2015 / 12:39:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileStar
-    parser := 'foo' asParser token star compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser token star).
     
     self assert: parser parse: 'foo'.
     self assert: result first inputValue = 'foo'.
@@ -311,8 +323,8 @@
 !
 
 testCompileStar2
-    parser := ('foo' asParser token , 'bar' asParser token) star 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser token , 'bar' asParser token) star.
+
     
     self assert: parser parse: 'foobar'.
     self assert: context tokenReads size = 1.
@@ -320,12 +332,13 @@
     self assert: parser parse: 'bar' end: 0.
     self assert: result isEmpty.
     self assert: context tokenReads size = 1.
-        
+
+    "Modified: / 07-09-2015 / 12:39:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileStar3
-    parser := 'a' asParser trimmingToken star , 'b' asParser trimmingToken 
-                    compileUsingCompiler:compiler.
+    parser := compiler compile: ('a' asParser trimmingToken star , 'b' asParser trimmingToken).
+
     
     self assert: parser parse: 'ab'.
     self assert: parser parse: 'aaab'.
@@ -333,6 +346,8 @@
     self assert: result first size = 3.
             
     self assert: parser fail: 'ac'.
+
+    "Modified: / 07-09-2015 / 12:39:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 testCompileTokenComplex2
@@ -346,7 +361,7 @@
         name: 'optionsWith'; 
         yourself.
 
-    parser := optionsWith compileUsingCompiler:compiler.
+    parser := compiler compile: (optionsWith).
     self assert: parser parse: '|'.
 
     self assert: parser parse: ']' end: 0.
@@ -372,7 +387,7 @@
     
     tricky := (a1 asParser, choice1) / (b2 asParser, choice2).
 
-    parser := tricky compileUsingCompiler:compiler.
+    parser := compiler compile: (tricky).
     self assert: parser parse: '||'.
 
     self assert: parser parse: '|]'.
@@ -409,7 +424,7 @@
 
     arrayItem := arrayLiteral / symbolLiteral.
 
-    parser := arrayItem compileUsingCompiler:compiler.
+    parser := compiler compile: (arrayItem).
 
     self assert: parser parse: '#(foo)'.
     self assert: parser parse: '#foo'.
@@ -418,7 +433,7 @@
 !
 
 testCompileTrim
-    parser := 'foo' asParser token trim end compileUsingCompiler:compiler.
+    parser := compiler compile: ('foo' asParser token trim end).
     
     self assert: parser parse: 'foo'.
     self assert: result inputValue = 'foo'.
@@ -439,7 +454,7 @@
 testTokenCharacter
     | token |
     token := $a asParser token.
-    parser := token plus compileUsingCompiler:compiler.
+    parser := compiler compile: (token plus).
 
     self assert: parser parse: 'a'.
     self assert: result first inputValue = 'a'.
@@ -452,7 +467,7 @@
 testTokenCharacter2
     | token |
     token := $a asParser token.
-    parser := token plus compileUsingCompiler:compiler.
+    parser := compiler compile: (token plus).
 
     self assert: parser parse: 'aaa'.
     self assert: result first inputValue = 'a'.
@@ -467,7 +482,7 @@
 testTokenName
     | token |
     token := 'foo' asParser token name: 'fooToken'; yourself.
-    parser := token plus compileUsingCompiler:compiler.
+    parser := compiler compile: (token plus).
 
     self assert: parser parse: 'foofoo'.
     self assert: result first inputValue = 'foo'.
@@ -486,7 +501,7 @@
         propertyAt: 'trimmingToken' put: true; 
         yourself.
     
-    parser := trimmingToken plus compileUsingCompiler:compiler.
+    parser := compiler compile: (trimmingToken plus).
 
     self assert: parser parse: ' foo '.
     self assert: result first inputValue = 'foo'.
@@ -506,7 +521,7 @@
         propertyAt: 'trimmingToken' put: true; 
         yourself.
     
-    parser := trimmingToken plus compileUsingCompiler:compiler.
+    parser := compiler compile: (trimmingToken plus).
 
     self assert: parser parse: ' foo foo '.
     self assert: result first inputValue = 'foo'.
@@ -527,7 +542,7 @@
         propertyAt: 'trimmingToken' put: true; 
         yourself.
     
-    parser := trimmingToken plus compileUsingCompiler:compiler.
+    parser := compiler compile: (trimmingToken plus).
 
     self assert: parser parse: ' foo  foo  foo  '.
     self assert: result first inputValue = 'foo'.