This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

Commit 6869de04 authored by Jonathan Evans's avatar Jonathan Evans

fixed operator! not working

parent 3a54b5fc
......@@ -57,7 +57,8 @@ struct TYPE_INFO
int operatorType;
int operatorInstance;
operator bool(){
operator bool()
{
if(type == BOOL){
return value.boolean;
}
......@@ -65,7 +66,7 @@ struct TYPE_INFO
}
bool operator!(){
return !(*this);
return !(bool(*this));
}
// man I really wish I had c++20's operator<=>/operator semantics right now
......@@ -126,7 +127,7 @@ struct TYPE_INFO
os << rhs.value.text;
break;
case BOOL:
os << rhs.value.boolean;
os << ((rhs.value.boolean)?"t":"nil");
break;
default:
throw std::invalid_argument("invalid type at print");
......
......@@ -105,7 +105,7 @@ N_START : // epsilon
break;
}
*/
cout << "---- Completed parsing ----\n" << endl;
cout << "\n---- Completed parsing ----\n" << endl;
cout << "\nValue of the expression is: ";
cout << $2 <<"\n";
}
......@@ -456,7 +456,7 @@ N_ID_EXPR_LIST : /* epsilon */
| N_ID_EXPR_LIST T_LPAREN T_IDENT N_EXPR T_RPAREN
{
string lexeme = string($3);
printf("___Adding %s to symbol table\n", $3);
// printf("___Adding %s to symbol table\n", $3);
bool found = scopeStack.top().findEntry(lexeme);
if (found){
yyerror("Multiply defined identifier");
......@@ -611,13 +611,13 @@ void printToken(const char* tokenType, char* lexeme){
void beginScope()
{
scopeStack.push(SYMBOL_TABLE());
printf("\n___Entering new scope...\n\n");
// printf("\n___Entering new scope...\n\n");
}
void endScope()
{
scopeStack.pop();
printf("\n___Exiting scope...\n\n");
// printf("\n___Exiting scope...\n\n");
}
bool findEntryInAnyScope(const string theName)
......@@ -685,6 +685,7 @@ int main(int argc, char** argv)
{
yyparse();
}
while (!feof(yyin));
while (!feof(yyin));
bail();
return 0;
}
---- Completed parsing ----
Value of the expression is: 60
Bye!
___Entering new scope...
___Adding bob to symbol table
___Adding fish to symbol table
___Entering new scope...
___Adding x to symbol table
___Exiting scope...
___Adding sandwich to symbol table
___Exiting scope...
---- Completed parsing ----
Value of the expression is: 0
Bye!
---- Completed parsing ----
Value of the expression is: 20
Bye!
---- Completed parsing ----
Value of the expression is: 100
Bye!
---- Completed parsing ----
Value of the expression is: 100
Bye!
---- Completed parsing ----
Value of the expression is: "false"
Bye!
---- Completed parsing ----
Value of the expression is: 100
Bye!
---- Completed parsing ----
Value of the expression is: -42
Bye!
___Entering new scope...
___Adding x to symbol table
___Adding y to symbol table
___Adding z to symbol table
34848944
___Exiting scope...
26185904
---- Completed parsing ----
Value of the expression is: 0
Bye!
___Entering new scope...
___Adding x to symbol table
___Adding y to symbol table
___Adding z to symbol table
28856496
28856496
___Exiting scope...
34783408
34783408
---- Completed parsing ----
Value of the expression is: 0
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
___Entering new scope...
___Adding x to symbol table
___Entering new scope...
___Adding y to symbol table
___Entering new scope...
___Adding z to symbol table
___Entering new scope...
___Adding w to symbol table
___Entering new scope...
___Adding p to symbol table
___Exiting scope...
___Exiting scope...
___Exiting scope...
___Exiting scope...
___Exiting scope...
---- Completed parsing ----
Value of the expression is: 0
Bye!
---- Completed parsing ----
Value of the expression is: 0
Value of the expression is: nil
Bye!
---- Completed parsing ----
Value of the expression is: nil
Bye!
---- Completed parsing ----
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: nil
Bye!
---- Completed parsing ----
Value of the expression is: nil
Bye!
"shake"
---- Completed parsing ----
Value of the expression is: "shake"
Bye!
0
nil
---- Completed parsing ----
Value of the expression is: 0
Value of the expression is: nil
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: 0
Value of the expression is: nil
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
---- Completed parsing ----
Value of the expression is: "hello kitty!"
Bye!
---- Completed parsing ----
Value of the expression is: 1
Value of the expression is: t
Bye!
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment