Register | Login
Forum Index > General Discussion > ptr token
Author Message
Pages: 1 2 3
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1023] - posted: 2012-05-07 17:10:27
Not in the office right now, but something along these lines:

note code is mostly psuedo

Code:
function event_Ptr() {
  //check if next is a newline -> if so
    Ziron_SetTokenType(zirUserIdent, 'ptr');
    return true;
  //}

  return false;
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register our keyword
  Ziron_RegisterKeyword('ptr', @event_Ptr);
  
  //register your dim keyword etc
  
  return strLoaded;
}


and with your dim event:

Code:
function event_Dim() {
  //your code
  
  if next token = zirUserIdent and Ziron_GetStringValue = 'ptr' then
    ...
    
}


hope that helps.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1024] - posted: 2012-05-07 20:02:18

strange something here!!!!!!

here is my ptr event function
Code:
function event_Ptr() 
{
  //check if next is a newline -> if so
  Ziron_ShowMessage('found ptr');     
   eax = Ziron_IsNextLineBreak(); 
   if (eax) {      
            Ziron_SetTokenType(zirUserIdent, 'ptr');
            return true;
  } 
  return false; // let Ziron handle the line  
}


and register it as this
Code:
Ziron_RegisterKeyword('ptr', @event_Ptr);


but ziron did not call event_Ptr function at all

and here is a line of my test program
Code:
Dim h As Byte ptr


http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1026] - posted: 2012-05-07 20:28:57

I found that

when 'ptr' is the first word in the line Ziron will detect ptr and call event handler , and if 'ptr' is in the middle of line or at end of the line ziron will not detect it.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1027] - posted: 2012-05-07 20:31:20
OK i will finish my current code i'm writing then i will take a look for any internal bugs smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1029] - posted: 2012-05-07 21:59:07
OK i believe i see the problem

http://www.codeziron.com/uploads/releases/ziron.compiler.beta.rar

i've updated the beta version with a new pf function, change:

Code:
Ziron_RegisterKeyword('ptr', ..


to

Code:
Ziron_RegisterUserToken('ptr', ...


let me know smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1030] - posted: 2012-05-07 22:56:58

ok , got Access violation when compiling the test program

here is the log file

Ziron Compiler 1.1.31.1
Copyright (C) 2011-2012. OverHertz Ltd. All rights reserved.
--------------------------------------------
5/7/2012 10:54:05 PM
--------------------------------------------

PlugSys: Basic plugin has loaded!
--------------------------------------------


Access violation at address 00001388. Read of address 00001388
Press the [enter] key to exit.


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1031] - posted: 2012-05-08 18:01:17
Seems there was a bug with Ziron_SetTokenType, it was getting address of peeknexttoken in GetFunction, anyhow i've fixed that and 1 other thing. I've re-uploaded the beta and here is a sample:

Code:
program WIN32DLL 'PLUGIN';

#include 'zirplug/framework.zir';

//////////////////////////////

const strLoaded = 'Plugin has loaded!';

//////////////////////////////

function token_Ptr() {
  eax = Ziron_IsNextLineBreak(); 
  if (eax) {      
    Ziron_SetTokenType(zirUserIdent, 'ptr');
    return true;
  }
  return false;
}


function event_ABCD() {
  eax = Ziron_ExpectNextToken(zirUserIdent);
  if (eax <> -1) {
    if (strCmp('ptr', strLower(Ziron_GetStringValue())) == True) {;
      Ziron_ShowMessage('Found PTR!');
      return true;
    }
    return false;
  }
    
  return false;
}

function InitPlugin(pointer pGetF) {
  Ziron_LoadAll(pGetF); //use framework utility function to load all

  //register token
  Ziron_RegisterUserToken('ptr', @token_Ptr);
  
  //register our keyword
  Ziron_RegisterKeyword('abcd', @event_ABCD);
  
  return strLoaded;
}

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    return true;
  }

  return false;
}

exports InitPlugin;


usage in source:

Code:
abcd ptr


should output Found PTR!

Hope this time everything is fine smile

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1032] - posted: 2012-05-08 20:43:43

ok , works fin now.

but i think you forget debug print statement in Ziron , because it prints term 'ptr' and
'5000' tow times when compiling a test program.

http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2 3
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 1 user(s) online. 0 member(s) and 1 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd