From b6a33cf4c6c66d364986d7f652c8574953fac4d9 Mon Sep 17 00:00:00 2001
From: Mike Buland <eichlan@xagasoft.com>
Date: Wed, 8 Feb 2012 09:47:20 -0700
Subject: Fixed lexer issue on -, precidence of comparisons.

---
 bloodfields.stage |  9 +++++----
 src/parser.l      |  4 ++--
 src/parser.y      |  2 +-
 src/variable.h    | 20 ++++++++++----------
 4 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/bloodfields.stage b/bloodfields.stage
index 38e3370..bfef7ba 100644
--- a/bloodfields.stage
+++ b/bloodfields.stage
@@ -94,14 +94,15 @@ function look()
 
 function mkEnemy()
 {
-	eid = random( 0, 2 );
+	eid = random( 0, count(global.enemyTypes) - 1 );
 	global.enemy = global.enemyTypes[eid];
 
-	mod = player.level - 1;
-	if mod > 2 then
+	mod = player.level;
+	if mod > count(global.enemyMods) then
 	{
-		mod = 2;
+		mod = count(global.enemyMods);
 	}
+	mod -= 1;
 	global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' +
 		global.enemy['name'];
 	global.enemy['attack'] += global.enemyMods[mod]['attack'];
diff --git a/src/parser.l b/src/parser.l
index 70704b8..950c209 100644
--- a/src/parser.l
+++ b/src/parser.l
@@ -72,7 +72,7 @@ null							{ return tokNull; }
 
 [a-zA-Z_][a-zA-Z0-9_]*			{ yylval->sValue = new Bu::String( yytext ); return tokIdent; }
 
--?[1-9][0-9]*					{
+[1-9][0-9]*						{
 	yylval->iValue = strtoll( yytext, NULL, 10 );
 	return tokInt;
 }
@@ -81,7 +81,7 @@ null							{ return tokNull; }
 	return tokInt;
 }
 
--?([1-9][0-9]*|0)?\.[0-9]*		{
+([1-9][0-9]*|0)?\.[0-9]*		{
 //	printf("Parsing float: %s\n", yytext );
 	yylval->dValue = strtod( yytext, NULL );
 //	printf("Final float: %f\n", yylval->dValue );
diff --git a/src/parser.y b/src/parser.y
index 47c0159..0358e48 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -87,9 +87,9 @@ void yyerror( YYLTYPE *llocp, yyscan_t yyscanner, GameBuilder &, const char *err
 %left NOT
 %right '=' tokPlusAssign tokMinusAssign tokTimesAssign tokDivideAssign
 %left tokIn tokAnd tokOr
+%right '<' '>' tokLtEq tokGtEq tokCmp
 %left '-' '+'
 %left '*' '/'
-%right '<' '>' tokLtEq tokGtEq tokCmp
 %left '(' ')' '[' ']'
 %left NEG
 
diff --git a/src/variable.h b/src/variable.h
index 2e84ae1..83b6d44 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -25,16 +25,16 @@ friend Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v );
 public:
 	enum Type
 	{
-		tNull,
-		tBool,
-		tInt,
-		tFloat,
-		tSituation,
-		tVariable,
-		tVarPtr,
-		tList,
-		tDictionary,
-		tString,
+		tNull			= 0,
+		tBool			= 1,
+		tInt			= 2,
+		tFloat			= 3,
+		tSituation		= 4,
+		tVariable		= 5,
+		tVarPtr			= 6,
+		tList			= 7,
+		tDictionary		= 8,
+		tString			= 9,
 	};
 
 public:
-- 
cgit v1.2.3