- minor changes: don't allow any token for labels, run ParseStatement from the next token

Sun, 09 Feb 2014 15:13:02 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 09 Feb 2014 15:13:02 +0200
changeset 104
62da929f7814
parent 103
48472c0678cc
child 105
6dbac3305614

- minor changes: don't allow any token for labels, run ParseStatement from the next token

src/Parser.cc file | annotate | diff | comparison | revisions
--- a/src/Parser.cc	Sun Feb 09 15:06:37 2014 +0200
+++ b/src/Parser.cc	Sun Feb 09 15:13:02 2014 +0200
@@ -201,6 +201,7 @@
 				}
 
 				// If nothing else, parse it as a statement
+				mLexer->Skip (-1);
 				DataBuffer* b = ParseStatement();
 
 				if (b == false)
@@ -374,7 +375,7 @@
 	CheckNotToplevel();
 
 	// Get the name of the label
-	mLexer->MustGetNext (tkAny);
+	mLexer->MustGetNext (tkSymbol);
 
 	// Find the mark this goto statement points to
 	String target = GetTokenString();
@@ -492,7 +493,6 @@
 
 	// Initializer
 	mLexer->MustGetNext (tkParenStart);
-	mLexer->MustGetNext (tkAny);
 	DataBuffer* init = ParseStatement();
 
 	if (init == null)
@@ -509,7 +509,6 @@
 	mLexer->MustGetNext (tkSemicolon);
 
 	// Incrementor
-	mLexer->MustGetNext (tkAny);
 	DataBuffer* incr = ParseStatement();
 
 	if (incr == null)
@@ -1192,7 +1191,7 @@
 DataBuffer* BotscriptParser::ParseStatement()
 {
 	// If it's a variable, expect assignment.
-	if (TokenIs (tkDollarSign))
+	if (mLexer->GetNext (tkDollarSign))
 	{
 		mLexer->MustGetNext (tkSymbol);
 		ScriptVariable* var = FindGlobalVariable (GetTokenString());

mercurial