📄 _vs1.0_lexer.cpp
字号:
YY_BREAK
case 9:
YY_RULE_SETUP
#line 344 "vs1.0_tokens.l"
{
// fprintf( stderr, "%s", yytext );
vs10_lval.reg.type = TYPE_FOG_RESULT_REG;
if ( yytext[yyleng-1] == '\n' )
line_incr = 1;
return REGISTER;
}
YY_BREAK
case 10:
YY_RULE_SETUP
#line 352 "vs1.0_tokens.l"
{
// fprintf( stderr, "%s", yytext );
vs10_lval.reg.type = TYPE_POSITION_RESULT_REG;
if ( yytext[yyleng-1] == '\n' )
line_incr = 1;
return REGISTER;
}
YY_BREAK
case 11:
YY_RULE_SETUP
#line 360 "vs1.0_tokens.l"
{
// fprintf( stderr, "%s", yytext );
vs10_lval.reg.type = TYPE_POINTS_RESULT_REG;
if ( yytext[yyleng-1] == '\n' )
line_incr = 1;
return REGISTER;
}
YY_BREAK
case 12:
YY_RULE_SETUP
#line 368 "vs1.0_tokens.l"
{
unsigned int offset;
offset = strcspn(yytext, " \t\n_");
yyless(offset);
OPCODEMAP *opcodeMap = FindOpcode(yytext);
if ( opcodeMap != NULL )
{
// fprintf( stderr, "%s\t", opcodeMap->string );
return( opcodeMap->tokenName );
}
else
{
gTempParseMacro = FindMacro(yytext);
if (gTempParseMacro != NULL)
{
if (gIncludeStackIndex >= MAX_INCLUDE_DEPTH )
{
LexError("macros nested too deeply");
exit( 1 );
}
if (gTempParseMacro->firstMacroLines != NULL)
{
gTempMacro = (MACROENTRY *)malloc(sizeof(MACROENTRY));
if (gTempMacro == NULL)
{
LexError("Out of memory allocating MACROENTRY structure.\n");
}
else
{
gTempMacro->next = NULL;
gTempMacro->prev = NULL;
gTempMacro->macroName = NULL;
gTempMacro->firstMacroParms = NULL;
gTempMacro->lastMacroParms = NULL;
gTempMacro->firstMacroLines = NULL;
gTempMacro->lastMacroLines = NULL;
gTempMacro->numParms = 0;
gTempMacro->nLines = 0;
gbTempInsideMacro = true; // flag we are currently doing a macro replace.
gInvokeState = YYSTATE;
if (gTempParseMacro->numParms > 0)
{
BEGIN(MACROPARMSTART);
}
else
{
EndMacroParms();
gbTempInsideMacro = false; // no longer waiting for macro invocation
}
}
}
}
else
{
// fprintf( stderr, "Opcode: \"%s\" not found\n", yytext );
REJECT;
}
}
//unsigned int offset;
//
//INSTRMAP *opcodeMap;
//
//offset = strcspn(yytext, " \t\n_");
//yyless(offset);
//opcodeMap = FindInstruction(yytext);
//if (opcodeMap == NULL)
//{
// REJECT;
//}
//
//yylval.opcodeInfo.opcodeMap = opcodeMap;
//
//return OPCODE;
}
YY_BREAK
case 13:
YY_RULE_SETUP
#line 455 "vs1.0_tokens.l"
{
// fprintf( stderr, "%s", yytext );
char *cmt = new char[yyleng+1];
strncpy( cmt, yytext, yyleng );
cmt[0] = '#';
cmt[yyleng] = '\0';
vs10_lval.comment = cmt;
return COMMENT;
}
YY_BREAK
case 14:
YY_RULE_SETUP
#line 465 "vs1.0_tokens.l"
{
// fprintf( stderr, "%s", yytext );
char *cmt = new char[yyleng+1];
strncpy( cmt+1, yytext+1, yyleng-1 );
cmt[0] = '#';
cmt[1] = ' ';
cmt[yyleng] = '\0';
vs10_lval.comment = cmt;
return COMMENT;
}
YY_BREAK
case 15:
YY_RULE_SETUP
#line 476 "vs1.0_tokens.l"
{
fprintf( stderr, "COISSUE found\n" );
yyless(yyleng-1);
//return COISSUE;
}
YY_BREAK
case 16:
YY_RULE_SETUP
#line 482 "vs1.0_tokens.l"
{
fprintf( stderr, "COISSUE found\n" );
//return COISSUE;
}
YY_BREAK
case 17:
YY_RULE_SETUP
#line 487 "vs1.0_tokens.l"
{
gCommentStartLine = yylineno;
yyless(0);
BEGIN(EATCOMMENT);
}
YY_BREAK
case 18:
YY_RULE_SETUP
#line 493 "vs1.0_tokens.l"
{
BEGIN(INCLUDE);
}
YY_BREAK
case 19:
YY_RULE_SETUP
#line 497 "vs1.0_tokens.l"
{ /* got the include file name */
// FILE *newyyin;
char *newyyin;
char incFileName[1024];
unsigned long sLen;
bool validFileName;
if ( gIncludeStackIndex >= MAX_INCLUDE_DEPTH )
{
LexError("Includes nested too deeply, aborting\n");
exit( 1 );
}
// GenDebugLine();
// GenListString();
yylineno++;
gLinesAssembled++;
validFileName = true;
// zap "" and <>
if ((yytext[0] == '"') || (yytext[0] == '<'))
{
char *endQuote;
endQuote = strchr(&yytext[1], yytext[0]);
sLen = (endQuote - yytext)-1;
if (endQuote == NULL)
{
LexError("Unable to open include file %s\n", incFileName);
BEGIN(INITIAL);
validFileName = false;
}
else
{
incFileName[0] ='\0';
strncat(incFileName, &yytext[1], sLen);
}
}
else
{
strcpy(incFileName, yytext);
}
if (validFileName)
{
sLen = strlen(incFileName);
if ((incFileName[sLen-1] == '"') || (incFileName[sLen-1] == '>'))
{
incFileName[sLen-1] = '\0';
}
newyyin = ReadTextFile( incFileName );
// newyyin = fopen( incFileName, "r" );
if ( ! newyyin )
{
LexError("Unable to open include file %s\n", incFileName);
BEGIN(SAVELINE);
}
else
{
gIncludeStack[gIncludeStackIndex].fileName = gCurFileName;
gIncludeStack[gIncludeStackIndex].lineNo = yylineno;
// gIncludeStack[gIncludeStackIndex].fileHandle = yyin;
gIncludeStack[gIncludeStackIndex].prevString = myin;
gIncludeStack[gIncludeStackIndex].nextString = newyyin;
gIncludeStack[gIncludeStackIndex].lastInvokeMacro = gInvokeMacro;
gIncludeStack[gIncludeStackIndex].lastParseMacro = gParseMacro;
gIncludeStack[gIncludeStackIndex].lastMacroLineParse = gMacroLineParse;
gIncludeStack[gIncludeStackIndex].lastbInsideMacro = gbInsideMacro;
gIncludeStack[gIncludeStackIndex].lastbInsideInclude = gbInsideInclude;
gIncludeStack[gIncludeStackIndex].buffer = YY_CURRENT_BUFFER;
gIncludeStack[gIncludeStackIndex].lastbProcessingIFDEF = gbProcessingIFDEF;
gIncludeStackIndex++;
gbProcessingIFDEF = false;
gCurFileName = strdup(incFileName);
// yyin = newyyin;
myin = newyyin;
// GenSwitchFileNames(gCurFileName);
yylineno = 1;
yy_switch_to_buffer(yy_create_buffer( yyin, YY_BUF_SIZE ) );
gbInsideInclude = true;
BEGIN(SAVELINE);
}
}
}
YY_BREAK
case YY_STATE_EOF(EATCOMMENT):
#line 592 "vs1.0_tokens.l"
{
LexError("End of file reached before end of comment started on line %d.\n", gCommentStartLine);
BEGIN(INITIAL);
}
YY_BREAK
case 20:
YY_RULE_SETUP
#line 597 "vs1.0_tokens.l"
{
char *endComment;
unsigned int keepSize;
strcpy(gSaveLine, yytext);
endComment = strstr(yytext, "*/");
char *cmt;
if (endComment != NULL)
{
keepSize = (endComment - yytext+2);
yyless(keepSize);
BEGIN(INITIAL);
if ( yytext[0] == '/' && yytext[1] == '*' )
{
cmt = new char[yyleng];
strncpy( cmt+3, yytext+2, yyleng-2 );
cmt[0] = '#';
cmt[1] = ' ';
cmt[2] = ' ';
cmt[yyleng-1] = '\0';
}
else
{
cmt = new char[yyleng];
strncpy( cmt+1, yytext, yyleng-2 );
cmt[0] = '#';
cmt[yyleng-1] = '\0';
}
vs10_lval.comment = cmt;
return COMMENT;
}
else
{
// GenDebugLine();
// GenListString();
gLinesAssembled++;
yylineno++;
if ( yytext[0] == '/' && yytext[1] == '*' )
{
cmt = new char[yyleng+2];
strncpy( cmt+3, yytext+2, yyleng-2 );
cmt[0] = '#';
cmt[1] = ' ';
cmt[2] = ' ';
cmt[yyleng+1] = '\0';
}
else
{
cmt = new char[yyleng+2];
strncpy( cmt+1, yytext, yyleng );
cmt[0] = '#';
cmt[yyleng+1] = '\0';
}
vs10_lval.comment = cmt;
return COMMENT;
}
}
YY_BREAK
case YY_STATE_EOF(DEFSTR):
#line 658 "vs1.0_tokens.l"
{
LexError("#define was incomplete before end of file\n");
BEGIN(INITIAL);
}
YY_BREAK
case YY_STATE_EOF(DEFINE):
#line 663 "vs1.0_tokens.l"
{
LexError("#define was incomplete before end of file\n");
BEGIN(INITIAL);
}
YY_BREAK
case YY_STATE_EOF(DEFSPACE):
#line 668 "vs1.0_tokens.l"
{
LexError("#define was incomplete before end of file\n");
BEGIN(INITIAL);
}
YY_BREAK
case YY_STATE_EOF(INCLUDE):
#line 673 "vs1.0_tokens.l"
{
LexError("#include was incomplete before end of file\n");
BEGIN(INITIAL);
}
YY_BREAK
case YY_STATE_EOF(MACROBODY):
#line 678 "vs1.0_tokens.l"
{
LexError("End of file reached before end of #define or endm was found, macro started on line %d.\n", gMacroStartLine);
BEGIN(INITIAL);
}
YY_BREAK
case YY_STATE_EOF(IFDEFBODY):
#line 683 "vs1.0_tokens.l"
{
LexError("End of file reached before #endif found, macro started on line %d.\n", gIfDefStartLine);
BEGIN(INITIAL);
}
YY_BREAK
case 21:
YY_RULE_SETUP
#line 688 "vs1.0_tokens.l"
{
LexError("#define was incomplete before end of line\n");
BEGIN(SAVELINE);
// GenDebugLine();
// GenListString();
gLinesAssembled++;
yylineno++;
}
YY_BREAK
case 22:
YY_RULE_SETUP
#line 697 "vs1.0_tokens.l"
{
LexError("#define was incomplete before end of line\n");
BEGIN(SAVELINE);
// GenDebugLine();
// GenListString();
gLinesAssembled++;
yylineno++;
}
YY_BREAK
case 23:
YY_RULE_SETUP
#line 706 "vs1.0_tokens.l"
{
LexError("#define was incomplete before end of line\n");
BEGIN(SAVELINE);
// GenDebugLine();
// GenListString();
gLinesAssembled++;
yylineno++;
}
YY_BREAK
case 24:
YY_RULE_SETUP
#line 715 "vs1.0_tokens.l"
{
if (gIfDefStackIndex >= MAX_IFDEF_DEPTH)
{
LexError("Out of stack space for #ifdef, aborting.\n");
exit( 1 );
}
else
{
gIfDefStack[gIfDefStackIndex].lastbProcessingIFDEF = gbProcessingIFDEF;
gIfDefStack[gIfDefStackIndex].lastbIFDEF = gbIFDEF;
gIfDefStack[gIfDefStackIndex].lastbCompareDefine = gbCompareDefine;
gIfDefStack[gIfDefStackIndex].lastIfDefStartLine = gIfDefStartLine;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -