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.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Not in the office right now, but something along these lines:

note code is mostly psuedo

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:

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

hope that helps.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

strange something here!!!!!!

here is my ptr event function

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

Ziron_RegisterKeyword('ptr', @event_Ptr);

but ziron did not call event_Ptr function at all

and here is a line of my test program

Dim h As Byte ptr

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK i will finish my current code i'm writing then i will take a look for any internal bugs :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

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:

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:

abcd ptr

should output Found PTR!

Hope this time everything is fine :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

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