--- a/GDBParser.st Thu Jun 19 10:10:52 2014 +0100
+++ b/GDBParser.st Thu Jun 19 22:16:26 2014 +0100
@@ -3,7 +3,7 @@
"{ Package: 'jv:libgdbs' }"
Object subclass:#GDBParser
- instanceVariableNames:'source lookahead token'
+ instanceVariableNames:'source lookahead token token2CommandMappingBlock'
classVariableNames:''
poolDictionaries:'GDBCommandStatus'
category:'GDB-Private'
@@ -17,6 +17,14 @@
"Created: / 27-05-2014 / 23:50:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!GDBParser methodsFor:'accessing'!
+
+token2CommandMappingBlock: aBlock
+ token2CommandMappingBlock := aBlock.
+
+ "Created: / 19-06-2014 / 21:34:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
!GDBParser methodsFor:'initialization'!
on: aStringOrStream
@@ -256,20 +264,36 @@
result-record → '^' result-class ( ',' result )* nl
"
- | result |
+ | command result descriptor propertyName propertyDescriptor propertyValue |
self expect: $^.
result := GDBCommandResult new.
result status: self parseResultClass.
- self peek == $, ifTrue:[
- self next.
- result value: self parseResult.
+ descriptor := GDBObjectValueDescriptor new.
+ (token notNil and:[ token2CommandMappingBlock notNil ]) ifTrue:[
+ command := token2CommandMappingBlock value: token.
+ command notNil ifTrue:[
+ result command: command.
+ descriptor := command resultValueDescriptor.
+ ].
].
+ [ self peek == $, ] whileTrue:[
+ self next. "/ eat $,
+ propertyName := self parseVariable.
+ propertyDescriptor := descriptor propertyDescriptorAt: propertyName.
+ self expect: $=.
+ propertyDescriptor isNil ifTrue:[
+ propertyValue := self parseValue.
+ ] ifFalse:[
+ propertyValue := propertyDescriptor parseUsingParser: self.
+ ].
+ result propertyAt: propertyName put: propertyValue.
+ ].
self parseNl.
^ GDBCommandResultEvent new result: result.
"Created: / 30-05-2014 / 09:52:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 02-06-2014 / 22:22:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-06-2014 / 22:03:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
parseToken
@@ -312,26 +336,31 @@
async-output → async-class ( ',' result )* nl
"
- | type eventClass data |
+ | type eventClass event propertyName propertyDescriptor descriptor propertyValue |
type := self parseString.
eventClass := eventClassBase eventClassForType: type.
-
- data := Array streamContents:[ :s |
- [ self peek == $, ] whileTrue:[
- self next.
- s nextPut: self parseResult.
- ]
+ event := eventClass new.
+ event type: type.
+ descriptor := eventClass gdbValueDescriptor.
+ [ self peek == $, ] whileTrue:[
+ self next. "/ eat $,
+ propertyName := self parseVariable.
+ propertyDescriptor := descriptor propertyDescriptorAt: propertyName.
+ self expect: $=.
+ propertyDescriptor isNil ifTrue:[
+ propertyValue := self parseValue.
+ ] ifFalse:[
+ propertyValue := propertyDescriptor parseUsingParser: self.
+ ].
+ event propertyAt: propertyName put: propertyValue.
].
self parseNl.
- ^ eventClass new
- type: type;
- data: data;
- yourself
+ ^ event
"Created: / 01-06-2014 / 23:43:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 12-06-2014 / 17:07:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 19-06-2014 / 21:43:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!GDBParser methodsFor:'parsing-misc'!