3 Flash ActionScript 3.0 compiler
5 Part of the swftools package.
7 Copyright (c) 2008 Matthias Kramm <kramm@quiss.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
27 #include "../rfxswf.h"
31 #include "tokenizer.h"
32 #include "parser.tab.h"
37 void test_lexer(char*filename)
39 char*fullfilename = find_file(filename, 1);
40 enter_file(filename, fullfilename, 0);
41 FILE*fi = fopen(fullfilename, "rb");
44 int token = as3_lex();
47 if(token>=32 && token<256) {
48 printf("'%c'\n", token);
50 printf("%s\n", token2string(token, a3_lval));
56 int main(int argn, char*argv[])
62 fprintf(stderr, "please supply a filename\n");
65 filename=argv[argn-1];
67 //a3_debug = 1; //if bison was called with -t
69 as3_add_include_dir(getcwd(buf, 512));
75 for(t=1;t<argn-1;t++) {
76 if(!strcmp(argv[t], "-lex")) {
80 if(!strcmp(argv[t], "-M")) {
81 mainclass = argv[++t];
83 if(!strcmp(argv[t], "-v")) {
86 if(!strcmp(argv[t], "-q")) {
89 if(!strcmp(argv[t], "-D")) {
92 printf("Error: compile definition must contain \"::\"\n");
95 if(!strcmp(argv[t], "-R")) {
96 as3_set_option("recurse","1");
98 if(!strcmp(argv[t], "-I")) {
99 as3_add_include_dir(argv[++t]);
101 if(!strcmp(argv[t], "-l")) {
102 as3_import_file(argv[++t]);
106 //extern int avm2_debug;
109 //memfile_t*m = memfile_open(filename);
110 //as3_parse_bytearray(filename, m->data, m->len);
112 if(!strcmp(filename, ".")) {
113 as3_parse_directory(".");
115 as3_parse_file(filename);
118 void*code = as3_getcode();
121 memset(&swf, 0, sizeof(swf));
123 swf.frameRate = 0x2500;
124 swf.movieSize.xmin = swf.movieSize.ymin = 0;
125 swf.movieSize.xmax = 20*20;
126 swf.movieSize.ymax = 10*20;
127 TAG*tag = swf.firstTag = swf_InsertTag(0, ST_DOABC);
128 swf_WriteABC(tag, code);
131 mainclass = as3_getglobalclass();
134 tag = swf_InsertTag(tag, ST_SYMBOLCLASS);
137 swf_SetString(tag, mainclass);
139 printf("Warning: no global public MovieClip subclass\n");
142 tag = swf_InsertTag(tag, ST_SHOWFRAME);
143 tag = swf_InsertTag(tag, ST_END);
147 int f = open("abc.swf",O_RDWR|O_CREAT|O_TRUNC|O_BINARY,0644);
148 swf_WriteSWF(f,&swf);