61 bool g_stateSpawnDefined = false; |
61 bool g_stateSpawnDefined = false; |
62 bool g_GotMainLoop = false; |
62 bool g_GotMainLoop = false; |
63 |
63 |
64 void ScriptReader::BeginParse (ObjWriter* w) { |
64 void ScriptReader::BeginParse (ObjWriter* w) { |
65 while (Next()) { |
65 while (Next()) { |
66 // printf ("got token %s\n", token.chars()); |
|
67 if (!token.icompare ("#include")) { |
|
68 MustString (); |
|
69 |
|
70 // First ensure that the file can be opened |
|
71 FILE* newfile = fopen (token.chars(), "r"); |
|
72 if (!newfile) |
|
73 ParserError ("couldn't open included file `%s`!", token.chars()); |
|
74 fclose (newfile); |
|
75 ScriptReader* newreader = new ScriptReader (token.chars()); |
|
76 newreader->BeginParse (w); |
|
77 continue; |
|
78 } |
|
79 |
|
80 if (!token.icompare ("state")) { |
66 if (!token.icompare ("state")) { |
81 MUST_TOPLEVEL |
67 MUST_TOPLEVEL |
82 |
68 |
83 MustString (); |
69 MustString (); |
84 |
70 |
87 ParserError ("state name must be a single word! got `%s`", token.chars()); |
73 ParserError ("state name must be a single word! got `%s`", token.chars()); |
88 str statename = token; |
74 str statename = token; |
89 |
75 |
90 // stateSpawn is special - it *must* be defined. If we |
76 // stateSpawn is special - it *must* be defined. If we |
91 // encountered it, then mark down that we have it. |
77 // encountered it, then mark down that we have it. |
92 if (!token.icompare ("stateSpawn")) |
78 if (!token.icompare ("statespawn")) |
93 g_stateSpawnDefined = true; |
79 g_stateSpawnDefined = true; |
94 |
80 |
95 // Must end in a colon |
81 // Must end in a colon |
96 MustNext (":"); |
82 MustNext (":"); |
97 |
83 |