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

added some methods to print bloc of metadata in differents formats #78

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
15 changes: 15 additions & 0 deletions src/Fame-ImportExport/FMDataStructurePrinter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ FMDataStructurePrinter >> crTabs [
tab: indent
]

{ #category : #printing }
FMDataStructurePrinter >> printEntityCloser [
^ self subclassResponsibility
]

{ #category : #printing }
FMDataStructurePrinter >> printEntityLineBreak [
^ self subclassResponsibility
]

{ #category : #printing }
FMDataStructurePrinter >> printEntityOpener [
^ self subclassResponsibility
]

{ #category : #accessing }
FMDataStructurePrinter >> stream [
^ stream
Expand Down
60 changes: 60 additions & 0 deletions src/Fame-ImportExport/FMFutureMetadata.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Class {
#name : #FMFutureMetadata,
#superclass : #FMFuture,
#instVars : [
'instance',
'currentProperty',
'importer'
],
#category : #'Fame-ImportExport-Importers'
}

{ #category : #accessing }
FMFutureMetadata >> addToPropertyValues: aValue [

instance setProperty: self currentProperty value: aValue
]

{ #category : #accessing }
FMFutureMetadata >> beginProperty: aString [

self assert: currentProperty isNil.
currentProperty := aString
]

{ #category : #accessing }
FMFutureMetadata >> currentProperty [

^ currentProperty
]

{ #category : #accessing }
FMFutureMetadata >> endProperty [

currentProperty := nil
]

{ #category : #accessing }
FMFutureMetadata >> importer [
^ importer
]

{ #category : #accessing }
FMFutureMetadata >> in: anImporter named: aString [

importer := anImporter.
instance := MooseModelMetadataHolder new "createInstance"
]

{ #category : #accessing }
FMFutureMetadata >> initialize [

super initialize.
instance := MooseModelMetadataHolder new
]

{ #category : #accessing }
FMFutureMetadata >> instance [

^ instance
]
18 changes: 16 additions & 2 deletions src/Fame-ImportExport/FMImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Class {
'ensureNoDandlingReferences',
'numberOfDanglingReferences',
'entities',
'parser'
'parser',
'instance'
],
#category : #'Fame-ImportExport-Importers'
}
Expand Down Expand Up @@ -96,6 +97,12 @@ FMImporter >> beginEntity: name [
stack push: (FMFutureEntity in: self named: translatedName)
]

{ #category : #'as yet unclassified' }
FMImporter >> beginMetadata [

stack push: FMFutureMetadata new.
]

{ #category : #parsing }
FMImporter >> beginProperty: name [
self currentEntity beginProperty: name
Expand Down Expand Up @@ -130,6 +137,12 @@ FMImporter >> endEntity: name [
stack ifNotEmpty: [ self currentEntity addToPropertyValues: entity ]
]

{ #category : #'as yet unclassified' }
FMImporter >> endMetadata [

stack pop
]

{ #category : #parsing }
FMImporter >> endProperty: name [
self currentEntity endProperty
Expand All @@ -145,8 +158,9 @@ FMImporter >> fromString: aString [
self stream: aString readStream
]

{ #category : #initialization }
{ #category : #accessing }
FMImporter >> initialize [

super initialize.
translationUnit := FMNullTranslationUnit new.
ensureNoDandlingReferences := true
Expand Down
15 changes: 14 additions & 1 deletion src/Fame-ImportExport/FMImporterFilter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@ FMImporterFilter >> beginDocument [

{ #category : #parsing }
FMImporterFilter >> beginEntity: name [

(filter includes: name)
ifTrue: [ shouldSkip := false.
ifTrue: [
shouldSkip := false.
importer beginEntity: name ]
ifFalse: [ shouldSkip := true ]
]

{ #category : #'as yet unclassified' }
FMImporterFilter >> beginMetadata [

importer beginMetadata
]

{ #category : #parsing }
FMImporterFilter >> beginProperty: name [
shouldSkip ifFalse: [ importer beginProperty: name ]
Expand All @@ -62,6 +70,11 @@ FMImporterFilter >> endEntity: name [
shouldSkip ifFalse: [ importer endEntity: name ]
]

{ #category : #'as yet unclassified' }
FMImporterFilter >> endMetadata [
importer endMetadata
]

{ #category : #parsing }
FMImporterFilter >> endProperty: name [
shouldSkip ifFalse: [ importer endProperty: name ]
Expand Down
43 changes: 40 additions & 3 deletions src/Fame-ImportExport/FMJSONParser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,24 @@ FMJSONParser >> Document [
"Document := EOF { openDocument; closeDocument }
| OPEN { openDocument } Entity* CLOSE { closeDocument }"

| pos hasMetadata |
self tWHITESPACE.
self atEnd
ifTrue: [ importer beginDocument ]
ifFalse: [" self tMultiOPEN
ifFalse: [ " self tMultiOPEN
ifFalse: [ ^ self syntaxError ]."
importer beginDocument.
pos := self position.
hasMetadata := self tOPEN.
hasMetadata ifTrue: [
self Metadata.
self tEntitiesaName.
self tPropertyNameSeparator ].
self MultiEntity.
"[ self Entity ] whileTrue.
hasMetadata ifTrue: [ "[ self Entity ] whileTrue.
self tMultiCLOSE
ifFalse: [ ^ self syntaxError ]" ].
ifFalse: [ ^ self syntaxError ]"
self tCLOSE ] ].
importer endDocument.
self tWHITESPACE.
^ true
Expand Down Expand Up @@ -71,6 +79,23 @@ FMJSONParser >> Entity [
^ true
]

{ #category : #'as yet unclassified' }
FMJSONParser >> Metadata [

| pos |
pos := self position.
self tMetadataName ifFalse: [ ^ self backtrack: pos ].
self tPropertyNameSeparator.
self tOPEN ifFalse: [ ^ self backtrack: pos ].
importer beginMetadata.
[
self Property
] whileTrue.
importer endMetadata.
self tCLOSE.
self tPropertySeparator
]

{ #category : #tokens }
FMJSONParser >> MultiEntity [

Expand Down Expand Up @@ -187,6 +212,12 @@ FMJSONParser >> tCLOSE [
^ self matchesWord: '}'
]

{ #category : #'as yet unclassified' }
FMJSONParser >> tEntitiesaName [

^ self matchesWord: '"entities"'
]

{ #category : #tokens }
FMJSONParser >> tFULLNAME [
self tFULLNAMEPropertyOpen ifFalse: [ ^ nil ].
Expand Down Expand Up @@ -223,6 +254,12 @@ FMJSONParser >> tID [
^ self matchesWord: '"id"'
]

{ #category : #'as yet unclassified' }
FMJSONParser >> tMetadataName [

^ self matchesWord: '"metadata"'
]

{ #category : #tokens }
FMJSONParser >> tMultiCLOSE [
^ self matchesWord: ']'
Expand Down
31 changes: 25 additions & 6 deletions src/Fame-ImportExport/FMJSONPrinter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ FMJSONPrinter >> beginDocument [

{ #category : #parsing }
FMJSONPrinter >> beginEntity: name [
indent := indent + 1.
stream nextPutAll: '{'.
self crTabs.

self printEntityOpener.
stream
nextPutAll: '"FM3":"';
nextPutAll: name;
Expand Down Expand Up @@ -45,9 +44,8 @@ FMJSONPrinter >> endDocument [

{ #category : #parsing }
FMJSONPrinter >> endEntity: name [
self crTabs.
stream nextPut: $}.
indent := indent - 1

self printEntityCloser.
]

{ #category : #parsing }
Expand Down Expand Up @@ -79,6 +77,27 @@ FMJSONPrinter >> primitive: value [
ifFalse: [ value msePrintOn: stream ]
]

{ #category : #parsing }
FMJSONPrinter >> printEntityCloser [
indent := indent - 1.
self crTabs.
stream nextPut: $}.

]

{ #category : #printing }
FMJSONPrinter >> printEntityLineBreak [
^ self crTabs
]

{ #category : #parsing }
FMJSONPrinter >> printEntityOpener [

indent := indent + 1.
stream nextPutAll: '{'.
self crTabs
]

{ #category : #parsing }
FMJSONPrinter >> printEntitySeparator [
stream nextPut: $,
Expand Down
Loading
Loading