Register | Login
Forum Index > Bugs and Fixes > Ziron_PeekNextToken problem
Author Message
Pages: 1 2
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1212] Ziron_PeekNextToken problem - posted: 2012-05-23 18:41:15

Hi Mr Colin.

i used this code to check of double hash EG. '##'
Code:
   Tok  = Ziron_GetNextToken();  
   .....
   .....
   if ( (Tok == zirDirective) or (Tok == zirHash) ) // so we found '#'
    {
        nxTok  =  Ziron_PeekNextToken();
        if( (nxTok == zirDirective) or (nxTok == zirHash)) check for another '#'
         {


but it seem's Ziron_PeekNextToken updates internal zrion state, so that Ziron_GetStringValue brings next Token in program and it should brings the one that belong to Tok.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1213] - posted: 2012-05-23 19:03:19
it will return the peeked token string

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
[1214] - posted: 2012-05-23 20:22:44

ok , can i have a flag that allow Ziron_GetStringValue to return the previous one.



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

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1215] - posted: 2012-05-23 20:25:46

or , can you make a new pf that return the string belong to Ziron_GetNextToken and one for
Ziron_PeekNextToken.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1216] - posted: 2012-05-23 20:56:28
To do this i will need to add a seperate buffer for current/peeked token strings, however since alot of plugins will not require this, it may be best for you to allocate your own buffer for token strings before calling peeknexttoken.

you could use something like this:

Code:
/////////////

const maxTokenLength = 256; //i will add this to framework.zir and will update it accordingly at later releases.

inline function Ziron_GetNextTokenEx() {
   global char tokString[maxTokenLength];

   eax = Ziron_GetNextToken();
   push eax
   eax = Ziron_GetStringValue();
   strcpy(@tokString, eax);
   pop eax

   $return eax;
}

inline function Ziron_GetStringValueEx() {
   $return @tokString;
}

//////

   Tok  = Ziron_GetNextTokenEx();  
   .....
   .....
   if ( (Tok == zirDirective) or (Tok == zirHash) ) // so we found '#'
    {
        nxTok  =  Ziron_PeekNextToken();
        if( (nxTok == zirDirective) or (nxTok == zirHash)) check for another '#'
         {


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
[1219] - posted: 2012-05-23 22:52:13
ok , thanks for your good solution.

now i am stuck , first thing is.
Code:
   #define  string(x)  #x


this means when you find this term string(Ziron) you must replace it with this term 'Ziron'
so how can i do this in ziron , const & inline function do not help hear.

so what do you suggests ?


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1220] - posted: 2012-05-24 00:17:25
i do not understand, can you explain in detail?

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
[1221] - posted: 2012-05-24 08:15:38

ok ,
Code:
 #define  string(x)  #x


when putting '#' before token in define body directive like this '#x' , you force ziron when
found string() inside the program it will replace the string() with what in between () and
add '|'' in front and at the end of what in between() , i mean force it to be literal string.

Eax.
Code:
  #define  string(x)  #x

  .........
  ......... 
  .........

  // later

  print(string(ziron)); // this should convert to be print('ziron'); 


http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2
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