main.cxx

changeset 48
976c57f153b3
parent 44
6bbaebc472b5
child 50
2e333a3ca49a
equal deleted inserted replaced
47:d84d82213137 48:976c57f153b3
55 55
56 #include "bots.h" 56 #include "bots.h"
57 #include "botcommands.h" 57 #include "botcommands.h"
58 58
59 const char* g_Keywords[] = { 59 const char* g_Keywords[] = {
60 "break",
61 "case",
60 "do", 62 "do",
61 "event", 63 "event",
62 "for", 64 "for",
63 "goto", 65 "goto",
64 "if", 66 "if",
65 "mainloop", 67 "mainloop",
66 "onenter", 68 "onenter",
67 "onexit", 69 "onexit",
68 "state", 70 "state",
71 "switch",
69 "var" 72 "var"
70 "while", 73 "while",
71 74
72 // These ones aren't implemented yet but I plan to do so, thus they are 75 // These ones aren't implemented yet but I plan to do so, thus they are
73 // reserved. Also serves as a to-do list of sorts for me. >:F 76 // reserved. Also serves as a to-do list of sorts for me. >:F
74 "break",
75 "case",
76 "continue", 77 "continue",
77 "default", 78 "default",
78 "else", 79 "else",
79 "enum", // Would enum actually be useful? I think so. 80 "enum", // Would enum actually be useful? I think so.
80 "func", // Would function support need external support from zandronum? 81 "func", // Would function support need external support from zandronum?
81 "return", 82 "return",
82 "switch",
83 }; 83 };
84
85 // databuffer global variable
86 int g_NextMark = 0;
84 87
85 int main (int argc, char** argv) { 88 int main (int argc, char** argv) {
86 // Intepret command-line parameters: 89 // Intepret command-line parameters:
87 // -l: list commands 90 // -l: list commands
88 if (argc == 2 && !strcmp (argv[1], "-l")) { 91 if (argc == 2 && !strcmp (argv[1], "-l")) {
162 // Prepare reader and writer 165 // Prepare reader and writer
163 ScriptReader *r = new ScriptReader (argv[1]); 166 ScriptReader *r = new ScriptReader (argv[1]);
164 ObjWriter *w = new ObjWriter (outfile); 167 ObjWriter *w = new ObjWriter (outfile);
165 168
166 // We're set, begin parsing :) 169 // We're set, begin parsing :)
167 printf ("Parsing script..\n"); 170 printf ("Parsing script...\n");
168 r->BeginParse (w); 171 r->BeginParse (w);
172 printf ("Script parsed successfully.\n");
169 173
170 // Parse done, print statistics and write to file 174 // Parse done, print statistics and write to file
171 unsigned int globalcount = CountGlobalVars (); 175 unsigned int globalcount = CountGlobalVars ();
176 unsigned int stringcount = CountStringTable ();
172 int NumMarks = w->MainBuffer->CountMarks (); 177 int NumMarks = w->MainBuffer->CountMarks ();
173 int NumRefs = w->MainBuffer->CountReferences (); 178 int NumRefs = w->MainBuffer->CountReferences ();
174 printf ("%u / %u global variable%s\n", globalcount, MAX_SCRIPT_VARIABLES, PLURAL (globalcount)); 179 printf ("%u / %u strings written\n", stringcount, MAX_LIST_STRINGS);
175 printf ("%d / %d mark%s used\n", NumMarks, MAX_MARKS, PLURAL (NumMarks)); 180 printf ("%u / %u global variables\n", globalcount, MAX_SCRIPT_VARIABLES);
176 printf ("%d / %d ref%s used\n", NumRefs, MAX_MARKS, PLURAL (NumRefs)); 181 printf ("%d / %d bytecode marks\n", NumMarks, MAX_MARKS);
177 printf ("%d state%s written\n", g_NumStates, PLURAL (g_NumStates)); 182 printf ("%d / %d bytecode references\n", NumRefs, MAX_MARKS);
178 printf ("%d event%s written\n", g_NumEvents, PLURAL (g_NumEvents)); 183 printf ("%d / %d events\n", g_NumEvents, MAX_NUM_EVENTS);
184 printf ("%d state%s\n", g_NumStates, PLURAL (g_NumStates));
185
179 w->WriteToFile (); 186 w->WriteToFile ();
180 187
181 // Clear out the junk 188 // Clear out the junk
182 delete r; 189 delete r;
183 delete w; 190 delete w;

mercurial