Remove TOPTREE

This commit is contained in:
bʰedoh₂ swé 2024-06-03 23:55:02 +05:00
parent 9764aff184
commit 7ed5367f20
4 changed files with 4 additions and 10 deletions

View File

@ -9,7 +9,7 @@
struct SyntaxElement* parse(FILE* file) {
struct SyntaxElement* syntaxtree = se_create();
struct SyntaxElement* syntaxtreestart = syntaxtree;
syntaxtree->type = TOPTREE;
syntaxtree->type = TREE;
char symbol;
bool intree = false;
bool incomment = false;
@ -72,7 +72,7 @@ struct SyntaxElement* parse(FILE* file) {
syntaxtree = se_bottom(syntaxtree);
break;
case ')':
if (syntaxtree->top->type == TOPTREE) {
if (syntaxtree->top->type == TREE) {
intree = false;
syntaxtree = syntaxtree->top;
syntaxtree = se_next(syntaxtree);
@ -107,7 +107,7 @@ struct SyntaxElement* parse(FILE* file) {
continue;
case '(':
intree = true;
syntaxtree->type = TOPTREE;
syntaxtree->type = TREE;
syntaxtree = se_bottom(syntaxtree);
syntaxtree->type = TREE;
continue;

View File

@ -9,10 +9,6 @@ void printtree(struct SyntaxElement* syntaxtree, int depth) {
for (int i = 1; i <= depth; i++)
putc(' ',stdout);
switch (syntaxtree->type) {
case TOPTREE:
printf("TOPTREE\n");
printtree((struct SyntaxElement*)syntaxtree->content, depth + 1);
break;
case TREE:
printf("TREE\n");
printtree((struct SyntaxElement*)syntaxtree->content, depth + 1);

View File

@ -30,7 +30,6 @@ void se_free(struct SyntaxElement* syntaxtree) {
free(syntaxtree);
return;
case TREE:
case TOPTREE:
if (syntaxtree->content != NULL) {
se_free((struct SyntaxElement*)syntaxtree->content);
}
@ -58,7 +57,7 @@ void se_clean(struct SyntaxElement* syntaxtree) {
break;
}
}
if (syntaxtree->content != NULL && (syntaxtree->type == TOPTREE || syntaxtree->type == TREE)) {
if (syntaxtree->content != NULL && (syntaxtree->type == TREE)) {
switch (((struct SyntaxElement*)syntaxtree->content)->type) {
case NONE:
free(syntaxtree->content);

View File

@ -1,7 +1,6 @@
#ifndef SYNTAX_H
#define SYNTAX_H
enum SyntaxElementType {
TOPTREE,
TREE,
TOKEN,
STRING,