compiler/PPCTokenizingConfiguration.st
changeset 531 dc3d13c2837d
parent 530 e36906742693
child 532 132d7898a2a1
--- a/compiler/PPCTokenizingConfiguration.st	Tue Aug 25 01:30:32 2015 +0100
+++ b/compiler/PPCTokenizingConfiguration.st	Wed Aug 26 21:41:20 2015 +0100
@@ -9,7 +9,6 @@
 	category:'PetitCompiler-Core'
 !
 
-
 !PPCTokenizingConfiguration methodsFor:'compiling'!
 
 buildClass: clazz
@@ -45,56 +44,96 @@
     self buildScannerScans.	
     self generateScanner.
     self generateParser.
-!
-
-options: args
-    super options: args.
 ! !
 
-!PPCTokenizingConfiguration methodsFor:'phases'!
+!PPCTokenizingConfiguration methodsFor:'error handling'!
 
 buildParserClazz
     | rootMethod |
-    rootMethod := PPCTokenizingCodeGenerator new
-        clazz: context parserClass;
-        options: options;
-        visit: ir.
-        
-    context parserClass propertyAt: #rootMethod put: rootMethod
 
-    "Modified: / 25-08-2015 / 00:07:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    rootMethod := (PPCTokenizingCodeGenerator new)
+            clazz:context parserClass;
+            options:context options;
+            visit:ir.
+    context parserClass propertyAt:#rootMethod put:rootMethod
+
+    "Modified: / 25-08-2015 / 00:07:38 / Jan Vrany <jan.vrany@fit."
+    "Modified: / 26-08-2015 / 19:57:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 buildScannerScans
     | fsas  generator |
-    
+
     "TODO JK: Perhpas write separate visitor for this?"
     fsas := IdentitySet new.
-    fsas addAll: (ir allNodes select: [ :node | node hasFsa ] thenCollect: [:node | node fsa]).
-    fsas addAll: (ir allNodes select: [ :node | node hasNextFsa ] thenCollect: [:node | node nextFsa]).
-    fsas := fsas reject: [ :fsa | fsa hasDistinctRetvals not ].
-    
-    generator := PPCScannerCodeGenerator new
-        clazz: context scannerClass;
-        options: options;
-        yourself.
-        
-    fsas do: [ :fsa | generator generate: fsa ].
+    fsas addAll:(ir allNodes 
+                select:[:node | node hasFsa ]
+                thenCollect:[:node | node fsa ]).
+    fsas addAll:(ir allNodes 
+                select:[:node | node hasNextFsa ]
+                thenCollect:[:node | node nextFsa ]).
+    fsas := fsas reject:[:fsa | fsa hasDistinctRetvals not ].
+    generator := (PPCScannerCodeGenerator new)
+            clazz:context scannerClass;
+            options:context options;
+            yourself.
+    fsas do:[:fsa | 
+        generator generate:fsa
+    ].
 
-    "Modified: / 25-08-2015 / 00:04:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 25-08-2015 / 00:04:43 / Jan Vrany <jan.vrany@fit."
+    "Modified: / 26-08-2015 / 19:57:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 buildScannerTokens
-    | generator  |
-    generator :=  PPCTokenCodeGenerator new
-        clazz: context scannerClass;
-        options: options;
-        yourself.
+    | generator |
+
+    generator := (PPCTokenCodeGenerator new)
+            clazz:context scannerClass;
+            options:context options;
+            yourself.
+    generator visit:ir.
+
+    "Modified: / 25-08-2015 / 00:04:46 / Jan Vrany <jan.vrany@fit."
+    "Modified: / 26-08-2015 / 19:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+generateParser
+    | parserClass  rootMethod |
 
-    generator visit: ir.
+    context options generate ifFalse:[
+        ^ self
+    ].
+    rootMethod := context parserClass propertyAt:#rootMethod.
+    context parserClass name:context options parserName.
+    context parserClass superclass:context options parserSuperclass.
+    parserClass := self buildClass:context parserClass.
+    parserClass startSymbol:rootMethod methodName.
+    self remember:parserClass as:#parser.
+    ir := parserClass new
+
+    "Modified: / 25-08-2015 / 00:05:49 / Jan Vrany"
+    "Modified: / 26-08-2015 / 19:57:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
 
-    "Modified: / 25-08-2015 / 00:04:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
+generateScanner
+    | scanner |
+
+    context options generate ifFalse:[
+        ^ self
+    ].
+    context scannerClass name:context options scannerName.
+    context scannerClass superclass:context options scannerSuperclass.
+    scanner := (self buildClass:context scannerClass).
+    context parserClass addConstant:scanner as:#scannerClass.
+    ir := scanner.
+    self remember:scanner as:#scanner
+
+    "Modified: / 25-08-2015 / 00:06:49 / Jan Vrany"
+    "Modified: / 26-08-2015 / 19:58:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!PPCTokenizingConfiguration methodsFor:'phases'!
 
 createFSAs
     ir := PPCFSAVisitor new
@@ -107,61 +146,24 @@
 !
 
 createLL1Choices
-    self flag: 'This phase needs revisit and update'.
-    
-    ir :=  PPCLL1Visitor new
-        options: options;
-        visit: ir.
-        
-    self remember: (self copyTree: ir) as: #LL1
-!
-
-generateParser
-    | parserClass rootMethod |
-    options generate ifFalse: [ ^ self ].
-    rootMethod := context parserClass propertyAt: #rootMethod.
-    
-    context parserClass name: options parserName.
-    context parserClass superclass: options parserSuperclass.
-    
-    parserClass := self buildClass: context parserClass.
-    parserClass startSymbol: rootMethod methodName.
-
-    self remember: parserClass as: #parser.
-    ir := parserClass new
-
-    "Modified: / 25-08-2015 / 00:05:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-generateScanner
-    | scanner |
-    options generate ifFalse: [ ^ self ].
-    
-    context scannerClass name: options scannerName.
-    context scannerClass superclass: options scannerSuperclass.
-    
-    scanner := (self buildClass: context scannerClass).
-    context parserClass addConstant: scanner as: #scannerClass.
-    
-    ir := scanner.
-    
-    self remember: scanner as: #scanner
-
-    "Modified: / 25-08-2015 / 00:06:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    self flag:'This phase needs revisit and update'.
+    ir := (PPCLL1Visitor new)
+            options:context options;
+            visit:ir.
+    self remember:(self copyTree:ir) as:#LL1
 !
 
 tokenize
     "
-        This will try transform the parser into the tokenizing parser
-    "
-    options tokenize ifFalse: [ ^ self ] .
+        This will try transform the parser into the tokenizing parser"
     
-    ir :=  PPCTokenizingVisitor new
-        options: options;
-        visit: ir.
-        
-        
-    self remember: (self copyTree: ir) as: #tokenize
+    context options tokenize ifFalse:[
+        ^ self
+    ].
+    ir := (PPCTokenizingVisitor new)
+            options:context options;
+            visit:ir.
+    self remember:(self copyTree:ir) as:#tokenize
 !
 
 unmarkConsumeTokensForInline
@@ -173,10 +175,3 @@
     ]
 ! !
 
-!PPCTokenizingConfiguration class methodsFor:'documentation'!
-
-version_HG
-
-    ^ '$Changeset: <not expanded> $'
-! !
-