Exemplo n.º 1
0
static NODE * print(void){
	NODE * t = new_stmt(N_PRINT);
	match(PRINT);
	if (t != NULL)
		t->child[0] = exp();
	return t;
}
Exemplo n.º 2
0
static NODE * read(void){
	NODE * t = new_stmt(N_READ);
	match(READ);
	if ((t != NULL) &&(token.type == VAR)){
		t->attribute.name = toHeap(token.attribute.name);
	}
	match(VAR);
	return t;
}
Exemplo n.º 3
0
static NODE * assign_stmt(void){
	NODE * t = new_stmt(N_ASSIGN);
	if ((t != NULL) && (token.type == VAR)){
		t->attribute.name = toHeap(token.attribute.name);
	}
	match(VAR);
	match(ASSIGN);
	if (t != NULL){
		t->child[0] = exp();
	}
	return t;
}
Exemplo n.º 4
0
static NODE * while_stmt(void){
	NODE * t = new_stmt(N_WHILE);
	match(WHILE);
	if(t != NULL){
		t->child[0] = exp();
	}
	match(DO);
	if(t != NULL) {
		t->child[1] = stmt_list();
	}
	return t;
}
Exemplo n.º 5
0
static NODE * if_stmt(void){
	NODE * t = new_stmt(N_IF);
	match(IF);
	if (t != NULL){
		t->child[0] = exp();
	}
	match(THEN);
	if (t != NULL){
		t->child[1] = stmt_list();
	}
	if (token.type == ELSE){
		match(ELSE);
		if (t!= NULL){
			t->child[2] = stmt_list();
		}
	}
	return t;
}
Exemplo n.º 6
0
StatementPtr ClassRequireStatement::clone() {
  ClassRequireStatementPtr new_stmt(new ClassRequireStatement(*this));
  return new_stmt;
}
Exemplo n.º 7
0
StatementPtr TraitRequireStatement::clone() {
  TraitRequireStatementPtr new_stmt(new TraitRequireStatement(*this));
  return new_stmt;
}