-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.h
99 lines (76 loc) · 1.69 KB
/
script.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef SCRIPT_H_
#define SCRIPT_H_ 1
#include <stdio.h>
#include <sys/types.h>
#include "arena.h"
#ifdef __cplusplus
extern "C" {
#endif
#define SCRIPT_DEGREES (3.14159265358979323846 / 180.0)
struct script_parse_context
{
void *scanner;
struct arena_info statement_arena;
int error;
struct ScriptStatement *statements;
};
struct ScriptStatement
{
const char *identifier;
struct ScriptParameter *parameters;
struct ScriptStatement *next;
off_t offset;
};
struct ScriptParameter
{
const char *identifier;
struct ScriptExpression *expression;
struct ScriptParameter *next;
};
enum ScriptExpressionType
{
/* Unary */
ScriptExpressionNumeric,
ScriptExpressionString,
ScriptExpressionBinary,
ScriptExpressionIdentifier,
ScriptExpressionStatement,
ScriptExpressionParen,
ScriptExpressionNegative,
ScriptExpressionAbsolute,
/* Binary */
ScriptExpressionAdd,
ScriptExpressionSubtract,
ScriptExpressionMultiply,
ScriptExpressionDivide,
};
struct ScriptExpression
{
enum ScriptExpressionType type;
union
{
struct ScriptExpression *expression;
struct ScriptStatement *statement;
const char *string;
const char *binary;
const char *numeric;
const char *identifier;
} lhs;
struct ScriptExpression *rhs;
double scale;
off_t offset;
};
void
SCRIPT_Optimize (struct script_parse_context *context);
int
script_parse_file(struct script_parse_context *context, FILE *file);
void
script_dump (struct script_parse_context *context);
void
script_dump_binary (struct script_parse_context *context, int ptrsize);
void
script_dump_html (struct script_parse_context *context);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SCRIPT_H_ */