Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1th #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Lab/Code/lexical.l
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ illID {digit}({letter_}|{digit})*
";" {yylval=create_node(_SEMI);yylval->line=yylineno;return SEMI;}
"," {yylval=create_node(_COMMA);yylval->line=yylineno;return COMMA;}
"=" {yylval=create_node(_ASSIGNOP);yylval->line=yylineno;return ASSIGNOP;}
">"|"<"|">="|"<="|"=="|"!=" {yylval=create_node(_RELOP);yylval->line=yylineno;return RELOP;}
">" {yylval=create_node(_GT);yylval->line=yylineno;return GT;}
"<" {yylval=create_node(_LT);yylval->line=yylineno;return LT;}
"==" {yylval=create_node(_EQ);yylval->line=yylineno;return EQ;}
">=" {yylval=create_node(_GE);yylval->line=yylineno;return GE;}
"<=" {yylval=create_node(_LE);yylval->line=yylineno;return LE;}
"!=" {yylval=create_node(_NE);yylval->line=yylineno;return NE;}
"+" {yylval=create_node(_PLUS);yylval->line=yylineno;return PLUS;}
"-" {yylval=create_node(_MINUS);yylval->line=yylineno;return MINUS;}
"*" {yylval=create_node(_STAR);yylval->line=yylineno;return STAR;}
Expand All @@ -49,6 +54,8 @@ illID {digit}({letter_}|{digit})*
"if" {yylval=create_node(_IF);yylval->line=yylineno;return IF;}
"else" {yylval=create_node(_ELSE);yylval->line=yylineno;return ELSE;}
"while" {yylval=create_node(_WHILE);yylval->line=yylineno;return WHILE;}
"for" {yylval=create_node(_FOR);yylval->line=yylineno;return FOR;}
"do" {yylval=create_node(_DO);yylval->line=yylineno;return DO;}
{int} {yylval=create_node(_INT);yylval->line=yylineno;yylval->value_i=get_value(yytext);return INT;}
{float} {yylval=create_node(_FLOAT);yylval->line=yylineno;yylval->value_f=strtof(yytext,NULL);return FLOAT;}
{id} {yylval=create_node(_ID);yylval->line=yylineno;strcpy(yylval->name,yytext);return ID;}
Expand All @@ -69,4 +76,4 @@ int get_value(const char* p)
value=strtol(p,NULL,16);
else value=strtol(p,NULL,8);
return (int)value;
}
}
133 changes: 71 additions & 62 deletions Lab/Code/syntax.y
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
#endif
#define YYERROR_VERBOSE 1
Node* head=NULL;
int yyerror(const char* msg);
void m_yyerror(char* msg,int lineno);
char message[100];
%}
%locations
/*1 Tokens*/
%token SEMI COMMA ASSIGNOP RELOP
%token SEMI COMMA ASSIGNOP GT LE LT EQ NE GE
%token PLUS MINUS STAR DIV
%token AND OR DOT NOT TYPE
%token LP RP LB RB LC RC
%token STRUCT RETURN IF ELSE WHILE
%token STRUCT RETURN IF ELSE WHILE FOR DO
%token ID INT FLOAT
/*优先级,结合性*/
%nonassoc LOWER_THAN_ELSE
Expand All @@ -34,10 +35,10 @@ Program : ExtDefList {$$=create_node(Program);construct($$,1,$1);head=$$;}
ExtDefList : ExtDef ExtDefList {$$=create_node(ExtDefList);construct($$,2,$1,$2);}
| /* empty */ {$$=create_node(ExtDefList);construct($$,1,create_node(None));}
;
ExtDef : Specifier ExtDecList SEMI {$$=create_node(ExtDef);construct($$,3,$1,$2,$3);}
| Specifier SEMI {$$=create_node(ExtDef);construct($$,2,$1,$2);}
| Specifier FunDec CompSt {$$=create_node(ExtDef);construct($$,3,$1,$2,$3);}
| Specifier error SEMI {$$=create_node(ExtDef);construct($$,3,$1,create_node(None),$3);
ExtDef : TypeSpecifier ExtDecList SEMI {$$=create_node(ExtDef);construct($$,3,$1,$2,$3);}
| TypeSpecifier SEMI {$$=create_node(ExtDef);construct($$,2,$1,$2);}
| TypeSpecifier FunDec CompSt {$$=create_node(ExtDef);construct($$,3,$1,$2,$3);}
| TypeSpecifier error SEMI {$$=create_node(ExtDef);construct($$,3,$1,create_node(None),$3);
m_yyerror("something wrong with ExtDecList before \";\"",@2.last_line);}
| error SEMI {$$=create_node(ExtDef);construct($$,2,create_node(None),$2);
m_yyerror("something wrong with Specifier before \";\"",@1.last_line);}
Expand All @@ -46,10 +47,10 @@ ExtDecList : VarDec {$$=create_node(ExtDecList);construct($$,1,$1);}
| VarDec COMMA ExtDecList {$$=create_node(ExtDecList);construct($$,3,$1,$2,$3);}
;
/*3 Specifiers*/
Specifier : TYPE {$$=create_node(Specifier);construct($$,1,$1);}
| StructSpecifier {$$=create_node(Specifier);construct($$,1,$1);}
TypeSpecifier : TYPE {$$=create_node(TypeSpecifier);construct($$,1,$1);}
| StructSpecifier {$$=create_node(TypeSpecifier);construct($$,1,$1);}
;
StructSpecifier : STRUCT OptTag LC DefList RC {$$=create_node(StructSpecifier);construct($$,5,$1,$2,$3,$4,$5);}
StructSpecifier : STRUCT OptTag LC VarDeclaration RC {$$=create_node(StructSpecifier);construct($$,5,$1,$2,$3,$4,$5);}
| STRUCT Tag {$$=create_node(StructSpecifier);construct($$,2,$1,$2);}
;
OptTag : ID {$$=create_node(OptTag);construct($$,1,$1);}
Expand All @@ -75,87 +76,95 @@ VarList : ParamDec COMMA VarList {$$=create_node(VarList);construct($$,3,$1,$2,$
| error COMMA VarList {$$=create_node(VarList);construct($$,3,create_node(None),$2,$3);
m_yyerror("something wrong with ParamDec",@1.last_line);}
;
ParamDec : Specifier VarDec {$$=create_node(ParamDec);construct($$,2,$1,$2);}
ParamDec : TypeSpecifier VarDec {$$=create_node(ParamDec);construct($$,2,$1,$2);}
;
/*5 Statements*/
CompSt : LC DefList StmtList RC {$$=create_node(CompSt);construct($$,4,$1,$2,$3,$4);}
CompSt : LC VarDeclaration StmtList RC {$$=create_node(CompSt);construct($$,4,$1,$2,$3,$4);}
| error RC {$$=create_node(CompSt);construct($$,2,create_node(None),$2);
m_yyerror("Missing \"{\"",@1.first_line);}
;
StmtList : Stmt StmtList {$$=create_node(StmtList);construct($$,2,$1,$2);}
| /* empty */ {$$=create_node(StmtList);construct($$,1,create_node(None));}
;
Stmt : Exp SEMI {$$=create_node(Stmt);construct($$,2,$1,$2);}
Stmt : Expr SEMI {$$=create_node(Stmt);construct($$,2,$1,$2);}
| error SEMI {$$=create_node(Stmt);construct($$,2,create_node(None),$2);
m_yyerror("something wrong with expression before \";\"",@1.last_line);}
| CompSt {$$=create_node(Stmt);construct($$,1,$1);}
| RETURN Exp SEMI {$$=create_node(Stmt);construct($$,3,$1,$2,$3);}
| RETURN Expr SEMI {$$=create_node(Stmt);construct($$,3,$1,$2,$3);}
| RETURN error SEMI {$$=create_node(Stmt);construct($$,3,$1,create_node(None),$3);
m_yyerror("something wrong with expression before \";\"",@2.last_line);}
| IF LP Exp RP Stmt %prec LOWER_THAN_ELSE {$$=create_node(Stmt);construct($$,5,$1,$2,$3,$4,$5);}
| IF LP Expr RP Stmt %prec LOWER_THAN_ELSE {$$=create_node(Stmt);construct($$,5,$1,$2,$3,$4,$5);}
| IF LP error RP Stmt %prec LOWER_THAN_ELSE{$$=create_node(Stmt);construct($$,5,$1,$2,create_node(None),$4,$5);
m_yyerror("something wrong with expression between ()",@3.last_line);}
| IF LP Exp RP Stmt ELSE Stmt {$$=create_node(Stmt);construct($$,7,$1,$2,$3,$4,$5,$6,$7);}
| IF LP Exp RP error ELSE Stmt {$$=create_node(Stmt);construct($$,7,$1,$2,$3,$4,create_node(None),$6,$7);
| IF LP Expr RP Stmt ELSE Stmt {$$=create_node(Stmt);construct($$,7,$1,$2,$3,$4,$5,$6,$7);}
| IF LP Expr RP error ELSE Stmt {$$=create_node(Stmt);construct($$,7,$1,$2,$3,$4,create_node(None),$6,$7);
m_yyerror("Missing \";\"",@5.last_line);}
| IF LP error RP Stmt ELSE Stmt {$$=create_node(Stmt);construct($$,7,$1,$2,create_node(None),$4,$5,$6,$7);
m_yyerror("something wrong with expression between ()",@3.last_line);}
| WHILE LP Exp RP Stmt {$$=create_node(Stmt);construct($$,5,$1,$2,$3,$4,$5);}
| WHILE LP error RP Stmt {$$=create_node(Stmt);construct($$,5,$1,$2,create_node(None),$4,$5);
m_yyerror("something wrong with expression between ()",@3.last_line);}
| IF error RP Stmt %prec LOWER_THAN_ELSE {$$=create_node(Stmt);construct($$,4,$1,create_node(None),$3,$4);
m_yyerror("missing \"(\"",@2.last_line);}
| IF error RP Stmt ELSE Stmt {$$=create_node(Stmt);construct($$,6,$1,create_node(None),$3,$4,$5,$6);
m_yyerror("missing \"(\"",@2.last_line);}
| WHILE error RP Stmt {$$=create_node(Stmt);construct($$,4,$1,create_node(None),$3,$4);
m_yyerror("missing \"(\"",@2.last_line);}
;
//循环语句部分
RepeatStatement: WHILE LP Expr RP StmtCompoundStatement {$$=create_node(RepeatStatement);construct($$,5,$1,$2,$3,$4,$5);}
| WHILE LP error RP CompoundStatement {$$=create_node(RepeatStatement);construct($$,5,$1,$2,create_node(None),$4,$5);
m_yyerror("something wrong with expression between ()",@3.last_line);}
| WHILE error RP CompoundStatement {$$=create_node(RepeatStatement);construct($$,4,$1,create_node(None),$3,$4);
m_yyerror("missing \"(\"",@2.last_line);}
| FOR LP Expr SEMI Expr SEMI Expr RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,9,$1,$2,$3,$4,$5,$6,$7,$8,$9);}
| FOR LP SEMI Expr SEMI Expr RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,8,$1,$2,$3,$4,$5,$6,$7,$8);}
| FOR LP Expr SEMI SEMI Expr RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,8,$1,$2,$3,$4,$5,$6,$7,$8);}
| FOR LP Expr SEMI Expr SEMI RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,8,$1,$2,$3,$4,$5,$6,$7,$8);}
| FOR LP SEMI SEMI Expr RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,7,$1,$2,$3,$4,$5,$6,$7);}
| FOR LP SEMI Expr SEMI RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,7,$1,$2,$3,$4,$5,$6,$7);}
| FOR LP Expr SEMI SEMI RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,7,$1,$2,$3,$4,$5,$6,$7);}
| FOR LP SEMI SEMI RP CompoundStatement { $$=create_node(RepeatStatement);;construct($$,6,$1,$2,$3,$4,$5,$6);}
//这里还有一些问题,就是没有for循环的错误情况处理
CompoundStatement: Stmt {$$=create_node(CompoundStatement);;construct($$,1,$1);}
|RepeatStament {$$=create_node(CompoundStatement);;construct($$,1,$1);}
//这里补充的是循环里面循环体的声明
//下面是条件选择的部分


/*6 Local Definitions*/
DefList : Def DefList {$$=create_node(DefList);construct($$,2,$1,$2);}
| /* empty */ {$$=create_node(DefList);construct($$,1,create_node(None));}
;
Def : Specifier DecList SEMI {$$=create_node(Def);construct($$,3,$1,$2,$3);}
| Specifier error SEMI {$$=create_node(Def);construct($$,3,$1,create_node(None),$3);
m_yyerror("unnecessary \",\"",@2.last_line);}
;
DecList : Dec {$$=create_node(DecList);construct($$,1,$1);}
| Dec COMMA DecList {$$=create_node(DecList);construct($$,3,$1,$2,$3);}
| error COMMA DecList {$$=create_node(DecList);construct($$,3,create_node(None),$2,$3);
m_yyerror("something wrong with declaration",@1.last_line);}
;
Dec : VarDec {$$=create_node(Dec);construct($$,1,$1);}
| VarDec ASSIGNOP Exp {$$=create_node(Dec);construct($$,3,$1,$2,$3);}
| error ASSIGNOP Exp {$$=create_node(Dec);construct($$,3,create_node(None),$2,$3);
m_yyerror("missing the variable",@1.last_line);}
VarDeclaration : TypeSpecifier Expr SEMI{$$=create_node(VarDeclaration);construct($$,2,$1,$2);}
| TypeSpecifier Expr COMMA Expr SEMI{$$=create_node(VarDeclaration);construct($$,3,$1,$2,$4);}
| /* empty */ {$$=create_node(VarDeclaration);construct($$,1,create_node(None));}
;
/*7 Expressions*/
Exp : Exp ASSIGNOP Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp AND Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp OR Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp RELOP Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp PLUS Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp MINUS Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp STAR Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp DIV Exp {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| LP Exp RP {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| MINUS Exp %prec NOT {$$=create_node(Exp);construct($$,2,$1,$2);}
| NOT Exp {$$=create_node(Exp);construct($$,2,$1,$2);}
| ID LP Args RP {$$=create_node(Exp);construct($$,4,$1,$2,$3,$4);}
| ID LP RP {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| Exp LB Exp RB {$$=create_node(Exp);construct($$,4,$1,$2,$3,$4);}
| Exp DOT ID {$$=create_node(Exp);construct($$,3,$1,$2,$3);}
| ID {$$=create_node(Exp);construct($$,1,$1);}
| INT {$$=create_node(Exp);construct($$,1,$1);}
| FLOAT {$$=create_node(Exp);construct($$,1,$1);}
| error RP {$$=create_node(Exp);construct($$,2,create_node(None),$2);
Expr : Expr ASSIGNOP Expr {$$=create_node(Expr);$$->value_c="=";construct($$,2,$1,$3);}
| Expr AND Expr {$$=create_node(Expr);$$->value_c="&&";construct($$,2,$1,$3);}
| Expr OR Expr {$$=create_node(Expr);$$->value_c="||";construct($$,2,$1,$3);}
| Expr GT Expr {$$=create_node(Expr);$$->value_c=">";construct($$,2,$1,$3);}
| Expr LT Expr {$$=create_node(Expr);$$->value_c="<";construct($$,2,$1,$3);}
| Expr EQ Expr {$$=create_node(Expr);$$->value_c="==";construct($$,2,$1,$3);}
| Expr GE Expr {$$=create_node(Expr);$$->value_c=">=";construct($$,2,$1,$3);}
| Expr LE Expr {$$=create_node(Expr);$$->value_c="<=";construct($$,2,$1,$3);}
| Expr NE Expr {$$=create_node(Expr);$$->value_c="!=";construct($$,2,$1,$3);}
| Expr PLUS Expr {$$=create_node(Expr);$$->value_c="+";construct($$,2,$1,$3);}
| Expr MINUS Expr {$$=create_node(Expr);$$->value_c="-";construct($$,2,$1,$3);}
| Expr STAR Expr {$$=create_node(Expr);$$->value_c="*";construct($$,2,$1,$3);}
| Expr DIV Expr {$$=create_node(Expr);$$->value_c="/";construct($$,2,$1,$3);}
| LP Expr RP {$$=create_node(Expr);construct($$,3,$1,$2,$3);}
| MINUS Expr %prec NOT {$$=create_node(Expr);construct($$,2,$1,$2);}
| NOT Expr {$$=create_node(Expr);construct($$,2,$1,$2);}
| ID LP Args RP {$$=create_node(Expr);construct($$,4,$1,$2,$3,$4);}
| ID LP RP {$$=create_node(Expr);construct($$,3,$1,$2,$3);}
| Expr LB Expr RB {$$=create_node(Expr);construct($$,4,$1,$2,$3,$4);}
| Expr DOT ID {$$=create_node(Expr);construct($$,3,$1,$2,$3);}
| ID {$$=create_node(Expr);construct($$,1,$1);}
| INT {$$=create_node(Expr);construct($$,1,$1);}
| FLOAT {$$=create_node(Expr);construct($$,1,$1);}
| error RP {$$=create_node(Expr);construct($$,2,create_node(None),$2);
m_yyerror("missing \"(\"",@1.last_line);}
| Exp LB error RB {$$=create_node(Exp);construct($$,4,$1,$2,create_node(None),$4);
| Expr LB error RB {$$=create_node(Expr);construct($$,4,$1,$2,create_node(None),$4);
m_yyerror("missing \"]\"",@3.last_line);}
| ID error RP {$$=create_node(Exp);construct($$,3,$1,create_node(None),$3);
| ID error RP {$$=create_node(Expr);construct($$,3,$1,create_node(None),$3);
m_yyerror("missing \"(\"",@2.last_line);}
;
Args : Exp COMMA Args {$$=create_node(Args);construct($$,3,$1,$2,$3);}
| Exp {$$=create_node(Args);construct($$,1,$1);}
Args : Expr COMMA Args {$$=create_node(Args);construct($$,3,$1,$2,$3);}
| Expr {$$=create_node(Args);construct($$,1,$1);}
| error COMMA Args {$$=create_node(Args);construct($$,3,create_node(None),$2,$3);
m_yyerror("something wrong with your expression",@1.last_line);}
;
Expand All @@ -180,11 +189,11 @@ int main(int argc,char** argv)
fclose(f);
return 0;
}
yyerror(char* msg) {
int yyerror(const char* msg) {
strcpy(message,msg+14);
error_occured=true;
}
void m_yyerror(char* msg,int lineno) {
printf("Error type B at Line %d: %s, maybe %s.\n",lineno,message,msg);
error_occured=true;
}
}
38 changes: 26 additions & 12 deletions Lab/Code/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static const char *const types_name_table[] =
/*0 Epsilon*/
"None",
/*1 Tokens*/
"SEMI","COMMA","ASSIGNOP","RELOP",
"SEMI","COMMA","ASSIGNOP","GT","LT","EQ","GE","LE","NE",
"PLUS","MINUS","STAR","DIV",
"AND","OR","DOT","NOT","TYPE",
"LP","RP","LB","RB","LC","RC",
Expand All @@ -15,15 +15,15 @@ static const char *const types_name_table[] =
/*2 High-level Definitions*/
"Program","ExtDefList","ExtDef","ExtDecList",
/*3 Specifiers*/
"Specifier","StructSpecifier","OptTag","Tag",
"TypeSpecifier","StructSpecifier","OptTag","Tag",
/*4 Declarators*/
"VarDec","FunDec","VarList","ParamDec",
/*5 Statements*/
"CompSt","StmtList","Stmt",
/*6 Local Definitions*/
"DefList","Def","DecList","Dec",
"VarDeclaration",
/*7 Expressions*/
"Exp","Args"
"Expr","Args"
};
const char* get_type_name(Types type)
{
Expand All @@ -41,6 +41,7 @@ Node* create_node(Types type)
p->value_f=0.0;
p->type=type;
p->name[0]='\0';
p->value_c="";
p->line=-1;
p->father=NULL;
p->child_count=0;
Expand Down Expand Up @@ -77,19 +78,32 @@ void print_tree(Node* p)
if(p==NULL)return;
if(p->line==-1)return;
depth++;
if(get_type_name(p->type)=="Program")
printf("*");
for(int i=0;i<depth;i++)
printf(" ");
printf("%s",get_type_name(p->type));
if(p->type>_FLOAT)
printf(" (%d)",p->line);
else if(p->type==_ID || p->type==_TYPE)
printf(": %s",p->name);
if(p->type==_INT||p->type==_FLOAT)
printf("ConstDeclaration");
else if(p->type==Expr && p->value_c!="")
printf("Expr,op:");
else if(p->type==Expr)
printf("Expr");
else
printf("%s",get_type_name(p->type));
//根据type索引到type_name
if(p->type==_ID )
printf(",symbol: %s",p->name);
else if(p->type==_TYPE )
printf(", %s",p->name);
else if(p->type==_INT)
printf(": %d",p->value_i);
printf(", %d",p->value_i);
else if(p->type==_FLOAT)
printf(": %f",p->value_f);
printf(", %f",p->value_f);
else if(p->type==Expr)
printf(" %s",p->value_c);
//这部分打印的是id名,int类型数据的值什么的
printf("\n");
for(int i=0;i<p->child_count;i++)
print_tree(p->child[i]);
depth--;
}
}
11 changes: 6 additions & 5 deletions Lab/Code/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef enum Types
/*0 Epsilon*/
None,
/*1 Tokens*/
_SEMI,_COMMA,_ASSIGNOP,_RELOP,
_SEMI,_COMMA,_ASSIGNOP,_GT,_LT,_EQ,_GE,_LE,_NE,
_PLUS,_MINUS,_STAR,_DIV,
_AND,_OR,_DOT,_NOT,_TYPE,
_LP,_RP,_LB,_RB,_LC,_RC,
Expand All @@ -20,15 +20,15 @@ typedef enum Types
/*2 High-level Definitions*/
Program,ExtDefList,ExtDef,ExtDecList,
/*3 Specifiers*/
Specifier,StructSpecifier,OptTag,Tag,
TypeSpecifier,StructSpecifier,OptTag,Tag,
/*4 Declarators*/
VarDec,FunDec,VarList,ParamDec,
/*5 Statements*/
CompSt,StmtList,Stmt,
/*6 Local Definitions*/
DefList,Def,DecList,Dec,
VarDeclaration,
/*7 Expressions*/
Exp,Args
Expr,Args
}Types;
typedef struct Node
{
Expand All @@ -37,6 +37,7 @@ typedef struct Node
int line;//行号
int value_i;//整形数值
float value_f;//浮点形数值
char* value_c;
struct Node* father;//父节点
int child_count;//字节点的数量
struct Node* child[MAX_COUNT_OF_CHILD];
Expand All @@ -46,4 +47,4 @@ Node* create_node(Types type);
void destroy_tree(Node* head);
void construct(Node* father,int n,...);
void print_tree(Node* head);
const char* get_type_name(Types type);
const char* get_type_name(Types type);
4 changes: 2 additions & 2 deletions Lab/Test/test5.cmm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
int main()
{
int i = 0123;
int j = 0x3F;
}
i > 2;
}
9 changes: 9 additions & 0 deletions Lab/Test/test7.cmm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
void main()
{
int a = 2, b;
while (a > 0) {
a = a -1;
}
print(a);
}