34 lines
441 B
C
34 lines
441 B
C
#ifndef PARSE_H
|
|
#define PARSE_H
|
|
|
|
#include <stddef.h>
|
|
|
|
typedef enum {
|
|
EXPR_IDENT,
|
|
EXPR_INT,
|
|
EXPR_SEXPR,
|
|
} ExprType;
|
|
|
|
typedef struct Expr Expr;
|
|
|
|
struct Expr {
|
|
ExprType type;
|
|
|
|
union {
|
|
char* text;
|
|
|
|
struct {
|
|
Expr** items;
|
|
size_t count;
|
|
} sexpr;
|
|
};
|
|
};
|
|
|
|
Expr* parse(const char* source);
|
|
void expr_free(Expr* expr);
|
|
void expr_print(Expr* expr);
|
|
|
|
void test_parse(void);
|
|
|
|
#endif
|