--- a/compiler/tests/PPCTokenizingCodeGeneratorTest.st Mon Aug 17 12:13:16 2015 +0100
+++ b/compiler/tests/PPCTokenizingCodeGeneratorTest.st Mon Aug 24 15:34:14 2015 +0100
@@ -4,7 +4,7 @@
PPAbstractParserTest subclass:#PPCTokenizingCodeGeneratorTest
instanceVariableNames:'visitor node result compiler parser context arguments tokenizer
- whitespace'
+ whitespace configuration'
classVariableNames:''
poolDictionaries:''
category:'PetitCompiler-Tests-Visitors'
@@ -25,30 +25,11 @@
].
!
-compileTokenizer: aNode
- tokenizer := visitor visit: aNode
-!
-
compileTree: root
-
- | configuration |
-
- configuration := PPCPluggableConfiguration on: [ :_self |
- _self cacheFirstFollow.
- _self generateScanner.
- _self generate.
-
- ].
- configuration arguments: arguments.
- configuration base: PPCConfiguration tokenizing.
parser := configuration compile: root.
!
-compileWs: aNode
- whitespace := visitor visit: aNode
-!
-
context
^ context := PPCProfilingContext new
!
@@ -60,12 +41,18 @@
self cleanClass.
- compiler := PPCTokenizingCodeGen new.
- compiler arguments: arguments.
-
- visitor := PPCTokenizingCodeGenerator new.
- visitor compiler: compiler.
- visitor arguments: arguments.
+ configuration := PPCPluggableConfiguration on: [ :_self |
+ _self cacheFirstFollow.
+ _self buildParserClazz.
+ _self unmarkConsumeTokensForInline.
+ _self createFSAs.
+ _self buildScannerTokens.
+ _self buildScannerScans.
+ _self generateScanner.
+ _self generateParser.
+ ] base: PPCConfiguration tokenizing.
+
+ configuration arguments: arguments.
!
tearDown
@@ -78,38 +65,12 @@
result := super assert: whatever parse: input.
!
-assert: whatever recognizesToken: input
- whatever startSymbol: #nextToken.
-
- self assert: whatever parse: input.
- self assert: (result isKindOf: PPToken).
-
- whatever startSymbol: #start
-!
-
-assert: whatever rejectsToken: input
- whatever startSymbol: #nextToken.
-
- self assert: whatever fail: input.
-
- whatever startSymbol: #start
-!
-
literalNode: literal
^ PPCLiteralNode new
literal: literal;
yourself
!
-tokenNode: child
- child markForInline.
-
- ^ PPCTokenNode new
- child: child;
- tokenClass: PPToken;
- yourself
-!
-
tokenNodeForEOF
| eof |
eof := PPCEndOfFileNode new
@@ -171,9 +132,8 @@
name: 'nextToken';
yourself.
- wsNode := PPCTokenStarSeparatorNode new
+ wsNode := PPCNilNode new
name: 'consumeWhitespace';
- child: PPCNilNode new;
yourself.
node := PPCTokenizingParserNode new
@@ -208,9 +168,8 @@
consumeNode := PPCTokenConsumeNode new
child: tokenNode;
yourself.
- wsNode := PPCTokenStarSeparatorNode new
+ wsNode := PPCNilNode new
name: 'consumeWhitespace';
- child: PPCSentinelNode instance;
yourself.
node := PPCTokenizingParserNode new
@@ -231,7 +190,7 @@
!
testTrimmingToken1
- | token tokenConsume tokensNode eof wsNode |
+ | token tokenConsume tokensNode eof wsNode separatorNode |
token := self trimmingTokenNode: (self literalNode: 'foo').
eof := (self tokenNodeForEOF) yourself.
@@ -245,9 +204,14 @@
name: 'nextToken';
yourself.
- wsNode := PPCTokenStarSeparatorNode new
+ separatorNode := PPCLiteralNode new
+ literal: ' ';
+ name: 'separator';
+ yourself.
+
+ wsNode := PPCStarNode new
name: 'consumeWhitespace';
- child: PPCNilNode new;
+ child: separatorNode;
yourself.
node := PPCTokenizingParserNode new