?? casl_tab.c
字號:
/* A Bison parser, made from casl.y with Bison version GNU Bison version 1.24
*/
#define YYBISON 1 /* Identify Bison output. */
#define NEW_LINE 258
#define CASL_DECIMAL 259
#define HEX 260
#define ID 261
#define STR 262
#define LABEL 263
#define DS 264
#define DC 265
#define GR0 266
#define GR1 267
#define GR2 268
#define GR3 269
#define GR4 270
#define LD 271
#define ST 272
#define LEA 273
#define ADD 274
#define SUB 275
#define AND 276
#define OR 277
#define EOR 278
#define CPA 279
#define CPL 280
#define SLA 281
#define SRA 282
#define SLL 283
#define SRL 284
#define JMP 285
#define JPZ 286
#define JMI 287
#define JNZ 288
#define JZE 289
#define PUSH 290
#define POP 291
#define CALL 292
#define RET 293
#define START 294
#define END 295
#define CASL_YACC_IN 296
#define CASL_YACC_OUT 297
#define EXIT 298
#line 1 "casl.y"
#include <windows.h>
#include <math.h>
#include <malloc.h>
#include <stdlib.h>
#include <algorithm>
#include "../Common/GlobalVariableDef.h"
#include "../Common/FileMapping.h"
LPVOID l;
//Casl.l中定義的存放當前編譯的源文件行號的全局變量的外部引用聲明!
extern int g_iLineNumber;
//--------------------標識當前編譯過程中有沒有發現錯誤------------------------------------
bool g_bCompilingErr = false;
//-------------當前的寄存器編號(0, 1, 2, 3, 4)--------------------------
int g_iCurrentRegNumber;
//-------------當前EA使用的變址寄存器的編號(0, 1, 2, 3, 4)--------------
int g_iCurrentEARegNumber;
//-------------當前被解析的指令的序號(從零開始)-------------------------
int g_lCurrentParseCodeNumber = 0;
//----------------------當前的有效地址操作數中的相對地址數據-----------------
EAAddress g_currentEAAddress;
//-----------------------當前的字符串常量-------------------------------------
string g_strCurrentStrConst;
//-----------------------當前的標號名稱 -------------------------------------
string g_strCurrentLabel;
//-----------------------當前的常量-------------------------------------------
CaslConst g_currentConst;
//-------------------------標號表----------------------------------------------
//表中的每一個元素都是一個Map
//以標號名稱 (string類型)為標號的Key
//標號所對應的指令的位置(long)為value
LabelMap g_mapLabel;
//-------------------------生成中間代碼過程中使用的臨時中間代碼變量-------------
IntermediateCode g_tempCode;
//------存放編譯過程中發現的錯誤信息-----------------------
vector<CompilingErrMsg> g_vecErrMsg;
//-----存放編譯過程中僅能發現但未識別具體性質的錯誤-------------------------
vector<CompilingErrMsg> g_verUnknownErrMsg;
int yyerror(char *s);
int yylex(void);
void showErrMsg(char *s);
char g_szErrMsg[200];
CompilingErrMsg g_tmpErrMsg;
#ifndef YYLTYPE
typedef
struct yyltype
{
int timestamp;
int first_line;
int first_column;
int last_line;
int last_column;
char *text;
}
yyltype;
#define YYLTYPE yyltype
#endif
#ifndef YYSTYPE
#define YYSTYPE int
#endif
#include <stdio.h>
#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif
#define YYFINAL 219
#define YYFLAG -32768
#define YYNTBASE 45
#define YYTRANSLATE(x) ((unsigned)(x) <= 298 ? yytranslate[x] : 120)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 44, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
36, 37, 38, 39, 40, 41, 42, 43
};
#if YYDEBUG != 0
static const short yyprhs[] = { 0,
0, 5, 8, 12, 15, 16, 19, 21, 23, 25,
27, 29, 31, 33, 35, 37, 39, 41, 42, 46,
48, 50, 55, 60, 62, 64, 66, 68, 70, 72,
74, 76, 83, 86, 88, 89, 91, 93, 95, 97,
99, 102, 104, 106, 108, 111, 112, 114, 116, 118,
120, 122, 123, 131, 132, 140, 142, 144, 145, 153,
154, 162, 164, 166, 168, 169, 177, 178, 186, 187,
195, 197, 199, 201, 203, 205, 207, 208, 216, 217,
225, 226, 234, 235, 243, 244, 252, 253, 261, 263,
265, 267, 269, 271, 272, 278, 279, 285, 286, 292,
293, 299, 300, 306, 308, 310, 311, 317, 318, 324,
326, 328, 329, 335, 336, 341, 343, 345, 347, 348,
353, 354, 362, 363
};
static const short yyrhs[] = { 39,
47, 40, 46, 0, 39, 47, 0, 47, 40, 46,
0, 3, 46, 0, 0, 48, 47, 0, 48, 0,
55, 0, 67, 0, 72, 0, 79, 0, 92, 0,
103, 0, 108, 0, 113, 0, 54, 0, 50, 0,
0, 1, 49, 3, 0, 51, 0, 52, 0, 57,
9, 4, 3, 0, 57, 10, 53, 3, 0, 5,
0, 4, 0, 8, 0, 7, 0, 3, 0, 56,
0, 65, 0, 63, 0, 57, 16, 58, 44, 59,
3, 0, 8, 3, 0, 8, 0, 0, 11, 0,
12, 0, 13, 0, 14, 0, 15, 0, 60, 61,
0, 4, 0, 8, 0, 5, 0, 44, 62, 0,
0, 11, 0, 12, 0, 13, 0, 14, 0, 15,
0, 0, 57, 64, 17, 58, 44, 59, 3, 0,
0, 57, 66, 18, 58, 44, 59, 3, 0, 68,
0, 70, 0, 0, 57, 69, 19, 58, 44, 59,
3, 0, 0, 57, 71, 20, 58, 44, 59, 3,
0, 73, 0, 75, 0, 77, 0, 0, 57, 74,
21, 58, 44, 59, 3, 0, 0, 57, 76, 22,
58, 44, 59, 3, 0, 0, 57, 78, 23, 58,
44, 59, 3, 0, 80, 0, 82, 0, 84, 0,
86, 0, 88, 0, 90, 0, 0, 57, 81, 24,
58, 44, 59, 3, 0, 0, 57, 83, 25, 58,
44, 59, 3, 0, 0, 57, 85, 26, 58, 44,
59, 3, 0, 0, 57, 87, 27, 58, 44, 59,
3, 0, 0, 57, 89, 28, 58, 44, 59, 3,
0, 0, 57, 91, 29, 58, 44, 59, 3, 0,
93, 0, 95, 0, 97, 0, 99, 0, 101, 0,
0, 57, 94, 30, 59, 3, 0, 0, 57, 96,
31, 59, 3, 0, 0, 57, 98, 32, 59, 3,
0, 0, 57, 100, 33, 59, 3, 0, 0, 57,
102, 34, 59, 3, 0, 104, 0, 106, 0, 0,
57, 105, 35, 59, 3, 0, 0, 57, 107, 36,
58, 3, 0, 109, 0, 111, 0, 0, 57, 110,
37, 59, 3, 0, 0, 57, 112, 38, 3, 0,
114, 0, 116, 0, 118, 0, 0, 57, 115, 43,
3, 0, 0, 57, 117, 41, 8, 44, 8, 3,
0, 0, 57, 119, 42, 8, 44, 8, 3, 0
};
#endif
#if YYDEBUG != 0
static const short yyrline[] = { 0,
109, 110, 116, 123, 123, 124, 124, 126, 126, 127,
128, 129, 130, 131, 132, 133, 134, 135, 138, 144,
144, 147, 158, 176, 181, 186, 192, 200, 202, 202,
202, 204, 236, 240, 244, 250, 254, 258, 262, 266,
272, 278, 283, 294, 306, 310, 316, 320, 324, 328,
332, 338, 339, 362, 363, 385, 385, 388, 389, 410,
411, 432, 432, 432, 434, 435, 456, 457, 478, 479,
500, 500, 501, 502, 503, 504, 507, 508, 530, 531,
554, 555, 577, 578, 600, 601, 623, 624, 646, 646,
647, 648, 649, 651, 652, 673, 674, 695, 696, 717,
718, 739, 740, 761, 761, 763, 764, 785, 786, 806,
806, 808, 809, 830, 831, 851, 851, 851, 853, 854,
870, 871, 910, 911
};
static const char * const yytname[] = { "$","error","$undefined.","NEW_LINE",
"CASL_DECIMAL","HEX","ID","STR","LABEL","DS","DC","GR0","GR1","GR2","GR3","GR4",
"LD","ST","LEA","ADD","SUB","AND","OR","EOR","CPA","CPL","SLA","SRA","SLL","SRL",
"JMP","JPZ","JMI","JNZ","JZE","PUSH","POP","CALL","RET","START","END","CASL_YACC_IN",
"CASL_YACC_OUT","EXIT","','","PROGRAM","NEW_LINE_STMT","BODY","EXECSTMT","@1",
"DEFSTMT","DSDEF","DCDEF","CONST","EMPTYSTMT","MEMSTMT","LDSTMT","LBLSTMT","GR",
"EA","ADDR","XRADDR","XR","STSTMT","@2","LEASTMT","@3","MATHSTMT","ADDSTMT",
"@4","SUBSTMT","@5","LOGSTMT","ANDSTMT","@6","ORSTMT","@7","EORSTMT","@8","RELSTMT",
"CPASTMT","@9","CPLSTMT","@10","SLASTMT","@11","SRASTMT","@12","SLLSTMT","@13",
"SRLSTMT","@14","CONDSTMT","JMPSTMT","@15","JPZSTMT","@16","JMISTMT","@17","JNZSTMT",
"@18","JZESTMT","@19","STACKSTMT","PUSHSTMT","@20","POPSTMT","@21","PROCSTMT",
"CALLSTMT","@22","RETSTMT","@23","MACROSTMT","EXITSTMT","@24","INSTMT","@25",
"OUTSTMT","@26",""
};
#endif
static const short yyr1[] = { 0,
45, 45, 45, 46, 46, 47, 47, 48, 48, 48,
48, 48, 48, 48, 48, 48, 48, 49, 48, 50,
50, 51, 52, 53, 53, 53, 53, 54, 55, 55,
55, 56, 57, 57, 57, 58, 58, 58, 58, 58,
59, 60, 60, 60, 61, 61, 62, 62, 62, 62,
62, 64, 63, 66, 65, 67, 67, 69, 68, 71,
70, 72, 72, 72, 74, 73, 76, 75, 78, 77,
79, 79, 79, 79, 79, 79, 81, 80, 83, 82,
85, 84, 87, 86, 89, 88, 91, 90, 92, 92,
92, 92, 92, 94, 93, 96, 95, 98, 97, 100,
99, 102, 101, 103, 103, 105, 104, 107, 106, 108,
108, 110, 109, 112, 111, 113, 113, 113, 115, 114,
117, 116, 119, 118
};
static const short yyr2[] = { 0,
4, 2, 3, 2, 0, 2, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 3, 1,
1, 4, 4, 1, 1, 1, 1, 1, 1, 1,
1, 6, 2, 1, 0, 1, 1, 1, 1, 1,
2, 1, 1, 1, 2, 0, 1, 1, 1, 1,
1, 0, 7, 0, 7, 1, 1, 0, 7, 0,
7, 1, 1, 1, 0, 7, 0, 7, 0, 7,
1, 1, 1, 1, 1, 1, 0, 7, 0, 7,
0, 7, 0, 7, 0, 7, 0, 7, 1, 1,
1, 1, 1, 0, 5, 0, 5, 0, 5, 0,
5, 0, 5, 1, 1, 0, 5, 0, 5, 1,
1, 0, 5, 0, 4, 1, 1, 1, 0, 4,
0, 7, 0, 7
};
static const short yydefact[] = { 0,
18, 28, 34, 0, 0, 0, 17, 20, 21, 16,
8, 29, 52, 31, 30, 9, 56, 57, 10, 62,
63, 64, 11, 71, 72, 73, 74, 75, 76, 12,
89, 90, 91, 92, 93, 13, 104, 105, 14, 110,
111, 15, 116, 117, 118, 0, 33, 2, 5, 6,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 19, 5,
5, 3, 0, 25, 24, 27, 26, 0, 36, 37,
38, 39, 40, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
4, 22, 23, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 42, 44, 43,
0, 46, 0, 0, 0, 0, 0, 0, 0, 115,
120, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 95, 0, 41,
97, 99, 101, 103, 107, 109, 113, 0, 0, 32,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 47, 48, 49, 50, 51, 45, 0,
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -