src/Parser.cc

changeset 104
62da929f7814
parent 103
48472c0678cc
child 105
6dbac3305614
equal deleted inserted replaced
103:48472c0678cc 104:62da929f7814
199 mLexer->MustGetNext (tkSemicolon); 199 mLexer->MustGetNext (tkSemicolon);
200 continue; 200 continue;
201 } 201 }
202 202
203 // If nothing else, parse it as a statement 203 // If nothing else, parse it as a statement
204 mLexer->Skip (-1);
204 DataBuffer* b = ParseStatement(); 205 DataBuffer* b = ParseStatement();
205 206
206 if (b == false) 207 if (b == false)
207 Error ("unknown token `%1`", GetTokenString()); 208 Error ("unknown token `%1`", GetTokenString());
208 209
372 void BotscriptParser::ParseGoto() 373 void BotscriptParser::ParseGoto()
373 { 374 {
374 CheckNotToplevel(); 375 CheckNotToplevel();
375 376
376 // Get the name of the label 377 // Get the name of the label
377 mLexer->MustGetNext (tkAny); 378 mLexer->MustGetNext (tkSymbol);
378 379
379 // Find the mark this goto statement points to 380 // Find the mark this goto statement points to
380 String target = GetTokenString(); 381 String target = GetTokenString();
381 ByteMark* mark = buffer()->FindMarkByName (target); 382 ByteMark* mark = buffer()->FindMarkByName (target);
382 383
490 CheckNotToplevel(); 491 CheckNotToplevel();
491 PushScope(); 492 PushScope();
492 493
493 // Initializer 494 // Initializer
494 mLexer->MustGetNext (tkParenStart); 495 mLexer->MustGetNext (tkParenStart);
495 mLexer->MustGetNext (tkAny);
496 DataBuffer* init = ParseStatement(); 496 DataBuffer* init = ParseStatement();
497 497
498 if (init == null) 498 if (init == null)
499 Error ("bad statement for initializer of for"); 499 Error ("bad statement for initializer of for");
500 500
507 Error ("bad statement for condition of for"); 507 Error ("bad statement for condition of for");
508 508
509 mLexer->MustGetNext (tkSemicolon); 509 mLexer->MustGetNext (tkSemicolon);
510 510
511 // Incrementor 511 // Incrementor
512 mLexer->MustGetNext (tkAny);
513 DataBuffer* incr = ParseStatement(); 512 DataBuffer* incr = ParseStatement();
514 513
515 if (incr == null) 514 if (incr == null)
516 Error ("bad statement for incrementor of for"); 515 Error ("bad statement for incrementor of for");
517 516
1190 // ============================================================================ 1189 // ============================================================================
1191 // 1190 //
1192 DataBuffer* BotscriptParser::ParseStatement() 1191 DataBuffer* BotscriptParser::ParseStatement()
1193 { 1192 {
1194 // If it's a variable, expect assignment. 1193 // If it's a variable, expect assignment.
1195 if (TokenIs (tkDollarSign)) 1194 if (mLexer->GetNext (tkDollarSign))
1196 { 1195 {
1197 mLexer->MustGetNext (tkSymbol); 1196 mLexer->MustGetNext (tkSymbol);
1198 ScriptVariable* var = FindGlobalVariable (GetTokenString()); 1197 ScriptVariable* var = FindGlobalVariable (GetTokenString());
1199 1198
1200 if (var == null) 1199 if (var == null)

mercurial