expression parsing has begun
[manmower/obtheme.git] / obtheme.h
1 #ifndef __THEME_PARSE_H__
2 #define __THEME_PARSE_H__
3
4 #include <glib.h>
5 #include "frame.h"
6 #include "misc.h"
7
8 #undef YY_DECL
9 #define YY_DECL int obthemelex(YYSTYPE *yylval, struct parser_control *pc)
10
11 #define YYDEBUG 1
12 #define YYLEX_PARAM pc
13
14 #define MAX_INCLUDE_DEPTH 32
15 #define LINE pc->currline[pc->include_stack_ptr]
16
17 extern int themedebug;
18
19 typedef enum {
20         OB_THEME_ADD,
21         OB_THEME_SUB,
22         OB_THEME_MUL,
23         OB_THEME_DIV,
24         OB_THEME_EQL
25 } ObThemeOp;
26
27 struct variable {
28         char *base;
29         char *member;
30         double number;
31 };
32
33 struct expression {
34         ObThemeOp op;
35         struct expression *a;
36         struct expression *b;
37         struct variable v;
38 };
39
40 struct material {
41         float opacity;
42 };
43
44 struct style {
45         char *name;
46         GSList *tree;
47 };
48
49 struct obthemedata {
50         GHashTable *themes;
51         GHashTable *materials;
52 };
53
54 struct theme {
55         char *name;
56         GHashTable *styles;
57 };
58
59 struct vector {
60         struct expression x;
61         struct expression y;
62         struct expression z;
63 };
64
65 struct space {
66         struct vector anchor;
67         struct vector up;
68 };
69
70 struct decor {
71         char *name;
72         GSList *children;
73         struct space space;
74         ObDirection cursor;
75         ObFrameContext context;
76 };
77
78 struct parser_control {
79         struct yy_buffer_state *include_stack[MAX_INCLUDE_DEPTH];
80         int currline[MAX_INCLUDE_DEPTH];
81         char currfile[MAX_INCLUDE_DEPTH][501];
82         int include_stack_ptr;
83         char error_buf[4096];
84         struct obthemedata *target;
85 };
86
87 void obthemeerror(struct parser_control *pc, char *s);
88 int obtheme_parse(struct obthemedata *td, const char *filename);
89 struct parser_control *parser_init(struct obthemedata *td);
90 int obthemeparse(struct parser_control *);
91 void parser_finish(struct parser_control *);
92
93 #endif /* __THEME_PARSE_H__ */