summaryrefslogtreecommitdiffhomepage
path: root/ast.h
diff options
context:
space:
mode:
Diffstat (limited to 'ast.h')
-rw-r--r--ast.h94
1 files changed, 47 insertions, 47 deletions
diff --git a/ast.h b/ast.h
index 337b81a..126aa65 100644
--- a/ast.h
+++ b/ast.h
@@ -39,7 +39,7 @@
#define JSON_C_TO_STRING_STRICT (1<<31)
-enum ut_lex_state {
+enum uc_lex_state {
UT_LEX_IDENTIFY_BLOCK,
UT_LEX_BLOCK_COMMENT_START,
UT_LEX_BLOCK_EXPRESSION_START,
@@ -51,7 +51,7 @@ enum ut_lex_state {
UT_LEX_EOF
};
-struct ut_op {
+struct uc_op {
uint16_t type;
uint16_t is_first:1;
uint16_t is_op:1;
@@ -80,40 +80,40 @@ struct ut_op {
};
};
-struct ut_scope {
- struct ut_scope *next;
+struct uc_scope {
+ struct uc_scope *next;
struct json_object *scope, *parent;
size_t refs;
};
-struct ut_source {
- struct ut_source *next;
+struct uc_source {
+ struct uc_source *next;
char *filename;
uint32_t off;
FILE *fp;
};
-struct ut_function {
+struct uc_function {
char *name;
union {
struct json_object *args;
void *cfn;
};
- struct ut_scope *parent_scope;
- struct ut_source *source;
+ struct uc_scope *parent_scope;
+ struct uc_source *source;
uint32_t entry;
};
-struct ut_callstack {
- struct ut_callstack *next;
- struct ut_function *function;
- struct ut_scope *scope;
+struct uc_callstack {
+ struct uc_callstack *next;
+ struct uc_function *function;
+ struct uc_scope *scope;
struct json_object *ctx;
uint32_t off;
};
-struct ut_state {
- struct ut_op *pool;
+struct uc_state {
+ struct uc_op *pool;
uint32_t poolsize;
uint32_t main;
uint8_t srand_called:1;
@@ -121,7 +121,7 @@ struct ut_state {
uint8_t lstrip_blocks:1;
uint8_t strict_declarations:1;
struct {
- enum ut_lex_state state;
+ enum uc_lex_state state;
uint8_t eof:1;
uint8_t skip_leading_whitespace:1;
uint8_t skip_leading_newline:1;
@@ -141,20 +141,20 @@ struct ut_state {
size_t lastoff;
} lex;
struct json_object *ctx, *rval, *exception;
- struct ut_scope *scopelist, *scope;
- struct ut_source *sources, *source;
- struct ut_callstack *callstack;
- struct ut_function *function;
+ struct uc_scope *scopelist, *scope;
+ struct uc_source *sources, *source;
+ struct uc_callstack *callstack;
+ struct uc_function *function;
size_t calldepth;
};
-struct ut_extended_type {
+struct uc_extended_type {
const char *name;
struct json_object *proto;
void (*free)(void *);
};
-static inline struct ut_op *ut_get_op(struct ut_state *s, uint32_t off)
+static inline struct uc_op *uc_get_op(struct uc_state *s, uint32_t off)
{
if (off == 0 || off > s->poolsize)
return NULL;
@@ -162,53 +162,53 @@ static inline struct ut_op *ut_get_op(struct ut_state *s, uint32_t off)
return &s->pool[off - 1];
}
-static inline struct ut_op *ut_get_child(struct ut_state *s, uint32_t off, int n)
+static inline struct uc_op *uc_get_child(struct uc_state *s, uint32_t off, int n)
{
- struct ut_op *op = ut_get_op(s, off);
+ struct uc_op *op = uc_get_op(s, off);
if (!op || n >= ARRAY_SIZE(op->tree.operand) || !op->tree.operand[n])
return NULL;
- return ut_get_op(s, op->tree.operand[n]);
+ return uc_get_op(s, op->tree.operand[n]);
}
-static inline uint32_t ut_get_off(struct ut_state *s, struct ut_op *op) {
+static inline uint32_t uc_get_off(struct uc_state *s, struct uc_op *op) {
return op ? (op - s->pool + 1) : 0;
};
-static inline bool ut_is_type(struct json_object *val, int type) {
- struct ut_op *tag = json_object_get_userdata(val);
+static inline bool uc_is_type(struct json_object *val, int type) {
+ struct uc_op *tag = json_object_get_userdata(val);
return (tag && tag->type == type);
};
-uint32_t ut_new_op(struct ut_state *s, int type, struct json_object *val, ...);
-uint32_t ut_wrap_op(struct ut_state *s, uint32_t parent, ...);
-uint32_t ut_append_op(struct ut_state *s, uint32_t a, uint32_t b);
-struct json_object *ut_parse(struct ut_state *s, FILE *fp);
-void ut_free(struct ut_state *s);
+uint32_t uc_new_op(struct uc_state *s, int type, struct json_object *val, ...);
+uint32_t uc_wrap_op(struct uc_state *s, uint32_t parent, ...);
+uint32_t uc_append_op(struct uc_state *s, uint32_t a, uint32_t b);
+struct json_object *uc_parse(struct uc_state *s, FILE *fp);
+void uc_free(struct uc_state *s);
-struct json_object *ut_new_func(struct ut_state *s, struct ut_op *decl, struct ut_scope *scope);
-struct json_object *ut_new_object(struct json_object *proto);
-struct json_object *ut_new_double(double v);
-struct json_object *ut_new_null(void);
-struct json_object *ut_new_regexp(const char *source, bool icase, bool newline, bool global, char **err);
+struct json_object *uc_new_func(struct uc_state *s, struct uc_op *decl, struct uc_scope *scope);
+struct json_object *uc_new_object(struct json_object *proto);
+struct json_object *uc_new_double(double v);
+struct json_object *uc_new_null(void);
+struct json_object *uc_new_regexp(const char *source, bool icase, bool newline, bool global, char **err);
__attribute__((format(printf, 3, 0)))
-struct json_object *ut_new_exception(struct ut_state *s, uint32_t off, const char *fmt, ...);
+struct json_object *uc_new_exception(struct uc_state *s, uint32_t off, const char *fmt, ...);
-struct ut_scope *ut_new_scope(struct ut_state *s, struct ut_scope *parent);
-struct ut_scope *ut_parent_scope(struct ut_scope *scope);
-struct ut_scope *ut_acquire_scope(struct ut_scope *scope);
-void ut_release_scope(struct ut_scope *scope);
+struct uc_scope *uc_new_scope(struct uc_state *s, struct uc_scope *parent);
+struct uc_scope *uc_parent_scope(struct uc_scope *scope);
+struct uc_scope *uc_acquire_scope(struct uc_scope *scope);
+void uc_release_scope(struct uc_scope *scope);
-bool ut_register_extended_type(const char *name, struct json_object *proto, void (*freefn)(void *));
-struct json_object *ut_set_extended_type(struct json_object *v, const char *name, void *data);
-void **ut_get_extended_type(struct json_object *val, const char *name);
+bool uc_register_extended_type(const char *name, struct json_object *proto, void (*freefn)(void *));
+struct json_object *uc_set_extended_type(struct json_object *v, const char *name, void *data);
+void **uc_get_extended_type(struct json_object *val, const char *name);
void *ParseAlloc(void *(*mfunc)(size_t));
-void Parse(void *pParser, int type, uint32_t off, struct ut_state *s);
+void Parse(void *pParser, int type, uint32_t off, struct uc_state *s);
void ParseFree(void *pParser, void (*ffunc)(void *));