|
| 1 | +" |
| 2 | +I am a FAST Python importer. |
| 3 | +
|
| 4 | +I mostly declare the TS language to use and redirect the visit to `FASTPythonVisitor`. |
| 5 | +" |
1 | 6 | Class { |
2 | 7 | #name : 'FASTPythonImporter', |
3 | | - #superclass : 'Object', |
4 | | - #instVars : [ |
5 | | - 'tsParser', |
6 | | - 'errorReportBlock' |
7 | | - ], |
| 8 | + #superclass : 'TSFASTAbstractImporter', |
8 | 9 | #category : 'FAST-Python-Tools', |
9 | 10 | #package : 'FAST-Python-Tools' |
10 | 11 | } |
@@ -103,48 +104,14 @@ FASTPythonImporter class >> parseFile: aFileReference [ |
103 | 104 | ^ self parse: aFileReference asFileReference contents |
104 | 105 | ] |
105 | 106 |
|
106 | | -{ #category : 'parsing' } |
107 | | -FASTPythonImporter >> deleteTreeSitterParser [ |
108 | | - |
109 | | - self tsParser delete |
110 | | -] |
111 | | - |
112 | 107 | { #category : 'accessing' } |
113 | | -FASTPythonImporter >> errorReportBlock: aBlock [ |
| 108 | +FASTPythonImporter >> tsLanguage [ |
114 | 109 |
|
115 | | - errorReportBlock := aBlock |
116 | | -] |
117 | | - |
118 | | -{ #category : 'as yet unclassified' } |
119 | | -FASTPythonImporter >> initialiseTreeSitterParser [ |
120 | | - |
121 | | - self tsParser: TSParser new. |
122 | | - self tsParser language: TSLanguage python |
123 | | -] |
124 | | - |
125 | | -{ #category : 'parsing' } |
126 | | -FASTPythonImporter >> parse: aString [ |
127 | | - |
128 | | - | tsTree fastTree | |
129 | | - self initialiseTreeSitterParser. |
130 | | - |
131 | | - tsTree := self tsParser parseString: aString. |
132 | | - fastTree := TSFASTPythonVisitor new |
133 | | - originString: aString; |
134 | | - in: [ :importer | errorReportBlock ifNotNil: [ importer errorReportBlock: errorReportBlock ] ]; |
135 | | - import: tsTree rootNode. |
136 | | - |
137 | | - self deleteTreeSitterParser. |
138 | | - |
139 | | - ^ fastTree |
| 110 | + ^ TSLanguage python |
140 | 111 | ] |
141 | 112 |
|
142 | 113 | { #category : 'accessing' } |
143 | | -FASTPythonImporter >> tsParser [ |
144 | | - ^ tsParser |
145 | | -] |
| 114 | +FASTPythonImporter >> visitorClass [ |
146 | 115 |
|
147 | | -{ #category : 'accessing' } |
148 | | -FASTPythonImporter >> tsParser: anObject [ |
149 | | - tsParser := anObject |
| 116 | + ^ FASTPythonVisitor |
150 | 117 | ] |
0 commit comments