Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache number parser to not create too many instances #75

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Fame-ImportExport/FMMSEParser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Class {
'characterSet',
'chararacter',
'buffer',
'importer'
'importer',
'numberParser'
],
#category : #'Fame-ImportExport-Importers'
}
Expand Down Expand Up @@ -89,7 +90,7 @@ FMMSEParser >> Identifier [
buffer nextPut: chararacter.
[ self characterSet isDigit: self next ] whileTrue: [ buffer nextPut: chararacter ].
self tWHITESPACE.
^ Integer readFrom: buffer contents readStream
^ (numberParser on: buffer contents readStream) nextInteger
]

{ #category : #expressions }
Expand Down Expand Up @@ -137,7 +138,7 @@ FMMSEParser >> Number [
self characterSet isDigit: self next ] whileTrue
")?)?" ] ].
self tWHITESPACE.
^ Number readFrom: buffer contents readStream
^ (numberParser on: buffer contents readStream) nextNumber
]

{ #category : #expressions }
Expand Down Expand Up @@ -292,6 +293,13 @@ FMMSEParser >> incrementProgressBar [
lastUpdate := Time millisecondClockValue
]

{ #category : #initialization }
FMMSEParser >> initialize [

super initialize.
numberParser := NumberParser new
]

{ #category : #tokens }
FMMSEParser >> matchesWord: aString [
"I am checking if the next part of the stream watches a word. If it matches, I also eat the next whitespace and return true. Else I return false (I do not backtrack)"
Expand Down
Loading