aboutsummaryrefslogtreecommitdiff
path: root/Parser.h
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 12:05:45 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2024-06-12 12:05:45 +0200
commit126a3c79516a6417181c3fe924084032d653b596 (patch)
tree1f1d356eccdf7d316cf7e991af036f0c0a6a53bd /Parser.h
parentc084bee21f66e6322d4d55b8700f0779f2c58d0d (diff)
parent8e0a865dd375baa71357ce817847ea8a9144434c (diff)
Merge branch 'master' into node
Diffstat (limited to 'Parser.h')
-rw-r--r--Parser.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/Parser.h b/Parser.h
new file mode 100644
index 0000000..3a86eec
--- /dev/null
+++ b/Parser.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <iostream>
+#include <istream>
+#include <exception>
+
+#include "Circuit.h"
+
+using std::istream;
+using std::string;
+
+class ParserException : public std::exception {
+public:
+ ParserException(const char * fmt, ...);
+ virtual ~ParserException();
+ virtual const char * what();
+
+private:
+ char * error = NULL;
+};
+
+class Parser {
+public:
+ Parser() = default;
+ virtual ~Parser() = default;
+
+ void parse(string input);
+ void parse(istream & input);
+
+ /**
+ * \brief preprocess (filter) line of input
+ *
+ * normalize whitespace and remove comments
+ */
+ static size_t filter(char * input);
+
+ void set_circuit(Circuit & circuit);
+
+private:
+ friend istream & operator << (Parser & parser, istream & s);
+ friend istream & operator >> (istream & s, Parser & parser);
+
+ Circuit * circuit;
+};
+