- blargh. buffers weren't initialized properly

Sun, 02 Feb 2014 18:07:06 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 02 Feb 2014 18:07:06 +0200
changeset 89
029a330a9bef
parent 88
5def6ff8b466
child 90
90ab2f2b3dc0

- blargh. buffers weren't initialized properly

src/Lexer.cc file | annotate | diff | comparison | revisions
src/Lexer.h file | annotate | diff | comparison | revisions
src/Parser.cc file | annotate | diff | comparison | revisions
src/String.cc file | annotate | diff | comparison | revisions
--- a/src/Lexer.cc	Sun Feb 02 17:06:39 2014 +0200
+++ b/src/Lexer.cc	Sun Feb 02 18:07:06 2014 +0200
@@ -198,7 +198,7 @@
 
 // =============================================================================
 //
-void Lexer::MustGetAnyOf (const List< EToken >& toks)
+void Lexer::MustGetAnyOf (const List<EToken>& toks)
 {
 	if (!GetNext())
 		Error ("unexpected EOF");
@@ -304,3 +304,10 @@
 	mTokenPosition = oldpos;
 	return result;
 }
+
+// =============================================================================
+//
+String Lexer::DescribePosition()
+{
+	return Format ("%1 / %2", mTokenPosition - mTokens.begin(), mTokens.Size());
+}
\ No newline at end of file
--- a/src/Lexer.h	Sun Feb 02 17:06:39 2014 +0200
+++ b/src/Lexer.h	Sun Feb 02 18:07:06 2014 +0200
@@ -99,6 +99,7 @@
 	}
 
 	String PeekNextString (int a = 1);
+	String DescribePosition();
 
 private:
 	TokenList		mTokens;
--- a/src/Parser.cc	Sun Feb 02 17:06:39 2014 +0200
+++ b/src/Parser.cc	Sun Feb 02 18:07:06 2014 +0200
@@ -75,6 +75,9 @@
 	// Lex and preprocess the file
 	mLexer->ProcessFile (fileName);
 
+	mMainBuffer = new DataBuffer;
+	mOnEnterBuffer = new DataBuffer;
+	mMainLoopBuffer = new DataBuffer;
 	mCurrentMode = ETopLevelMode;
 	mNumStates = 0;
 	mNumEvents = 0;
@@ -868,16 +871,16 @@
 		Error ("label name `%1` conflicts with variable\n", labelName);
 
 	// See if a mark already exists for this label
-	for (UndefinedLabel& undf : mUndefinedLabels)
+	for (UndefinedLabel& label : mUndefinedLabels)
 	{
-		if (undf.name != labelName)
+		if (label.name != labelName)
 			continue;
 
-		mark = undf.target;
+		mark = label.target;
 		buffer()->AdjustMark (mark);
 
 		// No longer undefined
-		mUndefinedLabels.Remove (undf);
+		mUndefinedLabels.Remove (label);
 		break;
 	}
 
@@ -914,26 +917,22 @@
 	// Number
 	mLexer->MustGetNext (tkNumber);
 	comm->number = mLexer->GetToken()->text.ToLong();
-
 	mLexer->MustGetNext (tkColon);
 
 	// Name
 	mLexer->MustGetNext (tkSymbol);
 	comm->name = mLexer->GetToken()->text;
-
 	mLexer->MustGetNext (tkColon);
 
 	// Return value
 	mLexer->MustGetAnyOf ({tkInt, tkVoid, tkBool, tkStr});
 	comm->returnvalue = GetTypeByName (mLexer->GetToken()->text); // TODO
 	assert (comm->returnvalue != -1);
-
 	mLexer->MustGetNext (tkColon);
 
 	// Num args
 	mLexer->MustGetNext (tkNumber);
 	comm->numargs = mLexer->GetToken()->text.ToLong();
-
 	mLexer->MustGetNext (tkColon);
 
 	// Max args
--- a/src/String.cc	Sun Feb 02 17:06:39 2014 +0200
+++ b/src/String.cc	Sun Feb 02 18:07:06 2014 +0200
@@ -59,8 +59,9 @@
 				copy.RemoveAt (i);
 
 	/*
-	while(( pos = copy.first( c )) != -1 )
-		copy.erase( pos );
+	int pos = 0;
+	while ((pos = copy.First (c)) != -1)
+		copy.RemoveAt (pos--);
 	*/
 
 	return copy;
@@ -72,7 +73,7 @@
 {
 	String newstr = mString;
 
-	for (char & c : newstr)
+	for (char& c : newstr)
 		if (c >= 'a' && c <= 'z')
 			c -= 'a' - 'A';
 

mercurial