push
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include "list.h"
|
||||
|
||||
void push_front(struct list **l, void *data, acceptor p, acceptor f)
|
||||
{
|
||||
(void)l;
|
||||
(void)data;
|
||||
(void)p;
|
||||
(void)f;
|
||||
}
|
||||
|
||||
void pop_front(struct list **l)
|
||||
{
|
||||
(void)l;
|
||||
}
|
||||
|
||||
void print_list(struct list *l)
|
||||
{
|
||||
(void)l;
|
||||
}
|
||||
|
||||
void destroy_list(struct list **l)
|
||||
{
|
||||
(void)l;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
typedef void (*acceptor)(void*);
|
||||
|
||||
struct list
|
||||
{
|
||||
void *data;
|
||||
struct list *next;
|
||||
acceptor print;
|
||||
acceptor free;
|
||||
};
|
||||
|
||||
void push_front(struct list **l, void *data, acceptor p, acceptor f);
|
||||
void pop_front(struct list **l);
|
||||
void print_list(struct list *l);
|
||||
void destroy_list(struct list **l);
|
||||
|
||||
#endif /* ! LIST_H */
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "visitor.h"
|
||||
|
||||
void visit(struct ast_node *node, visitor v)
|
||||
{
|
||||
(void)node;
|
||||
(void)v;
|
||||
}
|
||||
|
||||
void print_prefix(struct ast_node *node)
|
||||
{
|
||||
(void)node;
|
||||
}
|
||||
|
||||
void print_infix(struct ast_node *node)
|
||||
{
|
||||
(void)node;
|
||||
}
|
||||
|
||||
void print_suffix(struct ast_node *node)
|
||||
{
|
||||
(void)node;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef VISITOR_H
|
||||
#define VISITOR_H
|
||||
|
||||
enum node_type
|
||||
{
|
||||
// 0 operand
|
||||
NUM,
|
||||
|
||||
// 1 operand
|
||||
POS,
|
||||
NEG,
|
||||
|
||||
// 2 operands
|
||||
ADD,
|
||||
SUB,
|
||||
MUL,
|
||||
DIV,
|
||||
MOD,
|
||||
};
|
||||
|
||||
struct ast_node
|
||||
{
|
||||
int value;
|
||||
enum node_type type;
|
||||
struct ast_node *children;
|
||||
};
|
||||
|
||||
typedef void(*visitor)(struct ast_node *);
|
||||
|
||||
void visit(struct ast_node *node, visitor v);
|
||||
|
||||
void print_prefix(struct ast_node *node);
|
||||
void print_infix(struct ast_node *node);
|
||||
void print_suffix(struct ast_node *node);
|
||||
|
||||
#endif /* ! VISITOR_H */
|
||||
Reference in New Issue
Block a user