added rollbacking functionality to trier (for namespaces)
[swftools.git] / lib / as3 / tokenizer.h
1 /* tokenizer.h
2
3    Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
18
19 #ifndef __parser_h__
20 #define __parser_h__
21
22 #include "../q.h"
23 #include "abc.h"
24 #include "pool.h"
25 #include "files.h"
26 #include "tokenizer.h"
27 #include "registry.h"
28 #include "code.h"
29 #include "opcodes.h"
30
31 DECLARE(token);
32 DECLARE_LIST(token);
33 DECLARE(param);
34 DECLARE_LIST(param);
35 DECLARE(params);
36 DECLARE(typedcode);
37 DECLARE(modifiers);
38 DECLARE(namespace_decl);
39 DECLARE_LIST(namespace_decl);
40 DECLARE_LIST(typedcode);
41
42 struct _param {
43     char*name;
44     classinfo_t*type;
45     constant_t*value;
46 };
47
48 struct _params {
49     param_list_t*list;
50     char varargs;
51 };
52
53 struct _typedcode {
54     code_t*c;
55     classinfo_t*t;
56 };
57 struct _modifiers {
58     int flags;
59     char*ns;
60 };
61 struct _namespace_decl {
62     const char*name;
63     const char*url;
64 };
65
66 /* small helper structs: */
67 typedef struct _codeandnumber {
68     code_t*cc;
69     int number;
70 } codeandnumber_t;
71 typedef struct _for_start {
72     char*name;
73     char each;
74 } for_start_t;
75 typedef struct _regexp {
76     char*pattern;
77     char*options;
78 } regexp_t;
79
80 extern char start_of_expression;
81
82 typedef token_t*tokenptr_t;
83
84 extern trie_t*active_namespaces;
85
86 #include "parser.tab.h"
87
88 extern int as3_verbosity;
89 extern int as3_pass;
90 extern unsigned int as3_tokencount;
91 #define syntaxerror as3_error
92 void as3_error(const char*format, ...);
93 void as3_warning(const char*format, ...);
94 void as3_softwarning(const char*format, ...);
95
96 void as3_buffer_input(void*buffer, int len);
97 void as3_file_input(FILE*fi);
98
99 #define T_EOF 0
100
101 extern int avm2_lex();
102 extern int avm2_lex_destroy();
103
104 #endif