📄 lexer.c
字号:
// break;
// case R_CIF:
// ImageType=IT_CIF;
// break;
// case R_QCIF:
// ImageType=IT_QCIF;
// break;
// default:
// WHEREAMI();
// printf("Illegal token type encountered: %d\n",token);
// break;
// }
// }
//}
/*BFUNC
PrintProgram() prints out a program that is loaded as current.
EFUNC*/
//static void PrintProgram()
//{
// BEGIN("PrintProgram");
// int i;
//
// for(i=0;i<PLevel;i++)
// {
// switch(PCStack[i])
// {
// case R_ADD:
// case R_SUB:
// case R_MUL:
// case R_DIV:
//
// case R_NOT:
// case R_AND:
// case R_OR:
// case R_XOR:
// case R_LT:
// case R_LTE:
// case R_EQ:
// case R_GT:
// case R_GTE:
//
// case R_NEG:
// case R_SQRT:
// case R_ABS:
// case R_FLOOR:
// case R_CEIL:
// case R_ROUND:
//
// case R_DUP:
// case R_POP:
// case R_EXCH:
// case R_CLEAR:
// case R_EXIT:
// case R_PRINTSTACK:
// case R_PRINTIMAGE:
// case R_PRINTFRAME:
// printf("%d: %s\n",
// i,
// ReservedWords[PCStack[i]-1]);
// break;
// case R_COPY:
// case R_INDEX:
// case R_STO:
// case R_RCL:
// case R_EXE:
// case R_ABORT:
// case R_PRINTPROGRAM:
// printf("%d: %s %d\n",
// i,
// ReservedWords[PCStack[i]-1],
// PCStack[i+1]);
// i++;
// break;
// case R_ROLL:
// printf("%d: %s %d %d\n",
// i,
// ReservedWords[PCStack[i]-1],
// PCStack[i+1],
// PCStack[i+2]);
// i+=2;
// break;
// case R_GOTO:
// case R_IFG:
// case R_IFNG:
// printf("%d: %s %d\n",
// i,
// ReservedWords[PCStack[i]-1],
// PCStack[i+1]);
// i++;
// break;
// case R_VAL:
// printf("%d: %s %f\n",
// i,
// ReservedWords[PCStack[i]-1],
// PLStack[PCStack[i+1]]);
// i++;
// break;
// case R_ECHO:
// case R_OPEN:
// case R_CLOSE:
// case R_EQU:
// case R_STREAMNAME:
// case R_COMPONENT:
// case R_FRAMERATE:
// case R_FRAMESKIP:
// case R_QUANTIZATION:
// case R_SEARCHLIMIT:
// case R_NTSC:
// case R_CIF:
// case R_QCIF:
// WHEREAMI();
// printf("Top-level token occurring in program: %s.\n",
// ReservedWords[PCStack[i]-1]);
// break;
// default:
// WHEREAMI();
// printf("Bad token type %d\n",PCStack[i]);
// break;
// }
// }
//}
/*BFUNC
MakeProgram() makes a program from the input from mylex().
EFUNC*/
//static void MakeProgram()
//{
// BEGIN("MakeProgram");
// int ntoken;
//
// while((ntoken=mylex())!= R_CLOSE)
// {
// switch(ntoken)
// {
// case 0:
// exit(-1);
// break;
// case R_ADD:
// case R_SUB:
// case R_MUL:
// case R_DIV:
//
// case R_NOT:
// case R_AND:
// case R_OR:
// case R_XOR:
// case R_LT:
// case R_LTE:
// case R_EQ:
// case R_GT:
// case R_GTE:
//
// case R_NEG:
// case R_SQRT:
// case R_ABS:
// case R_FLOOR:
// case R_CEIL:
// case R_ROUND:
//
// case R_DUP:
// case R_POP:
// case R_EXCH:
// case R_CLEAR:
//
// case R_EXIT:
// case R_PRINTSTACK:
// case R_PRINTIMAGE:
// case R_PRINTFRAME:
// PCStack[PLevel++] = ntoken;
// break;
// case R_COPY:
// case R_INDEX:
// case R_STO:
// case R_RCL:
// case R_EXE:
// case R_ABORT:
// case R_PRINTPROGRAM:
// PCStack[PLevel++] = ntoken;
// ntoken = mylex();
// if ((ntoken==R_INTEGER)||(ntoken==R_ID))
// {
// PCStack[PLevel++] = yyint;
// }
// else
// {
// PCStack[PLevel++] = 0;
// printf("Integer expected.\n");
// }
// break;
// case R_ROLL:
// PCStack[PLevel++] = ntoken;
// ntoken = mylex();
// if ((ntoken==R_INTEGER)||(ntoken==R_ID))
// {
// PCStack[PLevel++] = yyint;
// }
// else
// {
// PCStack[PLevel++] = 0;
// printf("Integer expected.\n");
// }
// ntoken = mylex();
// if ((ntoken==R_INTEGER)||(ntoken==R_ID))
// {
// PCStack[PLevel++] = yyint;
// }
// else
// {
// PCStack[PLevel++] = 0;
// printf("Integer expected.\n");
// }
// break;
// case R_GOTO:
// case R_IFG:
// case R_IFNG:
// PCStack[PLevel++] = ntoken;
// ntoken = mylex();
// if (ntoken==R_ID)
// {
// LabelStack[LabelLevel] = Cid;
// PCStack[PLevel++] = LabelLevel++;
// }
// else
// {
// printf("Id expected.\n");
// }
// break;
// case R_VAL:
// PCStack[PLevel++] = ntoken;
// PLStack[PLLevel]=(double) *(--DataPtr); /* Take from Top of stack */
// DataLevel--;
// PCStack[PLevel++] = PLLevel++;
// break;
// case R_INTEGER:
// PCStack[PLevel++] = R_VAL;
// PLStack[PLLevel]=(double) yyint;
// PCStack[PLevel++] = PLLevel++;
// break;
// case R_REAL:
// PCStack[PLevel++] = R_VAL;
// PLStack[PLLevel] = atof(yytext);
// PCStack[PLevel++] = PLLevel++;
// break;
// case R_ID:
// if (Cid->value>=0)
// {
// WHEREAMI();
// printf("Attempt to redefine label.\n");
// break;
// }
// Cid->value = PLevel;
// break;
// default:
// WHEREAMI();
// printf("Token type %d not allowed in programs.\n",ntoken);
// break;
// }
// }
//}
/*BFUNC
CompileProgram() assigns values to the labels in a program.
EFUNC*/
//static void CompileProgram()
//{
// BEGIN("CompileProgram");
// int i;
//
// for(i=0;i<PLevel;i++)
// {
// switch(PCStack[i])
// {
// case R_ADD:
// case R_SUB:
// case R_MUL:
// case R_DIV:
//
// case R_NOT:
// case R_AND:
// case R_OR:
// case R_XOR:
// case R_LT:
// case R_LTE:
// case R_EQ:
// case R_GT:
// case R_GTE:
//
// case R_NEG:
// case R_SQRT:
// case R_ABS:
// case R_FLOOR:
// case R_CEIL:
// case R_ROUND:
//
// case R_DUP:
// case R_POP:
// case R_EXCH:
// case R_CLEAR:
//
// case R_EXIT:
// case R_PRINTSTACK:
// case R_PRINTIMAGE:
// case R_PRINTFRAME:
// break;
// case R_COPY:
// case R_INDEX:
// case R_STO:
// case R_RCL:
// case R_EXE:
// case R_ABORT:
// case R_VAL:
// case R_PRINTPROGRAM:
// i++;
// break;
// case R_ROLL:
// i+=2;
// break;
// case R_GOTO:
// case R_IFG:
// case R_IFNG:
// i++;
// if (!LabelStack[PCStack[i]]->value)
// {
// printf("Bad reference to label!\n");
// break;
// }
// PCStack[i] = LabelStack[PCStack[i]]->value;
// break;
// default:
// WHEREAMI();
// printf("Invalid program compilation token: %d.\n",PCStack[i]);
// break;
// }
// }
//}
/*BFUNC
mylex() reads either from the yylex() routine or from the currently
active program depending on what source is active.
EFUNC*/
//static int mylex()
//{
// BEGIN("mylex");
// int token;
//
// while(1)
// {
// if (!SourceLevel)
// {
// return(yylex());
// }
// token = CommandStack[CurrentLine++];
///*
// printf("Token:%d CommandStack:%x CurrentLine:%d\n",
// token,CommandStack,CurrentLine-1);
//*/
// if (NextVal)
// {
// NextVal--;
// yyint = token;
// return(R_INTEGER);
// }
// switch(token)
// {
// case 0:
// printf("Abnormal break at: %d\n",CurrentLine);
// popprogram();
// break;
// case R_VAL:
// pushdata(LocalStack[CommandStack[CurrentLine++]]);
// break;
// case R_GOTO:
// CurrentLine = CommandStack[CurrentLine];
// break;
// case R_IFG:
// DataLevel--;
// if (*(--DataPtr))
// {
// CurrentLine = CommandStack[CurrentLine];
// }
// else CurrentLine++;
// break;
// case R_IFNG:
// DataLevel--;
// if (!(*(--DataPtr)))
// {
// CurrentLine = CommandStack[CurrentLine];
// }
// else CurrentLine++;
// break;
// case R_EXIT:
// popprogram();
// break;
// case R_COPY:
// case R_INDEX:
// case R_STO:
// case R_RCL:
// case R_EXE:
// case R_ABORT:
// case R_PRINTPROGRAM:
// NextVal = 1; /* Notify to take the next integer straight */
// return(token);
// break;
// case R_ROLL:
// NextVal = 2;
// return(token);
// break;
// default:
// return(token);
// break;
// }
// }
//}
/*BFUNC
Execute() calls the program interpreter to execute a particular
program location.
EFUNC*/
//void Execute(int pnum)
//{
// BEGIN("Execute");
//
// if (ProgramLevel[pnum])
// {
// pushprogram(pnum,0);
// parser();
// }
//}
/*NOPROTO*/
/*END*/
int yyvstop[] ={
0,
15,
0,
1,
15,
0,
1,
0,
15,
0,
15,
0,
15,
0,
15,
0,
15,
0,
4,
15,
0,
4,
15,
0,
4,
15,
0,
2,
15,
0,
2,
15,
0,
10,
15,
0,
11,
15,
0,
16,
0,
16,
0,
16,
0,
12,
0,
4,
0,
4,
0,
4,
0,
3,
0,
13,
0,
3,
0,
4,
0,
4,
0,
8,
0,
6,
0,
8,
0,
8,
0,
2,
0,
2,
0,
2,
0,
2,
6,
0,
14,
0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -