VDBParser.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 10 Nov 2019 23:57:47 +0000
changeset 188 7080f4698aec
child 264 23960fcb9dac
permissions -rw-r--r--
UI: add `VDBDisassemblyApplication` An application to show disassembly for given address and/or address range. This is usefull when working with JIT-compiled code.

"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
"{ Package: 'jv:vdb' }"

"{ NameSpace: Smalltalk }"

PPCompositeParser subclass:#VDBParser
	instanceVariableNames:'decnum hexnum address range'
	classVariableNames:''
	poolDictionaries:''
	category:'VDB-Expressions'
!

!VDBParser class methodsFor:'documentation'!

copyright
"
jv:vdb - Visual / VM Debugger
Copyright (C) 2015-now Jan Vrany

This software is licensed under 'Creative Commons Attribution-NonCommercial 4.0 International License'

You may find a full license text in LICENSE.txt or at http://creativecommons.org/licenses/by-nc/4.0/
"
!

documentation
"
    This is (somewhat relaxed) parser used to parse various
    user inputs, like addresses, address ranges and so on.

    Used in various places to parse user input.

    [author:]
        Jan Vrany <jan.vrany@fit.cvut.cz>

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!VDBParser methodsFor:'rules'!

address
     ^ (hexnum / decnum) ==> [ :value | VDBAddress value: value ]

     "
     VDBParser new address parse: '0xF1'
     VDBParser new address parse: '01'
     "

    "Created: / 20-10-2019 / 20:22:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 10-11-2019 / 23:30:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

decnum
    ^ #digit asParser plus trim ==> [ :digits | Integer readFrom: digits radix: 10 ]

    "
    VDBUserInputParser new decnum parse: '21'
    "

    "Created: / 20-10-2019 / 20:26:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

hexnum
    ^ ($0 asParser , $x asParser , #hex asParser plus) trim
        ==> [ :nodes | Integer readFrom: nodes third radix: 16 ]

    "
    VDBUserInputParser new hexnum parse: ' 0xFF '
    "

    "Created: / 20-10-2019 / 20:26:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

range
     ^ (address , ',' asParser , address) ==> [ :nodes | VDBAddressRange from: nodes first to: nodes last ]

     "
     VDBParser new range parse: '0x1FF10000 , 0x1FF100F0'
     "

    "Created: / 20-10-2019 / 21:05:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 21-10-2019 / 00:03:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

start
    ^ range / address

    "Created: / 20-10-2019 / 20:27:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 21-10-2019 / 00:04:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !