📄 compile.cpp
字号:
aByte.attribute = EMPTY;
aByte.value = "EMPTY";
return aByte;
}
if(state == 71)//多行注释
{
while(1)
{
inputChar = getNextChar(pBuffer, pScr);
if(inputChar == '*')
{
inputChar = getNextChar(pBuffer, pScr);
if(inputChar == '/')
{
break;
}
}
}
goNextChar(pBuffer, pScr);
aByte.attribute = EMPTY;
aByte.value = "EMPTY";
return aByte;
}
if(state == 24)
{
aByte.attribute = OPERATION;
aByte.value = "/=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 27)
{
aByte.attribute = OPERATION;
aByte.value = ",";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 30)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '=':
state = 32;
break;
default:
state = 31;
}
}
if(state == 31)
{
aByte.attribute = OPERATION;
aByte.value = "%";
return aByte;
}
if(state == 32)
{
aByte.attribute = OPERATION;
aByte.value = "%=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 33)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '>':
state = 35;
break;
case '=':
state = 36;
break;
default:
state = 34;
}
}
if(state == 34)
{
aByte.attribute = OPERATION;
aByte.value = ">";
return aByte;
}
if(state == 35)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '=':
state = 38;
break;
default:
state = 37;
}
}
if(state == 36)
{
aByte.attribute = OPERATION;
aByte.value = ">=";
goNextChar(pBuffer, pScr);
return aByte;
}
if(state == 37)
{
aByte.attribute = OPERATION;
aByte.value = ">>";
return aByte;
}
if(state == 38)
{
aByte.attribute = OPERATION;
aByte.value = ">>=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 39)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '<':
state = 41;
break;
case '=':
state = 42;
break;
default:
state = 40;
}
}
if(state == 40)//<
{
aByte.attribute = OPERATION;
aByte.value = "<";
return aByte;
}
if(state == 41)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '=':
state = 44;
break;
default:
state = 43;
}
}
if(state == 42)//<=
{
aByte.attribute = OPERATION;
aByte.value = "<=";
goNextChar(pBuffer, pScr);
return aByte;
}
if(state == 43)//<<
{
aByte.attribute = OPERATION;
aByte.value = "<<";
return aByte;
}
if(state == 44)//<<=
{
aByte.attribute = OPERATION;
aByte.value = "<<=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 45)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '&':
state = 47;
break;
case '=':
state = 48;
break;
default:
state = 46;
}
}
if(state == 46)//&
{
aByte.attribute = OPERATION;
aByte.value = "&";
return aByte;
}
if(state == 47)//&&
{
aByte.attribute = OPERATION;
aByte.value = "&&";
goNextChar(pBuffer, pScr);
return aByte;
}
if(state == 48)//&=
{
aByte.attribute = OPERATION;
aByte.value = "&=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 49)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '|':
state = 51;
break;
case '=':
state = 52;
break;
default:
state = 50;
}
}
if(state == 50)//|
{
aByte.attribute = OPERATION;
aByte.value = "|";
return aByte;
}
if(state == 51)//||
{
aByte.attribute = OPERATION;
aByte.value = "||";
goNextChar(pBuffer, pScr);
return aByte;
}
if(state == 52)//|=
{
aByte.attribute = OPERATION;
aByte.value = "|=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 53)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '=':
state = 55;
break;
default:
state = 54;
}
}
if(state == 54)//^
{
aByte.attribute = OPERATION;
aByte.value = "^";
return aByte;
}
if(state == 55)//^=
{
aByte.attribute = OPERATION;
aByte.value = "^=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 56)//.
{
aByte.attribute = OPERATION;
aByte.value = ".";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 57)//?
{
aByte.attribute = OPERATION;
aByte.value = "?";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 58)
{
aByte.attribute = OPERATION;
aByte.value = ":";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 59)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '=':
state = 61;
break;
default:
state = 60;
}
}
if(state == 60)//!
{
aByte.attribute = OPERATION;
aByte.value = "!";
return aByte;
}
if(state == 61)//!=
{
aByte.attribute = OPERATION;
aByte.value = "!=";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 62)//~
{
aByte.attribute = OPERATION;
aByte.value = "~";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 64)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '\\':
state = 67;
break;
default:
tempChar = inputChar;
state = 66;
}
}
if(state == 66)
{
inputChar = getNextChar(pBuffer, pScr);
switch(inputChar)
{
case '\'':
state = 68;
break;
default:
state = 101;
}
}
if(state == 68)
{
aByte.attribute = CONST_CHAR;
aByte.value = (char *)malloc(2);
aByte.value[0] = tempChar;
aByte.value[1] = '\0';
goNextChar(pBuffer, pScr);
*pIsNeedFree = true;
return aByte;
}
if(state == 67)
{
inputChar = getNextChar(pBuffer, pScr);
if(inputChar == 't' || inputChar == 'n' || inputChar == '\\' || inputChar == '\"' || inputChar == '\'')
{
tempChar = inputChar;
state = 69;
}
else
{
state = 101;
}
}
if(state == 69)
{
inputChar = getNextChar(pBuffer, pScr);
if(inputChar == '\'')
{
aByte.attribute = CONST_CHAR;
switch(tempChar)
{
case 't':
aByte.value = "\\t";
break;
case 'n':
aByte.value = "\\n";
break;
case '\\':
aByte.value = "\\";
break;
case '\'':
aByte.value = "\'";
break;
case '\"':
aByte.value = "\"";
break;
}
goNextChar(pBuffer, pScr);
return aByte;
}
else
{
state = 101;
}
}
////////////////////////////////////////////////////////////
if(state == 65)
{
fputs("CONST_STR ", pDes);
inputChar = getNextChar(pBuffer, pScr);
if(inputChar != '\"')
fputc(inputChar, pDes);
while(inputChar != '\"')
{
inputChar = getNextChar(pBuffer, pScr);
if(inputChar == '\\')
{
fputc(*(pFinal + 1), pDes);
goNextChar(pBuffer, pScr);
continue;
}
if(inputChar != '\"')
fputc(inputChar, pDes);
}
fputc('\n', pDes);
goNextChar(pBuffer, pScr);
aByte.attribute = EMPTY;
aByte.value = "EMPTY";
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 99)
{
aByte.attribute = EMPTY;
aByte.value = "EMPTY";
end = true;
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 100)
{
aByte.attribute = EMPTY;
aByte.value = "EMPTY";
goNextChar(pBuffer, pScr);
return aByte;
}
////////////////////////////////////////////////////////////
if(state == 101)
{
aByte.attribute = EMPTY;
aByte.value = "EMPTY";
doError();
return aByte;
}
}
char getNextChar(char* pBuffer, FILE* pScr)
{
char ch;
if((pFinal + 1) == pBuffer + BUFFERSIZE)
{
loadFromFileToBuffer(pScr, pSecHalf, BUFFERSIZE);
pFinal ++;
}
else if((pFinal + 1) == pBuffer + 2 * BUFFERSIZE)
{
loadFromFileToBuffer(pScr, pFstHalf, BUFFERSIZE);
pFinal = pBuffer;
}
else
{
pFinal ++;
}
ch = *pFinal;
return ch;
}
void goNextChar(char* pBuffer, FILE* pScr)
{
if((pFinal + 1) == pBuffer + BUFFERSIZE)
{
loadFromFileToBuffer(pScr, pSecHalf, BUFFERSIZE);
pFinal ++;
}
else if((pFinal + 1) == pBuffer + 2 * BUFFERSIZE)
{
loadFromFileToBuffer(pScr, pFstHalf, BUFFERSIZE);
pFinal = pBuffer;
}
else
{
pFinal ++;
}
}
void backPoint(char* pBuffer)
{
if(pFinal == pBuffer)
{
pFinal = pBuffer + 2 * BUFFERSIZE - 1;
}
else
{
pFinal --;
}
}
void setValue(char* pBuffer, char* value)
{
int i;
char* pChar;
int n;
pChar = pBegin;
if(pFinal > pBegin)
{
n = pFinal - pBegin;
}
else
{
n = (2 * BUFFERSIZE) - (pBegin - pFinal);
}
for(i=0; i<n; i++)
{
*value = *pChar;
value ++;
pChar ++;
if(pChar == pBuffer + 2 * BUFFERSIZE)
{
pChar = pBuffer;
}
}
*value = '\0';
}
bool judgeKey(char* strKey)
{
int i;
for(i=0; i<KEYNUM; i++)
{
if(strcmp(strKey, keyword[i]) == 0)
{
return true;
}
}
return false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -