Skip to content

Commit

Permalink
Merge pull request #316 from tomooda/editable-table
Browse files Browse the repository at this point in the history
make attribute/utility definition tables editable
  • Loading branch information
tomooda committed Mar 27, 2024
2 parents 2328128 + 491155b commit 9676324
Show file tree
Hide file tree
Showing 36 changed files with 1,895 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,42 @@ RMDAbstractAssignableAttributeVariableNode class >> attributeVariable: aRMDAttri
yourself
]

{ #category : #accessing }
RMDAbstractAssignableAttributeVariableNode class >> classForOperator: aString [

aString = self deltaOperator ifTrue: [
^ RMDAssignableDeltaAttributeVariableNode ].
aString = self differentialOperator ifTrue: [
^ RMDAssignableDifferentialAttributeVariableNode ].
^ RMDAssignableAttributeVariableNode
]

{ #category : #accessing }
RMDAbstractAssignableAttributeVariableNode class >> deltaOperator [

^ 'Δ'
]

{ #category : #accessing }
RMDAbstractAssignableAttributeVariableNode class >> differentialOperator [

^ 'd/dt '
]

{ #category : #'instance creation' }
RMDAbstractAssignableAttributeVariableNode class >> identifier: aString agent: anotherString [
^ self new
attributeVariable: (RMDAttributeVariableNode identifier: aString agent: anotherString);
yourself
]

{ #category : #'instance creation' }
RMDAbstractAssignableAttributeVariableNode class >> operator: aString attributeVariable: aRMDAttributeVariableNode [

^ (self classForOperator: aString) attributeVariable:
aRMDAttributeVariableNode
]

{ #category : #comparing }
RMDAbstractAssignableAttributeVariableNode >> = anObject [
^ self class = anObject class
Expand All @@ -33,6 +62,13 @@ RMDAbstractAssignableAttributeVariableNode >> agent [
^ attributeVariable agent
]

{ #category : #accessing }
RMDAbstractAssignableAttributeVariableNode >> agent: aString [

self attributeVariable:
(RMDAttributeVariableNode identifier: self identifier agent: aString)
]

{ #category : #accessing }
RMDAbstractAssignableAttributeVariableNode >> attributeVariable [
^ attributeVariable
Expand Down Expand Up @@ -73,6 +109,12 @@ RMDAbstractAssignableAttributeVariableNode >> operator [
^ self subclassResponsibility
]

{ #category : #converting }
RMDAbstractAssignableAttributeVariableNode >> operator: aString [

^ self class operator: aString attributeVariable: attributeVariable
]

{ #category : #copying }
RMDAbstractAssignableAttributeVariableNode >> postCopy [

Expand Down
7 changes: 7 additions & 0 deletions src/ReMobidyc-Language/RMDAgentDefinitionNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ RMDAgentDefinitionNode >> isAgentDefinitionNode [
^ true
]

{ #category : #testing }
RMDAgentDefinitionNode >> isCorrectSyntax [

^ (RMDGrammar current agentDefinition end parse: self printString)
= self
]

{ #category : #accessing }
RMDAgentDefinitionNode >> name [

Expand Down
7 changes: 7 additions & 0 deletions src/ReMobidyc-Language/RMDAnimatInitializerNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ RMDAnimatInitializerNode >> isAnimatInitializerNode [
^ true
]

{ #category : #testing }
RMDAnimatInitializerNode >> isCorrectSyntax [

^ (RMDGrammar current animatInitializer end parse: self printString)
= self
]

{ #category : #accessing }
RMDAnimatInitializerNode >> population [
^ population
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Class {
#category : #'ReMobidyc-Language-AST'
}

{ #category : #accessing }
RMDAssignableAttributeVariableNode >> identifier: aString [

self attributeVariable identifier: aString
]

{ #category : #testing }
RMDAssignableAttributeVariableNode >> isAssignableAttributeVariableNode [
^ true
Expand Down
34 changes: 34 additions & 0 deletions src/ReMobidyc-Language/RMDAttributeDeclarationNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ RMDAttributeDeclarationNode class >> identifier: aString unit: aRMDUnit initiali
yourself
]

{ #category : #'typical instances' }
RMDAttributeDeclarationNode class >> template [

^ self identifier: '' unit: RMDUnit noDimension
]

{ #category : #comparing }
RMDAttributeDeclarationNode >> = anObject [

Expand Down Expand Up @@ -93,6 +99,34 @@ RMDAttributeDeclarationNode >> isAttributeDeclarationNode [
^ true
]

{ #category : #testing }
RMDAttributeDeclarationNode >> isCorrectSyntax [

^ (RMDGrammar current attributeDeclaration end parse:
self printString) = self
]

{ #category : #testing }
RMDAttributeDeclarationNode >> isCorrectTypeWithSubject: aString in: aRMDSimulationModel [

| agentDefinition |
agentDefinition := aRMDSimulationModel
agentDefinitionAt: aString
ifAbsent: [ ^ false ].
[
aRMDSimulationModel typechecker
typecheck: self
subject: aString
object: nil
utilities: agentDefinition utilityDefinitions ]
on: RMDError
do: [ :ex | ^ false ].
^ (agentDefinition attributeDeclarations contains: [
:attributeDeclaration |
attributeDeclaration ~~ self and: [
attributeDeclaration identifier = self identifier ] ]) not
]

{ #category : #accessing }
RMDAttributeDeclarationNode >> nameWithUnit [

Expand Down
30 changes: 30 additions & 0 deletions src/ReMobidyc-Language/RMDAttributeDefinitionNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,29 @@ RMDAttributeDefinitionNode >> asPresenter [
^ RMDAttributeDefinitionBrowser on: self
]

{ #category : #accessing }
RMDAttributeDefinitionNode >> identifier [

^ self variable identifier
]

{ #category : #accessing }
RMDAttributeDefinitionNode >> identifier: aString [
self variable identifier: aString
]

{ #category : #testing }
RMDAttributeDefinitionNode >> isAttributeDefinitionNode [
^ true
]

{ #category : #testing }
RMDAttributeDefinitionNode >> isCorrectSyntax [

^ (RMDGrammar current attributeDefinition end parse: self printString)
= self
]

{ #category : #accessing }
RMDAttributeDefinitionNode >> operator [
^ '='
Expand Down Expand Up @@ -68,3 +86,15 @@ RMDAttributeDefinitionNode >> printShortOn: aStream [
super printShortOn: aStream.
aStream nextPut: $'
]
{ #category : #accessing }
RMDAttributeDefinitionNode >> variableOperator [
^ variable operator
]
{ #category : #accessing }
RMDAttributeDefinitionNode >> variableOperator: aString [
variable := variable operator: aString
]
7 changes: 7 additions & 0 deletions src/ReMobidyc-Language/RMDAttributeInitializerNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ RMDAttributeInitializerNode >> isAttributeInitializerNode [
^ true
]

{ #category : #testing }
RMDAttributeInitializerNode >> isCorrectSyntax [

^ (RMDGrammar current attributeInitializer end parse:
self printString) = self
]

{ #category : #copying }
RMDAttributeInitializerNode >> postCopy [

Expand Down
6 changes: 6 additions & 0 deletions src/ReMobidyc-Language/RMDConditionNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ RMDConditionNode >> isConditionNode [
^ true
]

{ #category : #testing }
RMDConditionNode >> isCorrectSyntax [

^ (RMDGrammar current condition end parse: self printString) = self
]

{ #category : #accessing }
RMDConditionNode >> precedence [
^ self subclassResponsibility
Expand Down
6 changes: 6 additions & 0 deletions src/ReMobidyc-Language/RMDExpressionNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ RMDExpressionNode >> insertTrace [
^ RMDTraceNode on: super insertTrace
]

{ #category : #testing }
RMDExpressionNode >> isCorrectSyntax [

^ (RMDGrammar current expression end parse: self printString) = self
]

{ #category : #testing }
RMDExpressionNode >> isExpressionNode [
^ true
Expand Down
7 changes: 5 additions & 2 deletions src/ReMobidyc-Language/RMDGrammar.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ RMDGrammar >> _identifier [
{ #category : #'parsers-atoms' }
RMDGrammar >> _literal [

^ self numberString , self type optional ==> [ :pair |
^ self decimalString / self pi , self type optional ==> [ :pair |
self literalNodeClass
literal: pair first
unit: (pair second ifNil: [ RMDUnit noDimension ]) ]
Expand Down Expand Up @@ -1341,7 +1341,10 @@ RMDGrammar >> numberOfIndividualsInWorldDirectiveNodeClass [
{ #category : #'parsers-atoms' }
RMDGrammar >> numberString [

^ self decimalString / self pi
^ self decimalString , self type optional ==> [ :pair |
self literalNodeClass
literal: pair first
unit: (pair second ifNil: [ RMDUnit noDimension ]) ]
]

{ #category : #'parsers-definitions' }
Expand Down
6 changes: 6 additions & 0 deletions src/ReMobidyc-Language/RMDLifeDirectiveNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ RMDLifeDirectiveNode >> childrenTransform: aBlock [

]

{ #category : #testing }
RMDLifeDirectiveNode >> hasNewAgents [

^ false
]

{ #category : #comparing }
RMDLifeDirectiveNode >> hash [
^ self class hash
Expand Down
6 changes: 6 additions & 0 deletions src/ReMobidyc-Language/RMDNewDirectiveNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ RMDNewDirectiveNode >> childrenTransform: aBlock [
quantity ifNotNil: [ quantity := aBlock value: quantity ]
]

{ #category : #testing }
RMDNewDirectiveNode >> hasNewAgents [

^ true
]

{ #category : #comparing }
RMDNewDirectiveNode >> hash [

Expand Down
7 changes: 7 additions & 0 deletions src/ReMobidyc-Language/RMDPatchInitializerNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ RMDPatchInitializerNode >> hash [
bitXor: size hash) bitXor: length hash
]

{ #category : #testing }
RMDPatchInitializerNode >> isCorrectSyntax [

^ (RMDGrammar current patchInitializer end parse: self printString)
= self
]

{ #category : #testing }
RMDPatchInitializerNode >> isPatchInitializerNode [
^ true
Expand Down
6 changes: 6 additions & 0 deletions src/ReMobidyc-Language/RMDStageDirectiveNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ RMDStageDirectiveNode >> animatIdentifier: aString [
ifFalse: [ aString ]
]

{ #category : #testing }
RMDStageDirectiveNode >> hasNewAgents [

^ true
]

{ #category : #comparing }
RMDStageDirectiveNode >> hash [

Expand Down

0 comments on commit 9676324

Please sign in to comment.