12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /*
- Parser functions and class definitions for malio interpreter
- For details on specifications of the Malio language, please see:
- https://notabug.org/Malio
- Copyright 2015 - Malio dev team
-
- This file is part of malio-cpp
- malio-cpp is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- malio-cpp is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include <iostream>
- #include <string>
- #include <fstream>
- #include <vector>
- #include <map>
- #ifndef PARSER_H
- #define PARSER_H
- namespace malio {
- // shorthand function that will read the contents of a file:
- int read(std::string filename);
- // line-by-line parser
- std::tuple<std::string, std::string> parse(std::string line);
- // -- Exceptions raised by the interpreter:
- // basic exception class: contains solely a string indicating what
- // kind of error happened.
- class Exception {
- public:
- Exception(std::string err);
- protected:
- std::string errortype;
- };
- // a generic syntax error for malformed statements
- class SyntaxError : public Exception {
- public:
- SyntaxError(std::string what);
- private:
- std::string explanation;
- };
- // error raised when an undeclared name is mentioned, and is not from the
- // malio builtins.
- class NameError : public Exception {
- public:
- NameError(std::string what);
- private:
- std::string explanation;
- };
- } // namespace malio
- #endif
|