Entry
BBCBASIC: Windows: How to possibly convert Windows API calls to BBCBASIC Sys calls?
Feb 19th, 2006 13:46
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 19 February 2021 - 08:25 pm -------------------
BBCBASIC: Windows: How to possibly convert Windows API calls to
BBCBASIC Sys calls?
---
1. In analyzing the Microsoft Windows API calls, there are 3 modules
necessary:
1. a scanner (or lexical analyzer)
2. a parser (or syntax analyzer)
3. a semantic analyzer
---
2. You can further analyze a program
1. top down
2. bottom up
---
2. From the following given examples of API function calls
#define IDirect3D_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface()
#define IDirect3D_AddRef(p) (p)->lpVtbl->AddRef()
#define IDirect3D_Release(p) (p)->lpVtbl->Release()
#define IDirect3D_Initialize(p,a) (p)->lpVtbl->Initialize()
#define IDirect3D_EnumDevices(p,a,b) (p)->lpVtbl->EnumDevices()
#define IDirect3D_CreateLight(p,a,b) (p)->lpVtbl->CreateLight()
#define IDirect3D_CreateMaterial(p,a,b) (p)->lpVtbl->CreateMaterial()
#define IDirect3D_CreateViewport(p,a,b) (p)->lpVtbl->CreateViewport()
#define IDirect3D_FindDevice(p,a,b) (p)->lpVtbl->FindDevice()
---
3. You can induce the following general form:
1. Backus Naur Form for this API functions
--- cut here: begin --------------------------------------------------
->-(#)->(define)->-[API function name]->('(')->-+
|
|
|
+-<---------------------------------------------+
|
| +----<------------+
| | |
+->-+->-[parameter]->-+->-(')')->---------------+
| | |
+---->------------+ |
|
+-<---------------------------------------------+
|
|
|
+->-('(')->-[pointer]->-(')')->-('->')----------+
|
|
|
+-<---------------------------------------------+
|
|
|
+->-[left pointer virtual table]->--------------+
|
|
|
+-<---------------------------------------------+
|
|
|
+->-('->-')->-[API sub function name]->-('()')->-
--- cut here: end ----------------------------------------------------
3. This Backus Naur Form you could parse, using pseudo code,
as follows:
1. Begin at the start
2. follow the arrows
3. replace each parallel or serial option by the corresponding fixed
pseudocode form
4. until you reach the end
--- cut here: begin --------------------------------------------------
REM --------------------------
REM get '#'
REM --------------------------
if not '#'
return 'error'
else
get '#'
endif
REM --------------------------
REM get 'define'
REM --------------------------
s = empty string
if not character in [a-zA-Z_]
return 'error'
else
get character
endif
s = character
:
while character in [a-zA-Z_0-9]
get character
s = s + character
endwhile
:
if s not equal to 'define'
return 'error'
endif
REM --------------------------
REM get spaces
REM --------------------------
while ' '
get ' '
endwhile
REM --------------------------
REM get API function name
REM --------------------------
s = empty string
if not character in [a-zA-Z_]
return 'error'
else
get character
endif
s = character
:
while character in [a-zA-Z_0-9]
get character
s = s + character
endwhile
REM --------------------------
REM get '(' after API function name
REM --------------------------
if not '('
return 'error'
else
get '('
endif
REM --------------------------
REM get parameters
REM --------------------------
s = empty string
repeat
:
REM get spaces
while ' '
get ' '
endwhile
:
case:
when character in [a-zA-Z_0-9]
s = s + character
get character
while character in [a-zA-Z_0-9]
get character
s = s + character
endwhile
when ','
get ','
endcase
until current character equals ')'
REM --------------------------
REM get spaces
REM --------------------------
while ' '
get ' '
endwhile
REM --------------------------
REM get '('
REM --------------------------
if not '('
return 'error'
else
get '('
endif
REM --------------------------
REM get spaces
REM --------------------------
while ' '
get ' '
endwhile
REM --------------------------
REM get 'p'
REM --------------------------
if not 'p'
return 'error'
else
get 'p'
endif
REM --------------------------
REM get spaces
REM --------------------------
while ' '
get ' '
endwhile
REM --------------------------
REM get ')'
REM --------------------------
if not ')'
return 'error'
else
get ')'
endif
REM --------------------------
REM get '->'
REM --------------------------
if not '-'
return 'error'
else
get '-'
endif
:
if not '>'
return 'error'
else
get '>'
endif
REM --------------------------
REM get 'lpVtbl'
REM --------------------------
s = empty string
if not character in [a-zA-Z_]
return 'error'
else
get character
endif
s = character
:
while character in [a-zA-Z_0-9]
get character
s = s + character
endwhile
:
if s not equal to 'lpVtbl'
return 'error'
endif
REM --------------------------
REM get '->'
REM --------------------------
if not '-'
return 'error'
else
get '-'
endif
:
if not '>'
return 'error'
else
get '>'
endif
REM --------------------------
REM get API sub function name
REM --------------------------
s = empty string
if not character in [a-zA-Z_]
return 'error'
else
get character
endif
s = character
:
while character in [a-zA-Z_0-9]
get character
s = s + character
endwhile
REM --------------------------
REM get '('
REM --------------------------
if not '('
return 'error'
else
get '('
endif
REM --------------------------
REM get ')'
REM --------------------------
if not ')'
return 'error'
else
get ')'
endif
:
--- cut here: end ----------------------------------------------------
===
Internet: see also:
---
BBCBASIC: Windows: API: BBCBASIC: Operation Convert: Link: Overview:
Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/39746/fid/768
----------------------------------------------------------------------