compiler/tests/extras/PPCLRPParser.st
changeset 516 3b81c9e53352
parent 511 527038bc8edf
parent 515 b5316ef15274
child 529 439c4057517f
--- a/compiler/tests/extras/PPCLRPParser.st	Fri Jul 31 14:07:31 2015 +0100
+++ b/compiler/tests/extras/PPCLRPParser.st	Mon Aug 17 12:56:02 2015 +0100
@@ -3,10 +3,11 @@
 "{ NameSpace: Smalltalk }"
 
 PPCompositeParser subclass:#PPCLRPParser
-	instanceVariableNames:'program variable block bra ket identifier machine body event
-		transition epsilon wildcard state onentry running onexit comment
-		lineTerminator statebody spawn integer errorNode success failed
-		lastError styler timeoutIdentifier timeoutInteger endOfComment'
+	instanceVariableNames:'program variable smalltalkBlock bra ket identifier machine body
+		event transition epsilon wildcard state onentry running onexit
+		comment lineTerminator statebody spawn integer errorNode success
+		failed lastError styler timeoutIdentifier timeoutInteger
+		endOfComment'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'PetitCompiler-Extras-Tests-LRP'
@@ -106,7 +107,7 @@
 !
 
 event
-    ^ (bra, 'event' asParser trim, identifier, block,  ket)  
+    ^ (bra, 'event' asParser trim, identifier, smalltalkBlock,  ket)  
         ==> [:tokens | | ident |
                 ident := (tokens at: 3).
                 (PPCLRPEvent named: ident inputValue 
@@ -118,7 +119,7 @@
 !
 
 integer 
-    ^(#digit asParser) plus flatten trim token
+    ^(#digit asParser) plus  token trim
 !
 
 machine
@@ -128,7 +129,7 @@
                 bod := (tokens at: 4).
                 bod isEmpty
                     ifTrue: [ stop := tokens last stop - 1 ]
-                 	ifFalse: [ stop := (bod at: 1) start - 1 ].
+                 		ifFalse: [ stop := (bod at: 1) start - 1 ].
                 (PPCLRPMachine name: ident inputValue body: bod)
                     start: (tokens first start) stop: (tokens last stop);
                     nameRange: (ident start to: stop);
@@ -137,7 +138,7 @@
 !
 
 onentry
-    ^ (bra, 'onentry' asParser trim, (block/spawn) ,  ket ) 
+    ^ (bra, 'onentry' asParser trim, (smalltalkBlock/spawn) ,  ket ) 
         ==> [:tokens | 
                 (PPCLRPOnEntry block: (tokens at: 3))
                 start: (tokens first start) stop: (tokens last stop);
@@ -147,7 +148,7 @@
 !
 
 onexit
-    ^ (bra, 'onexit' asParser trim, (block/spawn),  ket)  
+    ^ (bra, 'onexit' asParser trim, (smalltalkBlock/spawn),  ket)  
         ==> [:tokens | 
                 (PPCLRPOnExit block: (tokens at: 3))
                 start: (tokens first start) stop: (tokens last stop);
@@ -161,7 +162,7 @@
 !
 
 running
-    ^ (bra, 'running' asParser trim, (block/spawn),  ket)  
+    ^ (bra, 'running' asParser trim, (smalltalkBlock/spawn),  ket)  
         ==> [:tokens | 
                 (PPCLRPRunning block: (tokens at: 3))
                 start: (tokens first start) stop: (tokens last stop);
@@ -174,8 +175,8 @@
     ^(bra , 'spawn' asParser trim , identifier , identifier , ket) 
         ==> [ :tokens |  
                 (PPCLRPSpawn
-                    machine: (tokens at: 3) parsedValue
-                    state: (tokens at: 4) parsedValue)
+                    machine: (tokens at: 3) inputValue
+                    state: (tokens at: 4) inputValue)
                 start: (tokens first start) stop: (tokens last stop);
                 nameRange: ((tokens at: 3) start to: (tokens at: 4) stop)
                 yourself.
@@ -202,7 +203,7 @@
 !
 
 variable
-    ^ (bra , 'var' asParser trim , identifier , ':=' asParser trim , block , ket) 
+    ^ (bra , 'var' asParser trim , identifier , ':=' asParser trim , smalltalkBlock , ket) 
         ==> [ :tokens | |ident|
             ident := (tokens at: 3).
             (PPCLRPVariable name: ident inputValue value: (tokens at: 5))
@@ -215,11 +216,11 @@
 !PPCLRPParser methodsFor:'grammar-comments'!
 
 comment
-    ^ ( $; asParser token , (endOfComment negate star) flatten,  endOfComment token) trim 
-    ==> [ :tokens |  |text|
-            text := tokens  at: 2.
-                (PPCLRPComment text: (text copyFrom: 1 to: text size -1))
-                start: (tokens first start) stop: (tokens last stop);
+    ^ ($; asParser, (endOfComment negate star),  endOfComment) token trim 
+    ==> [ :token |  |text|
+            text := token inputValue.
+                (PPCLRPComment text: (text copyFrom: 1 to: text size -1) trim)
+                start: (token start) stop: (token stop);
                 yourself.
         ]
 !
@@ -235,20 +236,20 @@
 
 !PPCLRPParser methodsFor:'grammar-common'!
 
-block
-    ^PPSmalltalkParser new block
-!
-
 bra
     ^ $( asParser token trim
 !
 
 identifier 
-    ^(#letter asParser , (#word asParser /  $_ asParser) star) flatten token trim
+    ^(#letter asParser , (#word asParser /  $_ asParser) star) token trim
 !
 
 ket
     ^ $) asParser token trim
+!
+
+smalltalkBlock
+    ^PPSmalltalkParser new productionAt: #block
 ! !
 
 !PPCLRPParser methodsFor:'grammar-transitions'!