partial start of implementation for interpreter
This commit is contained in:
		
							
								
								
									
										9
									
								
								interpreter.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								interpreter.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | ||||
| // | ||||
| // interpreter.cpp | ||||
| // curly | ||||
| // | ||||
| // Created by Bob Polis at 2020-09-05 | ||||
| // Copyright (c) 2020 SwiftCoder. All rights reserved. | ||||
| // | ||||
|  | ||||
| #include "interpreter.hpp" | ||||
							
								
								
									
										73
									
								
								interpreter.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								interpreter.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| // | ||||
| // interpreter.hpp | ||||
| // curly | ||||
| // | ||||
| // Created by Bob Polis at 2020-09-05 | ||||
| // Copyright (c) 2020 SwiftCoder. All rights reserved. | ||||
| // | ||||
|  | ||||
| #ifndef _interpreter_H_ | ||||
| #define _interpreter_H_ | ||||
|  | ||||
| #include <iostream> | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #include <map> | ||||
|  | ||||
| class interpreter { | ||||
|     public: | ||||
|         interpreter() = default; | ||||
|  | ||||
|         std::string eval(std::istream& in); | ||||
|  | ||||
|     private: | ||||
|         std::vector<std::string> _ops; | ||||
|         std::map<std::string, std::vector<std::string>> _funs; | ||||
|  | ||||
|         // integer operations | ||||
|         void add(); | ||||
|         void sub(); | ||||
|         void mul(); | ||||
|         void div(); | ||||
|         void mod(); | ||||
|         void abs(); | ||||
|         void neg(); | ||||
|         void dup(); | ||||
|         void inc(); | ||||
|         void dec(); | ||||
|  | ||||
|         // string operations | ||||
|         void rev(); | ||||
|         void slc(); | ||||
|         void idx(); | ||||
|         void cat(); | ||||
|         void len(); | ||||
|         void rot(); | ||||
|  | ||||
|         // tests | ||||
|         void teq(); | ||||
|         void tne(); | ||||
|         void tlt(); | ||||
|         void tle(); | ||||
|         void tgt(); | ||||
|         void tge(); | ||||
|  | ||||
|         // blocks | ||||
|         void end(); | ||||
|          | ||||
|         // conditionals | ||||
|         void ift(); | ||||
|         void els(); | ||||
|  | ||||
|         // loops | ||||
|         void whl(); | ||||
|  | ||||
|         // functions | ||||
|         void fun(); | ||||
|         void run(); | ||||
|  | ||||
|         // solution | ||||
|         void sol(); | ||||
| }; | ||||
|  | ||||
| #endif // _interpreter_H_ | ||||
		Reference in New Issue
	
	Block a user