Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / General Discussion

ptr token

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ptr token

hi ,

is the term 'ptr' a keyword ?

and if so what is the enumeration value of it?

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ptr is actually an internal macro so it does not have an enumeration value, what are you trying to do? maybe I can give some ideas :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , i was playing with my old basic plugin and fount that in my to-do section

// to-do-list
//dim kk% = -20
//DIM  Ea[10,10] as int32
//Dim h As Byte ptr
//Dim s1 As String * 10

so i was trying to implement this

Dim h As Byte ptr

Ziron refused to accept 'ptr' as zirIdent token.

any help ,please ?

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK, i have an idea for a solution for the next release, for now you could do a pass on source to replace the type ptr

ie, if a data type is hit, you can do a manual check of the source line and if ptr follows the datatype you can internally replace "type ptr" with type*.

dim a as byte ptr
dim b as dword ptr

in this example, if a type such as byte is found in your dim handler, you can extract the line and check for "type ptr"

replace the " ptr" with "* "

as the following:

dim a as byte*
dim b as dword*

and of course into:

byte* a;
dword* b;

hope this helps ;)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , thanks.

but how can i do a manual check of the source line ?

here is a part of my code

function event_Dim() {
    uses edi;  
    Dword Len;
    char var[255];  
    char buf[1024]; 
    char tmp[255];  
  repeat {         
    buf = 0; //make sure buf is initialized otherwise it may be filled with junk
    
    // get the variable name and hold it in Var 
    eax = Ziron_ExpectNextToken(zirIdent);
    if (eax == -1) {
      Ziron_FatalError('Expected Variable Name');
      return true;
    }
    H_strcpy(@var,Ziron_GetStringValue());   
  
    // get whatever after variable name
    eax = Ziron_GetNextToken();
       
    // let's parse it
    // it can be one of those  
    // As % $ ! # [] 
    case (eax) {
    
      /*********   Dim Var as int32;      **************/     
      /*********   Dim Var as int32 ptr;  **************/      
      state zirAs:
        
        eax = Ziron_ExpectNextToken(zirDATA_TYPE);
        if (eax == -1) {
          Ziron_FatalError('Expected data type');
          return true;
        }
        H_strcpy(@tmp,Ziron_GetStringValue());
        // if end of line the exit
        eax = Ziron_IsNextLineBreak(); 
        if (eax) {
             goto @doit;
         }
        // check if next token is 'ptr'  
        eax = Ziron_PeekNextToken(); 
        if ( eax ==  zirIdent) 
         {
            Dbg(eax); // used for debug purpose
            //Ziron_GetNextToken(); 
            strCmp('ptr',strLower(Ziron_GetStringValue()));
            if(eax)
             {
                H_strcat(@tmp,'*');
             } 
         }    
       @doit:
        H_strjoin(@buf, @tmp, ' ', @var, ';');          
        eax = Ziron_Exec(@buf);
        if (eax == false) {
          Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
          return true;
        }  

        break;       

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I suggest you take a look through the "plugin/plugin_interface.rtf" file for a list of api functions. You will probably need the following function: Ziron_ExtractLine :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

using the latest release you can now set a custom token so, register keyword "ptr"

in the callback, if the next token is a new line for example, then use the new pf function Ziron_SetTokenType as so:

Ziron_SetTokenType(zirUserIdent, 'ptr');

return as handled if set, else false, then in your other code you can do a ziron get id and string to check if the token is a user token and if the text is ptr :)

good luck :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

thanks for the new release of Ziron.

but could you please , give me a Little working example to show me your new function.

http://www.freewebs.com/ogremagic/index.htm