Skip to content

Commit 0efeb77

Browse files
committed
Use new abstract importer + improve names
1 parent 1a8492e commit 0efeb77

2 files changed

Lines changed: 123 additions & 156 deletions

File tree

src/FAST-Python-Tools/FASTPythonImporter.class.st

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
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+
"
16
Class {
27
#name : 'FASTPythonImporter',
3-
#superclass : 'Object',
4-
#instVars : [
5-
'tsParser',
6-
'errorReportBlock'
7-
],
8+
#superclass : 'TSFASTAbstractImporter',
89
#category : 'FAST-Python-Tools',
910
#package : 'FAST-Python-Tools'
1011
}
@@ -103,48 +104,14 @@ FASTPythonImporter class >> parseFile: aFileReference [
103104
^ self parse: aFileReference asFileReference contents
104105
]
105106

106-
{ #category : 'parsing' }
107-
FASTPythonImporter >> deleteTreeSitterParser [
108-
109-
self tsParser delete
110-
]
111-
112107
{ #category : 'accessing' }
113-
FASTPythonImporter >> errorReportBlock: aBlock [
108+
FASTPythonImporter >> tsLanguage [
114109

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
140111
]
141112

142113
{ #category : 'accessing' }
143-
FASTPythonImporter >> tsParser [
144-
^ tsParser
145-
]
114+
FASTPythonImporter >> visitorClass [
146115

147-
{ #category : 'accessing' }
148-
FASTPythonImporter >> tsParser: anObject [
149-
tsParser := anObject
116+
^ FASTPythonVisitor
150117
]

0 commit comments

Comments
 (0)