[196,26]: Expected register or data type or variable or local variable or local parameter or constant or number or constant string or - but found [edi] in [Helper.zir]
Code:
while(AL == char[EDI])
the code
function H_strcmp(Dword str1,str2)
{
ESI = str1; EDI = str2;
AL = char[ESI];
while(AL == char[EDI])
{
if(AL == 0 && char[EDI] ==0){ return 0; }
ESI++; EDI++;
AL = char[ESI];
}
xor Eax,Eax
al = = char[ESI];
al -= char[EDI];
}
so it seems While did not accept parameters just like if statement.
here is what i done , oh.... the H_strjoin gives access violation
function event_Let() {
uses edi;
char buf[2048];
char var[255];
char str1[255];
Dword Len;
boolean StringFlg;
// get the variable name and hold it in Var
eax = Ziron_GetNextToken();
case (eax) {
state zironVar:
state zironLocalVar:
break;
default:
Ziron_FatalError('Expected Variable Name');
return true;
}
H_strcpy(@var,Ziron_GetStringValue());
StringFlg = strCmp(Ziron_GetVarTypeString(Ziron_GetID()),'char');
// check for'=' symbol
eax = Ziron_ExpectNextToken(zirAssignment);
if (eax == -1) {
Ziron_FatalError('Expected = symbol');
return true;
}
// start pares if the var type is string
if(StringFlg)
{
// here we start getting what after '='
Ziron_GetNextToken();
H_strcpy(@str1,Ziron_GetStringValue());
eax = Ziron_IsNextLineBreak();
if (!eax) {
Ziron_GetNextToken(); // remove ';'
}
buf=0;
H_strjoin(@buf, 'H_strcpy(@' , @var, ', \'' , str1, '\');' ); // access violation here
Ziron_ShowMessage(@buf);
return true;
}
else
{
return false; // let Ziron handle the line
}
}
oh , my mistake , forgot '@' ,any way here is a working Let code
function event_Let() {
uses edi;
char buf[2048];
char var[255];
char str1[255];
Dword Len;
boolean StringFlg;
// get the variable name and hold it in Var
eax = Ziron_GetNextToken();
case (eax) {
state zironVar:
state zironLocalVar:
break;
default:
Ziron_FatalError('Expected Variable Name');
return true;
}
H_strcpy(@var,Ziron_GetStringValue());
StringFlg = strCmp(Ziron_GetVarTypeString(Ziron_GetID()),'char');
// check for'=' symbol
eax = Ziron_ExpectNextToken(zirAssignment);
if (eax == -1) {
Ziron_FatalError('Expected = symbol');
return true;
}
// start pares if the var type is string
if(StringFlg)
{
// here we start getting what after '='
Ziron_GetNextToken();
H_strcpy(@str1,Ziron_GetStringValue());
eax = Ziron_IsNextLineBreak();
if (!eax) {
Ziron_GetNextToken(); // remove ';'
}
buf=0;
H_strjoin(@buf, 'H_strcpy(@' , @var, ', \'' , @str1, '\');' );
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');
return true;
}
return true;
}
else
{
return false; // let Ziron handle the line
}
}
function InitPlugin(pointer pGetF) {
Ziron_LoadAll(pGetF); //use framework utility function to load all
//add H_strcpy function
const sc_code = '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; }';
Ziron_Execute(@sc_code,H_strlen(@sc_code));
//add some variable type
const MyType = 'type Integer = Int32; type String = char; type Uchar = char; type Schar = sbyte; type USHORT = word;';
Ziron_Execute(@MyType,H_strlen(@MyType));
//register our keyword
Ziron_RegisterKeyword('Dim', @event_Dim);
Ziron_RegisterKeyword('Let', @event_Let);
return strLoaded;
}
as you see , in InitPlugin i have putted H_strcpy implementation , but need to check if it
already implemented before or not
here is a test code
DIM Name$
print('Name = ');
Let Name = '100';
WriteLnEx(@Name,4);
eax = Ziron_IsNextLineBreak();
if (!eax) {
eax = Ziron_GetNextToken();
case (eax) {
state zirPlusSym:
state zirComma:
Ziron_ShowMessage('found + or ,');
break;
// remove ';' if found
state zirSemi_Colon:
Ziron_ShowMessage('found ;');
break;
default:
Ziron_FatalError('Expected "+" or ";"');
return true;
}
}
test code give this error
Expected number or hexadecimal or constant string but found wait_key in [testprog.zir]
Code:
wait_key(nil);
Dim c$
Let c = 'Emil' + 'halim'
wait_key(nil);
ExitProcess(0);