summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-02-08 09:47:20 -0700
committerMike Buland <eichlan@xagasoft.com>2012-02-08 09:47:20 -0700
commitb6a33cf4c6c66d364986d7f652c8574953fac4d9 (patch)
treed18e84ec3750ff774239dd73f724a2005889b9b8
parent33b6c34a20545222088f645bbc3cc5610f7cc782 (diff)
downloadstage-b6a33cf4c6c66d364986d7f652c8574953fac4d9.tar.gz
stage-b6a33cf4c6c66d364986d7f652c8574953fac4d9.tar.bz2
stage-b6a33cf4c6c66d364986d7f652c8574953fac4d9.tar.xz
stage-b6a33cf4c6c66d364986d7f652c8574953fac4d9.zip
Fixed lexer issue on -, precidence of comparisons.
-rw-r--r--bloodfields.stage9
-rw-r--r--src/parser.l4
-rw-r--r--src/parser.y2
-rw-r--r--src/variable.h20
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()
94 94
95function mkEnemy() 95function mkEnemy()
96{ 96{
97 eid = random( 0, 2 ); 97 eid = random( 0, count(global.enemyTypes) - 1 );
98 global.enemy = global.enemyTypes[eid]; 98 global.enemy = global.enemyTypes[eid];
99 99
100 mod = player.level - 1; 100 mod = player.level;
101 if mod > 2 then 101 if mod > count(global.enemyMods) then
102 { 102 {
103 mod = 2; 103 mod = count(global.enemyMods);
104 } 104 }
105 mod -= 1;
105 global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' + 106 global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' +
106 global.enemy['name']; 107 global.enemy['name'];
107 global.enemy['attack'] += global.enemyMods[mod]['attack']; 108 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; }
72 72
73[a-zA-Z_][a-zA-Z0-9_]* { yylval->sValue = new Bu::String( yytext ); return tokIdent; } 73[a-zA-Z_][a-zA-Z0-9_]* { yylval->sValue = new Bu::String( yytext ); return tokIdent; }
74 74
75-?[1-9][0-9]* { 75[1-9][0-9]* {
76 yylval->iValue = strtoll( yytext, NULL, 10 ); 76 yylval->iValue = strtoll( yytext, NULL, 10 );
77 return tokInt; 77 return tokInt;
78} 78}
@@ -81,7 +81,7 @@ null { return tokNull; }
81 return tokInt; 81 return tokInt;
82} 82}
83 83
84-?([1-9][0-9]*|0)?\.[0-9]* { 84([1-9][0-9]*|0)?\.[0-9]* {
85// printf("Parsing float: %s\n", yytext ); 85// printf("Parsing float: %s\n", yytext );
86 yylval->dValue = strtod( yytext, NULL ); 86 yylval->dValue = strtod( yytext, NULL );
87// printf("Final float: %f\n", yylval->dValue ); 87// 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
87%left NOT 87%left NOT
88%right '=' tokPlusAssign tokMinusAssign tokTimesAssign tokDivideAssign 88%right '=' tokPlusAssign tokMinusAssign tokTimesAssign tokDivideAssign
89%left tokIn tokAnd tokOr 89%left tokIn tokAnd tokOr
90%right '<' '>' tokLtEq tokGtEq tokCmp
90%left '-' '+' 91%left '-' '+'
91%left '*' '/' 92%left '*' '/'
92%right '<' '>' tokLtEq tokGtEq tokCmp
93%left '(' ')' '[' ']' 93%left '(' ')' '[' ']'
94%left NEG 94%left NEG
95 95
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 );
25public: 25public:
26 enum Type 26 enum Type
27 { 27 {
28 tNull, 28 tNull = 0,
29 tBool, 29 tBool = 1,
30 tInt, 30 tInt = 2,
31 tFloat, 31 tFloat = 3,
32 tSituation, 32 tSituation = 4,
33 tVariable, 33 tVariable = 5,
34 tVarPtr, 34 tVarPtr = 6,
35 tList, 35 tList = 7,
36 tDictionary, 36 tDictionary = 8,
37 tString, 37 tString = 9,
38 }; 38 };
39 39
40public: 40public: