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 jdev52's avatar jdev52

fixed operator! not working

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