diff --git a/stella/src/debugger/DebuggerParser.cxx b/stella/src/debugger/DebuggerParser.cxx index bb1a3ecfd..c378b1f0e 100644 --- a/stella/src/debugger/DebuggerParser.cxx +++ b/stella/src/debugger/DebuggerParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: DebuggerParser.cxx,v 1.51 2005-07-12 02:27:06 urchlay Exp $ +// $Id: DebuggerParser.cxx,v 1.52 2005-07-13 02:54:13 urchlay Exp $ //============================================================================ #include "bspf.hxx" @@ -876,6 +876,7 @@ bool DebuggerParser::validateArgs(int cmd) { // main entry point: PromptWidget calls this method. string DebuggerParser::run(const string& command) { + static Expression *lastExpression; int i=0; // special case: parser testing @@ -884,7 +885,13 @@ string DebuggerParser::run(const string& command) { int status = YaccParser::parse(command.c_str() + 5); commandResult += debugger->valueToString(status); commandResult += ", result=="; - commandResult += debugger->valueToString(YaccParser::getResult()); + lastExpression = YaccParser::getResult(); + commandResult += debugger->valueToString(lastExpression->evaluate()); + return commandResult; + } + + if(command == "expr") { + commandResult = "result==" + debugger->valueToString(lastExpression->evaluate()); return commandResult; } diff --git a/stella/src/debugger/EqualsExpression.cxx b/stella/src/debugger/EqualsExpression.cxx new file mode 100644 index 000000000..be6f395ad --- /dev/null +++ b/stella/src/debugger/EqualsExpression.cxx @@ -0,0 +1,27 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: EqualsExpression.cxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +//============================================================================ + +#include "Expression.hxx" +#include "EqualsExpression.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +EqualsExpression::EqualsExpression(Expression *left, Expression *right) + : Expression(left, right) +{ +} + diff --git a/stella/src/debugger/EqualsExpression.hxx b/stella/src/debugger/EqualsExpression.hxx new file mode 100644 index 000000000..d7fdd4604 --- /dev/null +++ b/stella/src/debugger/EqualsExpression.hxx @@ -0,0 +1,39 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: EqualsExpression.hxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +//============================================================================ + +#ifndef EQUALS_EXPRESSION_HXX +#define EQUALS_EXPRESSION_HXX + +#include "Expression.hxx" + +/** + This class provides an implementation of an constant expression; + that is, one that consists solely of a constant integer value. + + @author B. Watson + @version $Id: EqualsExpression.hxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +*/ +class EqualsExpression : public Expression +{ + public: + EqualsExpression(Expression *left, Expression *right); + int evaluate() { return myLHS->evaluate() == myRHS->evaluate(); } +}; + +#endif + diff --git a/stella/src/debugger/MinusExpression.cxx b/stella/src/debugger/MinusExpression.cxx new file mode 100644 index 000000000..e2d6158ff --- /dev/null +++ b/stella/src/debugger/MinusExpression.cxx @@ -0,0 +1,27 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: MinusExpression.cxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +//============================================================================ + +#include "Expression.hxx" +#include "MinusExpression.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +MinusExpression::MinusExpression(Expression *left, Expression *right) + : Expression(left, right) +{ +} + diff --git a/stella/src/debugger/MinusExpression.hxx b/stella/src/debugger/MinusExpression.hxx new file mode 100644 index 000000000..8cf197ba9 --- /dev/null +++ b/stella/src/debugger/MinusExpression.hxx @@ -0,0 +1,39 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: MinusExpression.hxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +//============================================================================ + +#ifndef MINUS_EXPRESSION_HXX +#define MINUS_EXPRESSION_HXX + +#include "Expression.hxx" + +/** + This class provides an implementation of an constant expression; + that is, one that consists solely of a constant integer value. + + @author B. Watson + @version $Id: MinusExpression.hxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +*/ +class MinusExpression : public Expression +{ + public: + MinusExpression(Expression *left, Expression *right); + int evaluate() { return myLHS->evaluate() - myRHS->evaluate(); } +}; + +#endif + diff --git a/stella/src/debugger/PlusExpression.cxx b/stella/src/debugger/PlusExpression.cxx new file mode 100644 index 000000000..898f05ffa --- /dev/null +++ b/stella/src/debugger/PlusExpression.cxx @@ -0,0 +1,27 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: PlusExpression.cxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +//============================================================================ + +#include "Expression.hxx" +#include "PlusExpression.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +PlusExpression::PlusExpression(Expression *left, Expression *right) + : Expression(left, right) +{ +} + diff --git a/stella/src/debugger/PlusExpression.hxx b/stella/src/debugger/PlusExpression.hxx new file mode 100644 index 000000000..95dc1810a --- /dev/null +++ b/stella/src/debugger/PlusExpression.hxx @@ -0,0 +1,39 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2005 by Bradford W. Mott and the Stella team +// +// See the file "license" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +// +// $Id: PlusExpression.hxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +//============================================================================ + +#ifndef PLUS_EXPRESSION_HXX +#define PLUS_EXPRESSION_HXX + +#include "Expression.hxx" + +/** + This class provides an implementation of an constant expression; + that is, one that consists solely of a constant integer value. + + @author B. Watson + @version $Id: PlusExpression.hxx,v 1.1 2005-07-13 02:54:13 urchlay Exp $ +*/ +class PlusExpression : public Expression +{ + public: + PlusExpression(Expression *left, Expression *right); + int evaluate() { return myLHS->evaluate() + myRHS->evaluate(); } +}; + +#endif + diff --git a/stella/src/debugger/module.mk b/stella/src/debugger/module.mk index dde32993a..eb070438e 100644 --- a/stella/src/debugger/module.mk +++ b/stella/src/debugger/module.mk @@ -6,6 +6,9 @@ MODULE_OBJS := \ src/debugger/EquateList.o \ src/debugger/Expression.o \ src/debugger/ConstExpression.o \ + src/debugger/EqualsExpression.o \ + src/debugger/PlusExpression.o \ + src/debugger/MinusExpression.o \ src/debugger/PackedBitArray.o \ src/debugger/CpuDebug.o \ src/debugger/RamDebug.o \ diff --git a/stella/src/yacc/Makefile.yacc b/stella/src/yacc/Makefile.yacc index 561f22185..4fd3da4ad 100644 --- a/stella/src/yacc/Makefile.yacc +++ b/stella/src/yacc/Makefile.yacc @@ -8,9 +8,9 @@ all: stella.y calctest: stella.y calctest.c YaccParser.cxx YaccParser.hxx bison -y -d stella.y - g++ -DPRINT -O2 -c YaccParser.cxx - g++ -O2 -c calctest.c - g++ -O2 -Wall -o calctest calctest.o YaccParser.o + g++ -DPRINT -I../debugger -O2 -c YaccParser.cxx + g++ -DBM -I../debugger -O2 -c calctest.c + g++ -I../debugger -O2 -Wall -o calctest calctest.o YaccParser.o ../debugger/*Expression.o strip calctest #clean: diff --git a/stella/src/yacc/YaccParser.cxx b/stella/src/yacc/YaccParser.cxx index a9ae5f7f6..4ecf52daa 100644 --- a/stella/src/yacc/YaccParser.cxx +++ b/stella/src/yacc/YaccParser.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: YaccParser.cxx,v 1.2 2005-07-03 14:18:54 stephena Exp $ +// $Id: YaccParser.cxx,v 1.3 2005-07-13 02:54:13 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -21,21 +21,27 @@ //#include "YaccParser.hxx" -#ifdef __cplusplus -extern "C" { -#endif +//#ifdef __cplusplus +//extern "C" { +//#endif + +#include "Expression.hxx" +#include "PlusExpression.hxx" +#include "MinusExpression.hxx" +#include "EqualsExpression.hxx" +#include "ConstExpression.hxx" namespace YaccParser { #include #include -int result; -//#include "y.tab.h" +#include "y.tab.h" +yystype result; #include "y.tab.c" -int getResult() { - return result; +Expression *getResult() { + return result.exp; } @@ -72,12 +78,12 @@ int parse(const char *in) { int yylex() { char o, p; - yylval = 0; + yylval.val = 0; while(*c != '\0') { //fprintf(stderr, "looking at %c, state %d\n", *c, state); switch(state) { case ST_SPACE: - yylval = 0; + yylval.val = 0; if(isspace(*c)) { c++; } else if(isdigit(*c)) { @@ -92,8 +98,8 @@ int yylex() { case ST_NUMBER: while(isdigit(*c)) { - yylval *= 10; - yylval += (*c++ - '0'); + yylval.val *= 10; + yylval.val += (*c++ - '0'); //fprintf(stderr, "yylval==%d, *c==%c\n", yylval, *c); } state = ST_DEFAULT; @@ -152,7 +158,7 @@ int yylex() { case ST_DEFAULT: default: - yylval = 0; + yylval.val = 0; if(isspace(*c)) { state = ST_SPACE; } else if(isdigit(*c)) { @@ -160,8 +166,8 @@ int yylex() { } else if(is_operator(*c)) { state = ST_OPERATOR; } else { - yylval = *c++; - return yylval; + yylval.val = *c++; + return yylval.val; } break; } @@ -184,6 +190,6 @@ int main(int argc, char **argv) { #endif } -#ifdef __cplusplus -} -#endif +//#ifdef __cplusplus +//} +//#endif diff --git a/stella/src/yacc/YaccParser.hxx b/stella/src/yacc/YaccParser.hxx index 8e4280c8e..d7a84e489 100644 --- a/stella/src/yacc/YaccParser.hxx +++ b/stella/src/yacc/YaccParser.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: YaccParser.hxx,v 1.2 2005-07-03 14:18:54 stephena Exp $ +// $Id: YaccParser.hxx,v 1.3 2005-07-13 02:54:13 urchlay Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -22,17 +22,19 @@ #ifndef PARSER_HXX #define PARSER_HXX -#ifdef __cplusplus -extern "C" { -#endif +#include "Expression.hxx" + +//#ifdef __cplusplus +//extern "C" { +//#endif namespace YaccParser { int parse(const char *); - int getResult(); + Expression *getResult(); }; -#ifdef __cplusplus -} -#endif +//#ifdef __cplusplus +//} +//#endif #endif diff --git a/stella/src/yacc/calctest.c b/stella/src/yacc/calctest.c index a9aab6125..2e3a16101 100644 --- a/stella/src/yacc/calctest.c +++ b/stella/src/yacc/calctest.c @@ -11,13 +11,16 @@ int main(int argc, char **argv) { #ifndef BM YaccParser::parse(argv[1]); - printf("\n= %d\n", YaccParser::getResult()); + printf("\n= %d\n", YaccParser::getResult()->evaluate()); #else - char buf[10]; + char buf[30]; - for(int i=0; i<1000000; i++) { - sprintf(buf, "(1<2)&(3+4)"); - YaccParser::parse(buf); + sprintf(buf, "1+2+3+4+5+6+7"); + YaccParser::parse(buf); + Expression *e = YaccParser::getResult(); + + for(int i=0; i<100000000; i++) { + printf("%d\n", e->evaluate()); } #endif diff --git a/stella/src/yacc/stella.y b/stella/src/yacc/stella.y index 3149bb085..720f58f78 100644 --- a/stella/src/yacc/stella.y +++ b/stella/src/yacc/stella.y @@ -13,7 +13,12 @@ void yyerror(char *e) { %} -%token NUMBER +%union { + int val; + Expression *exp; +} + +%token NUMBER %left '-' '+' %left '*' '/' '%' %left LOG_OR @@ -24,45 +29,51 @@ void yyerror(char *e) { %nonassoc '<' '>' GTE LTE NE EQ %nonassoc UMINUS +%type expression + %% -statement: expression { result = $1; } +statement: expression { fprintf(stderr, "\ndone\n"); result.exp = $1; } ; -expression: expression '+' expression { fprintf(stderr, " +"); $$ = $1 + $3; } - | expression '-' expression { fprintf(stderr, " -"); $$ = $1 - $3; } - | expression '*' expression { fprintf(stderr, " *"); $$ = $1 * $3; } +expression: expression '+' expression { fprintf(stderr, " +"); $$ = new PlusExpression($1, $3); } + | expression '-' expression { fprintf(stderr, " -"); $$ = new MinusExpression($1, $3); } + | expression '*' expression { fprintf(stderr, " *"); } | expression '/' expression { fprintf(stderr, " /"); +/* if($3 == 0) yyerror("divide by zero"); else $$ = $1 / $3; +*/ } | expression '%' expression { fprintf(stderr, " %"); +/* if($3 == 0) yyerror("divide by zero"); else $$ = $1 % $3; +*/ } - | expression '&' expression { fprintf(stderr, " &"); $$ = $1 & $3; } - | expression '|' expression { fprintf(stderr, " |"); $$ = $1 | $3; } - | expression '^' expression { fprintf(stderr, " ^"); $$ = $1 ^ $3; } - | expression '>' expression { fprintf(stderr, " <"); $$ = $1 > $3; } - | expression '<' expression { fprintf(stderr, " >"); $$ = $1 < $3; } - | expression GTE expression { fprintf(stderr, " >="); $$ = $1 >= $3; } - | expression LTE expression { fprintf(stderr, " <="); $$ = $1 <= $3; } - | expression NE expression { fprintf(stderr, " !="); $$ = $1 != $3; } - | expression EQ expression { fprintf(stderr, " =="); $$ = $1 == $3; } - | expression SHR expression { fprintf(stderr, " >>"); $$ = $1 >> $3; } - | expression SHL expression { fprintf(stderr, " >>"); $$ = $1 << $3; } - | expression LOG_OR expression { fprintf(stderr, " ||"); $$ = $1 || $3; } - | expression LOG_AND expression { fprintf(stderr, " &&"); $$ = $1 && $3; } - | '-' expression %prec UMINUS { fprintf(stderr, " U-"); $$ = -$2; } - | '~' expression %prec UMINUS { fprintf(stderr, " ~"); $$ = (~$2) & 0xffff; } - | '<' expression { fprintf(stderr, " <"); $$ = $2 & 0xff; } - | '>' expression { fprintf(stderr, " >"); $$ = ($2 >> 8) & 0xff; } - | '(' expression ')' { fprintf(stderr, " ()"); $$ = $2; } - | NUMBER { fprintf(stderr, " %d", $1); } + | expression '&' expression { fprintf(stderr, " &"); } + | expression '|' expression { fprintf(stderr, " |"); } + | expression '^' expression { fprintf(stderr, " ^"); } + | expression '>' expression { fprintf(stderr, " <"); } + | expression '<' expression { fprintf(stderr, " >"); } + | expression GTE expression { fprintf(stderr, " >="); } + | expression LTE expression { fprintf(stderr, " <="); } + | expression NE expression { fprintf(stderr, " !="); } + | expression EQ expression { fprintf(stderr, " =="); $$ = new EqualsExpression($1, $3); } + | expression SHR expression { fprintf(stderr, " >>"); } + | expression SHL expression { fprintf(stderr, " >>"); } + | expression LOG_OR expression { fprintf(stderr, " ||"); } + | expression LOG_AND expression { fprintf(stderr, " &&"); } + | '-' expression %prec UMINUS { fprintf(stderr, " U-"); } + | '~' expression %prec UMINUS { fprintf(stderr, " ~"); } + | '<' expression { fprintf(stderr, " <"); } + | '>' expression { fprintf(stderr, " >"); } + | '(' expression ')' { fprintf(stderr, " ()"); } + | NUMBER { fprintf(stderr, " %d", $1); $$ = new ConstExpression($1); } ; %% diff --git a/stella/src/yacc/y.tab.c b/stella/src/yacc/y.tab.c index 58811ac0d..528b61126 100644 --- a/stella/src/yacc/y.tab.c +++ b/stella/src/yacc/y.tab.c @@ -28,8 +28,14 @@ void yyerror(char *e) { fprintf(stderr, "%s\n", e); } + +#line 16 "stella.y" #ifndef YYSTYPE -# define YYSTYPE int +typedef union { + int val; + Expression *exp; +} yystype; +# define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif #ifndef YYDEBUG @@ -104,9 +110,9 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 28, 31, 32, 33, 34, 41, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, - 61, 62, 63, 64, 65, 66 + 0, 35, 38, 39, 40, 41, 50, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77 }; #endif @@ -923,114 +929,118 @@ yyreduce: switch (yyn) { case 1: -#line 28 "stella.y" -{ result = yyvsp[0]; } +#line 35 "stella.y" +{ fprintf(stderr, "\ndone\n"); result.exp = yyvsp[0].exp; } break; case 2: -#line 31 "stella.y" -{ fprintf(stderr, " +"); yyval = yyvsp[-2] + yyvsp[0]; } +#line 38 "stella.y" +{ fprintf(stderr, " +"); yyval.exp = new PlusExpression(yyvsp[-2].exp, yyvsp[0].exp); } break; case 3: -#line 32 "stella.y" -{ fprintf(stderr, " -"); yyval = yyvsp[-2] - yyvsp[0]; } +#line 39 "stella.y" +{ fprintf(stderr, " -"); yyval.exp = new MinusExpression(yyvsp[-2].exp, yyvsp[0].exp); } break; case 4: -#line 33 "stella.y" -{ fprintf(stderr, " *"); yyval = yyvsp[-2] * yyvsp[0]; } +#line 40 "stella.y" +{ fprintf(stderr, " *"); } break; case 5: -#line 35 "stella.y" +#line 42 "stella.y" { fprintf(stderr, " /"); - if(yyvsp[0] == 0) +/* + if($3 == 0) yyerror("divide by zero"); else - yyval = yyvsp[-2] / yyvsp[0]; + $$ = $1 / $3; +*/ } break; case 6: -#line 42 "stella.y" +#line 51 "stella.y" { fprintf(stderr, " %"); - if(yyvsp[0] == 0) +/* + if($3 == 0) yyerror("divide by zero"); else - yyval = yyvsp[-2] % yyvsp[0]; + $$ = $1 % $3; +*/ } break; case 7: -#line 48 "stella.y" -{ fprintf(stderr, " &"); yyval = yyvsp[-2] & yyvsp[0]; } +#line 59 "stella.y" +{ fprintf(stderr, " &"); } break; case 8: -#line 49 "stella.y" -{ fprintf(stderr, " |"); yyval = yyvsp[-2] | yyvsp[0]; } +#line 60 "stella.y" +{ fprintf(stderr, " |"); } break; case 9: -#line 50 "stella.y" -{ fprintf(stderr, " ^"); yyval = yyvsp[-2] ^ yyvsp[0]; } +#line 61 "stella.y" +{ fprintf(stderr, " ^"); } break; case 10: -#line 51 "stella.y" -{ fprintf(stderr, " <"); yyval = yyvsp[-2] > yyvsp[0]; } +#line 62 "stella.y" +{ fprintf(stderr, " <"); } break; case 11: -#line 52 "stella.y" -{ fprintf(stderr, " >"); yyval = yyvsp[-2] < yyvsp[0]; } +#line 63 "stella.y" +{ fprintf(stderr, " >"); } break; case 12: -#line 53 "stella.y" -{ fprintf(stderr, " >="); yyval = yyvsp[-2] >= yyvsp[0]; } +#line 64 "stella.y" +{ fprintf(stderr, " >="); } break; case 13: -#line 54 "stella.y" -{ fprintf(stderr, " <="); yyval = yyvsp[-2] <= yyvsp[0]; } +#line 65 "stella.y" +{ fprintf(stderr, " <="); } break; case 14: -#line 55 "stella.y" -{ fprintf(stderr, " !="); yyval = yyvsp[-2] != yyvsp[0]; } +#line 66 "stella.y" +{ fprintf(stderr, " !="); } break; case 15: -#line 56 "stella.y" -{ fprintf(stderr, " =="); yyval = yyvsp[-2] == yyvsp[0]; } +#line 67 "stella.y" +{ fprintf(stderr, " =="); yyval.exp = new EqualsExpression(yyvsp[-2].exp, yyvsp[0].exp); } break; case 16: -#line 57 "stella.y" -{ fprintf(stderr, " >>"); yyval = yyvsp[-2] >> yyvsp[0]; } +#line 68 "stella.y" +{ fprintf(stderr, " >>"); } break; case 17: -#line 58 "stella.y" -{ fprintf(stderr, " >>"); yyval = yyvsp[-2] << yyvsp[0]; } +#line 69 "stella.y" +{ fprintf(stderr, " >>"); } break; case 18: -#line 59 "stella.y" -{ fprintf(stderr, " ||"); yyval = yyvsp[-2] || yyvsp[0]; } +#line 70 "stella.y" +{ fprintf(stderr, " ||"); } break; case 19: -#line 60 "stella.y" -{ fprintf(stderr, " &&"); yyval = yyvsp[-2] && yyvsp[0]; } +#line 71 "stella.y" +{ fprintf(stderr, " &&"); } break; case 20: -#line 61 "stella.y" -{ fprintf(stderr, " U-"); yyval = -yyvsp[0]; } +#line 72 "stella.y" +{ fprintf(stderr, " U-"); } break; case 21: -#line 62 "stella.y" -{ fprintf(stderr, " ~"); yyval = (~yyvsp[0]) & 0xffff; } +#line 73 "stella.y" +{ fprintf(stderr, " ~"); } break; case 22: -#line 63 "stella.y" -{ fprintf(stderr, " <"); yyval = yyvsp[0] & 0xff; } +#line 74 "stella.y" +{ fprintf(stderr, " <"); } break; case 23: -#line 64 "stella.y" -{ fprintf(stderr, " >"); yyval = (yyvsp[0] >> 8) & 0xff; } +#line 75 "stella.y" +{ fprintf(stderr, " >"); } break; case 24: -#line 65 "stella.y" -{ fprintf(stderr, " ()"); yyval = yyvsp[-1]; } +#line 76 "stella.y" +{ fprintf(stderr, " ()"); } break; case 25: -#line 66 "stella.y" -{ fprintf(stderr, " %d", yyvsp[0]); } +#line 77 "stella.y" +{ fprintf(stderr, " %d", yyvsp[0].val); yyval.exp = new ConstExpression(yyvsp[0].val); } break; } @@ -1265,5 +1275,5 @@ yyreturn: #endif return yyresult; } -#line 68 "stella.y" +#line 79 "stella.y" diff --git a/stella/src/yacc/y.tab.h b/stella/src/yacc/y.tab.h index eced98741..5f10ee2a1 100644 --- a/stella/src/yacc/y.tab.h +++ b/stella/src/yacc/y.tab.h @@ -1,10 +1,14 @@ #ifndef BISON_Y_TAB_H # define BISON_Y_TAB_H -# ifndef YYSTYPE -# define YYSTYPE int -# define YYSTYPE_IS_TRIVIAL 1 -# endif +#ifndef YYSTYPE +typedef union { + int val; + Expression *exp; +} yystype; +# define YYSTYPE yystype +# define YYSTYPE_IS_TRIVIAL 1 +#endif # define NUMBER 257 # define LOG_OR 258 # define LOG_AND 259