diff -r 548996aca274 -r fb212e14d1f4 compiler/tests/PPCTokenizingTest.st --- a/compiler/tests/PPCTokenizingTest.st Mon Sep 07 08:03:02 2015 +0100 +++ b/compiler/tests/PPCTokenizingTest.st Mon Sep 07 08:20:46 2015 +0100 @@ -3,8 +3,8 @@ "{ NameSpace: Smalltalk }" PPAbstractParserTest subclass:#PPCTokenizingTest - instanceVariableNames:'parser result context node compiler id node2 id2 id1 node1 node3 - options configuration' + instanceVariableNames:'parser result context node id node2 id2 id1 node1 node3 options + compiler' classVariableNames:'' poolDictionaries:'' category:'PetitCompiler-Tests-Core-Tokenizing' @@ -44,14 +44,12 @@ ! setUp - options := PPCCompilationOptions default - profile: true; - tokenize: true; - yourself. - - configuration := PPCConfiguration new. - configuration context options: options. - + options := (PPCCompilationOptions default) + profile:true; + tokenize:true; + yourself. + compiler := PPCCompiler new. + compiler context options:options. self cleanClass. "Modified: / 04-09-2015 / 16:21:36 / Jan Vrany " @@ -69,7 +67,7 @@ p1 := a1 star. p2 := a2. - parser := p1 / p2 compileWithConfiguration: configuration. + parser := p1 / p2 compileUsingCompiler:compiler. self assert: parser parse: ''. self assert: result isEmpty. @@ -89,10 +87,8 @@ ! testChoiceOrder - parser := ( - 'a' asParser token, 'b' asParser token / - 'a' asParser token) - compileWithConfiguration: configuration. + parser := (('a' asParser token , 'b' asParser token) / 'a' asParser token) + compileUsingCompiler:compiler. self assert: parser parse: 'ab'. self assert: result first inputValue = 'a'. @@ -110,7 +106,7 @@ p1 := 'a' asParser token, 'b' asParser token. p2 := 'b' asParser token / 'a' asParser token. - parser := p1 / p2 compileWithConfiguration: configuration. + parser := p1 / p2 compileUsingCompiler:compiler. self assert: parser parse: 'ab'. self assert: result first inputValue = 'a'. @@ -134,7 +130,7 @@ p1 := a1, 'b' asParser token. p2 := a2. - parser := p1 / p2 compileWithConfiguration: configuration. + parser := p1 / p2 compileUsingCompiler:compiler. self assert: parser parse: 'ab'. self assert: result first inputValue = 'a'. @@ -155,7 +151,7 @@ p1 := a1, 'b' asParser token. p2 := 'b' asParser token / a2. - parser := p1 / p2 compileWithConfiguration: configuration. + parser := p1 / p2 compileUsingCompiler:compiler. self assert: parser parse: 'ab'. self assert: result first inputValue = 'a'. @@ -172,15 +168,16 @@ ! testCompileAnd - parser := (('foo' asParser token and) / ('bar' asParser token and)), 'bar' asParser token - compileWithConfiguration: configuration. + parser := (('foo' asParser token and) / ('bar' asParser token and)) + , 'bar' asParser token compileUsingCompiler:compiler. self assert: parser parse: 'bar'. self assert: result second inputValue = 'bar'. ! testCompileChoice - parser := ('foo' asParser / 'bar' asParser) token compileWithConfiguration: configuration. + parser := ('foo' asParser / 'bar' asParser) token + compileUsingCompiler:compiler. self assert: parser parse: 'foo'. self assert: result inputValue = 'foo'. @@ -191,7 +188,8 @@ ! testCompileChoice2 - parser := ('foo' asParser token trim / 'bar' asParser token trim) compileWithConfiguration: configuration. + parser := ('foo' asParser token trim / 'bar' asParser token trim) + compileUsingCompiler:compiler. self assert: parser parse: 'foo'. self assert: result inputValue = 'foo'. @@ -202,8 +200,9 @@ ! testCompileComplex1 - parser := ('foo' asParser token, 'bar' asParser token) / - ('foo' asParser token, 'baz' asParser token) compileWithConfiguration: configuration. + parser := ('foo' asParser token , 'bar' asParser token) + / ('foo' asParser token , 'baz' asParser token) + compileUsingCompiler:compiler. self assert: parser parse: 'foobar'. self assert: result second inputValue = 'bar'. @@ -216,8 +215,8 @@ ! testCompileComplex2 - parser := ('foo' asParser token, 'bar' asParser token) star, 'foo' asParser token - compileWithConfiguration: configuration. + parser := ('foo' asParser token , 'bar' asParser token) star , 'foo' asParser token + compileUsingCompiler:compiler. self assert: parser parse: 'foobarfoobarfoo'. self assert: parser parse: 'foo'. @@ -227,9 +226,9 @@ ! testCompileComplex3 - parser := ('foo' asParser token, 'bar' asParser token) star, 'foo' asParser token / - ('foo' asParser token, 'baz' asParser token) - compileWithConfiguration: configuration. + parser := (('foo' asParser token , 'bar' asParser token) star , 'foo' asParser token) + / ('foo' asParser token , 'baz' asParser token) + compileUsingCompiler:compiler. self assert: parser parse: 'foobarfoobarfoo'. self assert: parser parse: 'foo'. @@ -245,7 +244,7 @@ epsilon := '' asParser token. self should: [ - (start, epsilon, stop) compileWithConfiguration: configuration. + (start , epsilon , stop) compileUsingCompiler:compiler. ] raise: Exception. " self assert: parser parse: '()'. @@ -254,7 +253,7 @@ ! testCompileLiteral - parser := 'foo' asParser token compileWithConfiguration: configuration. + parser := 'foo' asParser token compileUsingCompiler:compiler. self assert: parser parse: 'foo'. self assert: result inputValue = 'foo'. @@ -262,8 +261,8 @@ ! testCompileSequence - parser := ('foo' asParser token), ('bar' asParser token) - compileWithConfiguration: configuration. + parser := ('foo' asParser token) , ('bar' asParser token) + compileUsingCompiler:compiler. self assert: parser parse: 'foobar'. self assert: result first inputValue = 'foo'. @@ -271,8 +270,8 @@ ! testCompileSequence2 - parser := ('foo' asParser trimmingToken), ('bar' asParser trimmingToken) - compileWithConfiguration: configuration. + parser := ('foo' asParser trimmingToken) , ('bar' asParser trimmingToken) + compileUsingCompiler:compiler. self assert: parser parse: 'foobar'. self assert: result first inputValue = 'foo'. @@ -288,10 +287,8 @@ ! testCompileSequence3 - parser := ('foo' asParser trimmingToken), - ('bar' asParser trimmingToken), - ('baz' asParser trimmingToken) - compileWithConfiguration: configuration. + parser := ('foo' asParser trimmingToken) , ('bar' asParser trimmingToken) + , ('baz' asParser trimmingToken) compileUsingCompiler:compiler. self assert: parser parse: 'foobarbaz'. self assert: result first inputValue = 'foo'. @@ -304,7 +301,7 @@ ! testCompileStar - parser := 'foo' asParser token star compileWithConfiguration: configuration. + parser := 'foo' asParser token star compileUsingCompiler:compiler. self assert: parser parse: 'foo'. self assert: result first inputValue = 'foo'. @@ -314,7 +311,8 @@ ! testCompileStar2 - parser := ('foo' asParser token, 'bar' asParser token) star compileWithConfiguration: configuration. + parser := ('foo' asParser token , 'bar' asParser token) star + compileUsingCompiler:compiler. self assert: parser parse: 'foobar'. self assert: context tokenReads size = 1. @@ -326,8 +324,8 @@ ! testCompileStar3 - parser := 'a' asParser trimmingToken star, 'b' asParser trimmingToken - compileWithConfiguration: configuration. + parser := 'a' asParser trimmingToken star , 'b' asParser trimmingToken + compileUsingCompiler:compiler. self assert: parser parse: 'ab'. self assert: parser parse: 'aaab'. @@ -348,7 +346,7 @@ name: 'optionsWith'; yourself. - parser := optionsWith compileWithConfiguration: configuration. + parser := optionsWith compileUsingCompiler:compiler. self assert: parser parse: '|'. self assert: parser parse: ']' end: 0. @@ -374,7 +372,7 @@ tricky := (a1 asParser, choice1) / (b2 asParser, choice2). - parser := tricky compileWithConfiguration: configuration. + parser := tricky compileUsingCompiler:compiler. self assert: parser parse: '||'. self assert: parser parse: '|]'. @@ -411,7 +409,7 @@ arrayItem := arrayLiteral / symbolLiteral. - parser := arrayItem compileWithConfiguration: configuration. + parser := arrayItem compileUsingCompiler:compiler. self assert: parser parse: '#(foo)'. self assert: parser parse: '#foo'. @@ -420,7 +418,7 @@ ! testCompileTrim - parser := 'foo' asParser token trim end compileWithConfiguration: configuration. + parser := 'foo' asParser token trim end compileUsingCompiler:compiler. self assert: parser parse: 'foo'. self assert: result inputValue = 'foo'. @@ -441,8 +439,7 @@ testTokenCharacter | token | token := $a asParser token. - parser := token plus - compileWithConfiguration: configuration. + parser := token plus compileUsingCompiler:compiler. self assert: parser parse: 'a'. self assert: result first inputValue = 'a'. @@ -455,8 +452,7 @@ testTokenCharacter2 | token | token := $a asParser token. - parser := token plus - compileWithConfiguration: configuration. + parser := token plus compileUsingCompiler:compiler. self assert: parser parse: 'aaa'. self assert: result first inputValue = 'a'. @@ -471,8 +467,7 @@ testTokenName | token | token := 'foo' asParser token name: 'fooToken'; yourself. - parser := token plus - compileWithConfiguration: configuration. + parser := token plus compileUsingCompiler:compiler. self assert: parser parse: 'foofoo'. self assert: result first inputValue = 'foo'. @@ -484,15 +479,14 @@ testWhitespace | token ws trimmingToken | - configuration removePass: PPCInliningVisitor. + compiler removePass: PPCInliningVisitor. token := 'foo' asParser token. ws := #blank asParser star name: 'consumeWhitespace'; yourself. trimmingToken := ((ws, token, ws) ==> #second) propertyAt: 'trimmingToken' put: true; yourself. - parser := trimmingToken plus - compileWithConfiguration: configuration. + parser := trimmingToken plus compileUsingCompiler:compiler. self assert: parser parse: ' foo '. self assert: result first inputValue = 'foo'. @@ -505,15 +499,14 @@ testWhitespace2 | token ws trimmingToken | - configuration removePass: PPCInliningVisitor. + compiler removePass: PPCInliningVisitor. token := 'foo' asParser token. ws := #blank asParser star name: 'consumeWhitespace'; yourself. trimmingToken := ((ws, token, ws) ==> #second) propertyAt: 'trimmingToken' put: true; yourself. - parser := trimmingToken plus - compileWithConfiguration: configuration. + parser := trimmingToken plus compileUsingCompiler:compiler. self assert: parser parse: ' foo foo '. self assert: result first inputValue = 'foo'. @@ -527,15 +520,14 @@ testWhitespace3 | token ws trimmingToken | - configuration removePass: PPCInliningVisitor. + compiler removePass: PPCInliningVisitor. token := 'foo' asParser token. ws := #blank asParser star name: 'consumeWhitespace'; yourself. trimmingToken := ((ws, token, ws) ==> #second) propertyAt: 'trimmingToken' put: true; yourself. - parser := trimmingToken plus - compileWithConfiguration: configuration. + parser := trimmingToken plus compileUsingCompiler:compiler. self assert: parser parse: ' foo foo foo '. self assert: result first inputValue = 'foo'.