src/Parser.cc

changeset 103
48472c0678cc
parent 102
28f89ca1a236
child 104
62da929f7814
equal deleted inserted replaced
102:28f89ca1a236 103:48472c0678cc
372 void BotscriptParser::ParseGoto() 372 void BotscriptParser::ParseGoto()
373 { 373 {
374 CheckNotToplevel(); 374 CheckNotToplevel();
375 375
376 // Get the name of the label 376 // Get the name of the label
377 mLexer->MustGetNext(); 377 mLexer->MustGetNext (tkAny);
378 378
379 // Find the mark this goto statement points to 379 // Find the mark this goto statement points to
380 String target = GetTokenString(); 380 String target = GetTokenString();
381 ByteMark* mark = buffer()->FindMarkByName (target); 381 ByteMark* mark = buffer()->FindMarkByName (target);
382 382
490 CheckNotToplevel(); 490 CheckNotToplevel();
491 PushScope(); 491 PushScope();
492 492
493 // Initializer 493 // Initializer
494 mLexer->MustGetNext (tkParenStart); 494 mLexer->MustGetNext (tkParenStart);
495 mLexer->MustGetNext(); 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(); 512 mLexer->MustGetNext (tkAny);
513 DataBuffer* incr = ParseStatement(); 513 DataBuffer* incr = ParseStatement();
514 514
515 if (incr == null) 515 if (incr == null)
516 Error ("bad statement for incrementor of for"); 516 Error ("bad statement for incrementor of for");
517 517
946 946
947 if (mCurrentMode == ETopLevelMode && comm->returnvalue == EVoidType) 947 if (mCurrentMode == ETopLevelMode && comm->returnvalue == EVoidType)
948 Error ("command call at top level"); 948 Error ("command call at top level");
949 949
950 mLexer->MustGetNext (tkParenStart); 950 mLexer->MustGetNext (tkParenStart);
951 mLexer->MustGetNext(); 951 mLexer->MustGetNext (tkAny);
952 952
953 int curarg = 0; 953 int curarg = 0;
954 954
955 for (;;) 955 for (;;)
956 { 956 {
967 if (curarg >= comm->args.Size()) 967 if (curarg >= comm->args.Size())
968 Error ("too many arguments passed to %1\n\tusage is: %2", 968 Error ("too many arguments passed to %1\n\tusage is: %2",
969 comm->name, comm->GetSignature()); 969 comm->name, comm->GetSignature());
970 970
971 r->MergeAndDestroy (ParseExpression (comm->args[curarg].type, true)); 971 r->MergeAndDestroy (ParseExpression (comm->args[curarg].type, true));
972 mLexer->MustGetNext(); 972 mLexer->MustGetNext (tkAny);
973 973
974 if (curarg < comm->minargs - 1) 974 if (curarg < comm->minargs - 1)
975 { 975 {
976 mLexer->TokenMustBe (tkComma); 976 mLexer->TokenMustBe (tkComma);
977 mLexer->MustGetNext(); 977 mLexer->MustGetNext (tkAny);
978 } 978 }
979 else if (curarg < comm->args.Size() - 1) 979 else if (curarg < comm->args.Size() - 1)
980 { 980 {
981 // Can continue, but can terminate as well. 981 // Can continue, but can terminate as well.
982 if (TokenIs (tkParenEnd)) 982 if (TokenIs (tkParenEnd))
985 break; 985 break;
986 } 986 }
987 else 987 else
988 { 988 {
989 mLexer->TokenMustBe (tkComma); 989 mLexer->TokenMustBe (tkComma);
990 mLexer->MustGetNext(); 990 mLexer->MustGetNext (tkAny);
991 } 991 }
992 } 992 }
993 993
994 curarg++; 994 curarg++;
995 } 995 }

mercurial