3 Compiler for parsing Flash2 AVM2 ABC Actionscript
5 Extension module for the rfxswf library.
6 Part of the swftools package.
8 Copyright (c) 2008/2009 Matthias Kramm <kramm@quiss.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
24 #include "tokenizer.h"
27 #include "parser.tab.h"
31 /* flex/bison definitions */
32 extern void avm2_set_in (FILE * in_str );
33 extern int avm2_parse();
35 void as3_setverbosity(int level)
39 void as3_add_include_dir(char*dir)
44 static char registry_initialized = 0;
45 static char parser_initialized = 0;
47 void as3_parse_file(char*filename)
49 if(!registry_initialized) {
50 registry_initialized = 1;
53 if(!parser_initialized) {
54 parser_initialized = 1;
60 char*fullfilename = enter_file(filename, 0);
61 FILE*fi = fopen(fullfilename, "rb");
63 syntaxerror("Couldn't find file %s: %s", fullfilename, strerror(errno));
68 initialize_file(filename);
74 // TODO: this should re-use tokens!
75 enter_file(filename, 0);
77 fseek(fi, 0, SEEK_SET);
79 initialize_file(filename);
88 static void*as3code = 0;
91 if(parser_initialized) {
92 parser_initialized = 0;
93 as3code = finish_parser();
97 char* as3_getglobalclass()
99 return as3_globalclass;
104 if(parser_initialized) {
105 parser_initialized = 0;
106 swf_FreeABC(finish_parser());
108 if(as3_globalclass) {
109 free(as3_globalclass);as3_globalclass=0;