Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

ZirToken

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

Replies

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i am Little confused ,i got this error ,Ziron ver 1.1.26.1

PlugSys: Unexpected token type

Code:

Var = 1000;

here is the uptodate Plugin

function event_Dim()
{
	uses edi;  
	Dword Len;
    char var[255];  
    char buf[1024]; 
    
repeat {    
    buf = 0; //make sure buf is initialized otherwise it may be filled with junk
      
    eax = Ziron_ExpectNextToken(zirIdent);
	if (eax == -1) {
		Ziron_FatalError('Expected Variable Name');
		return true;
	}
	H_strcpy(@var,Ziron_GetStringValue());   
Ziron_ShowMessage(@var);
	
	eax = Ziron_GetNextToken();
//push eax; Ziron_ShowMessage(@var); pop eax;	 
	
	case (eax) 
	 {
/*********   Dim Var as int32;    **************/      	 
	   state zirAs:
	      eax = Ziron_ExpectNextToken(zirDATA_TYPE);
	      if (eax == -1) 
	       {
		       Ziron_FatalError('Expected data type');
		       return true;
	       }
	      eax =  Ziron_GetStringValue();
          H_strcat(@buf,eax); 
          H_strcat(@buf,' ');  
          H_strcat(@buf,@var);
          H_strcat(@buf,';');  
          H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
          Len = H_strlen(@buf);          
	      eax = Ziron_Execute(@buf,Len);
          if (eax == false)
           {
               Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
           }  
          break;
/*********   dim k%;    **************/        
       state zirModSym:
             H_strcat(@buf,'int32 '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }  
          break;
/*********   dim k$;    **************/              
        state zirDollarSym:
             H_strcat(@buf,'char '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,'[1024];');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }  
          break;
/*********   dim k!;    **************/          
        state zirExclamation:
             H_strcat(@buf,'single '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }        
          break; 
/*********   dim k#;    **************/          
        state zirHash:
             H_strcat(@buf,'double '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }                
          break;  
/*********       **************          
        state zirIdent:
              eax = Ziron_GetStringValue();  
              
              
              
          break;
/*********       **************/            
     default:
	      Ziron_FatalError('Expected as Keyword');
		  return true;
	 }

	eax = Ziron_IsNextLineBreak(); 
	if(eax)
	 {
	    break;      // check end of line so we end without semicolon
	 } 

    eax = Ziron_GetNextToken();    
    if (eax == zirSEMI_COLON) 
     {
			break;
	 } elseif (eax != zirCOMMA) {
			Ziron_FatalError('Unexpected token type');
		    	
	 }  
};
	return true;
}

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

and here is the test program

program WIN32CUI 'Basic Syntax test';

#include 'console.zir';

function  H_strcpy(Dword dst,src)
{ 
  Eax = dst; 
  Edx = src; 
  push Eax;
  BL =  [Edx]; 
  while ( BL != 0)  
   { 
      [Eax] = BL; 
      Eax++; Edx++; 
      BL =  [Edx]; 
   }  
  [Eax] = 0;
  pop Eax;
} 

eax = 1;
print('eax = ', eax:int, '\r\n');

Dim Var as int32  // note well , in basic there is no semicolon at end of file

DIM Name$

DIM a AS int32, b AS Dword, c AS char

dim k%

dim S!

dim M#

Var = 1000;
a = -10;
b = 150;
c = ord('A');
k = -2000;

H_strcpy(@Name , 'Emil');

print('Var = ', Var, '\r\n');
print('a = ', a, '\r\n');
print('b = ', b, '\r\n');
print('c = ');
WriteLnEx(@c,1);
print('k = ', k, '\r\n');
WriteLnEx(@Name,4);

wait_key(nil);
ExitProcess(0);

so what could be the problem?

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria
 eax = Ziron_GetNextToken();    
    if (eax == zirSEMI_COLON) 
     {
      break;
   } elseif (eax != zirCOMMA) {
      Ziron_FatalError('Unexpected token type');
          
   }  

this is your problem, you are enforcing the semi colon, and in the test code you do not put semi colons.

And actually i see i need to add another pf function to peek at the next token, i will add it now, and give you link for testing with.

what you will need is

	eax = Ziron_PeekNextToken();    
	if (eax == zirCOMMA) {
		Ziron_GetNextToken();
	} else {
		break;
	}

give me 5 minutes. :)

Colin admin
Posts
928
Threads
49
Location
Bulgaria

ok sent you link :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

the same error with ver 1.1.27.5 alpha

code:

Dim Name$

function event_Dim()
{
	uses edi;  
	Dword Len;
    char var[255];  
    char buf[1024]; 
    
repeat {    
    buf = 0; //make sure buf is initialized otherwise it may be filled with junk
      
    eax = Ziron_ExpectNextToken(zirIdent);
	if (eax == -1) {
		Ziron_FatalError('Expected Variable Name');
		return true;
	}
	H_strcpy(@var,Ziron_GetStringValue());   
Ziron_ShowMessage(@var);
	
	eax = Ziron_GetNextToken();
//push eax; Ziron_ShowMessage(@var); pop eax;	 
	
	case (eax) 
	 {
/*********   Dim Var as int32;    **************/      	 
	   state zirAs:
	      eax = Ziron_ExpectNextToken(zirDATA_TYPE);
	      if (eax == -1) 
	       {
		       Ziron_FatalError('Expected data type');
		       return true;
	       }
	      eax =  Ziron_GetStringValue();
          H_strcat(@buf,eax); 
          H_strcat(@buf,' ');  
          H_strcat(@buf,@var);
          H_strcat(@buf,';');  
          H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
          Len = H_strlen(@buf);          
	      eax = Ziron_Execute(@buf,Len);
          if (eax == false)
           {
               Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
           }  
          break;
/*********   dim k%;    **************/        
       state zirModSym:
             H_strcat(@buf,'int32 '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }  
          break;
/*********   dim k$;    **************/              
        state zirDollarSym:
             H_strcat(@buf,'char '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,'[1024];');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }  
          break;
/*********   dim k!;    **************/          
        state zirExclamation:
             H_strcat(@buf,'single '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }        
          break; 
/*********   dim k#;    **************/          
        state zirHash:
             H_strcat(@buf,'double '); 
             H_strcat(@buf,@var);
             H_strcat(@buf,';');  
             H_strcat(@buf,'\r\n'); 
//Ziron_ShowMessage(@buf);
             Len = H_strlen(@buf);          
	         eax = Ziron_Execute(@buf,Len);
             if (eax == false)
              {
                 Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
              }                
          break;  
/*********       **************          
        state zirIdent:
              eax = Ziron_GetStringValue();  
              
              
              
          break;
/*********       **************/            
     default:
	      Ziron_FatalError('Expected as Keyword');
		  return true;
	 }

	eax = Ziron_IsNextLineBreak(); 
	if(eax)
	 {
	    break;      // check end of line so we end without semicolon
	 } 

    eax = Ziron_PeekNextToken();    
    if (eax == zirCOMMA) {
       Ziron_GetNextToken();
     } else {
       break;
     }
};
	return true;
}

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

i cleaned up the function a little and compiled with your test code, compiled without a problem :)

function event_Dim() {
	uses edi;  
	Dword Len;
	char var[255];  
	char buf[1024]; 
    	
	repeat {         
		buf = 0; //make sure buf is initialized otherwise it may be filled with junk
		
		eax = Ziron_ExpectNextToken(zirIdent);
		if (eax == -1) {
			Ziron_FatalError('Expected Variable Name');
			return true;
		}
		
		H_strcpy(@var,Ziron_GetStringValue());   
		Ziron_ShowMessage(@var);
  
		eax = Ziron_GetNextToken();
		//push eax; Ziron_ShowMessage(@var); pop eax;   
  
		case (eax) {
		
			/*********   Dim Var as int32;    **************/         
			state zirAs:
				eax = Ziron_ExpectNextToken(zirDATA_TYPE);
				if (eax == -1) {
					Ziron_FatalError('Expected data type');
					return true;
				}
				eax =  Ziron_GetStringValue();
				H_strcat(@buf,eax); 
				H_strcat(@buf,' ');  
				H_strcat(@buf,@var);
				H_strcat(@buf,';');  

				Len = H_strlen(@buf);          
				eax = Ziron_Execute(@buf,Len);
				if (eax == false) {
					Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
					return true;
				}  
				break;
				
			/*********   dim k%;    **************/        
			state zirModSym:
				H_strcat(@buf,'int32 '); 
				H_strcat(@buf,@var);
				H_strcat(@buf,';');   

				Len = H_strlen(@buf);          
				eax = Ziron_Execute(@buf,Len);
				if (eax == false) {
					Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
					return true;
				}
				break;
				
			/*********   dim k$;    **************/              
			state zirDollarSym:
				H_strcat(@buf,'char '); 
				H_strcat(@buf,@var);
				H_strcat(@buf,'[1024];');  

				Len = H_strlen(@buf);          
				eax = Ziron_Execute(@buf,Len);
				if (eax == false) {
					Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
					return true;
				}
				break;
				
			/*********   dim k!;    **************/          
			state zirExclamation:
				H_strcat(@buf,'single '); 
				H_strcat(@buf,@var);
				H_strcat(@buf,';');  

				Len = H_strlen(@buf);          
				eax = Ziron_Execute(@buf,Len);
				if (eax == false) {
					Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
					return true;
				}        
				break; 
				
			/*********   dim k#;    **************/          
			state zirHash:
				H_strcat(@buf,'double '); 
				H_strcat(@buf,@var);
				H_strcat(@buf,';');

				Len = H_strlen(@buf);          
				eax = Ziron_Execute(@buf,Len);
				if (eax == false) {
					Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
					return true;
				}                
				break;  
				
			/*********       **************          
			//state zirIdent:
				//eax = Ziron_GetStringValue();  
				//break;
				
			/*********       **************/            
			default:
				Ziron_FatalError('Expected as Keyword');
				return true;
		}

		eax = Ziron_IsNextLineBreak(); 
		if (eax) {
			break;      // check end of line so we end without semicolon
		} 

		eax = Ziron_PeekNextToken();    
		if (eax == zirCOMMA) {
			Ziron_GetNextToken();
		} else {
			break;
		}
	};
	return true;
}

i could not see any problems.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

oh , no , i have cut and past your post , and test it again

still get the same error ?

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

Colin admin
Posts
928
Threads
49
Location
Bulgaria

did you re-download the latest package from your Private Message ?