aboutsummaryrefslogtreecommitdiff
path: root/src/parser/parse_tree.cpp
diff options
context:
space:
mode:
authorClément Zrounba <clement.zrounba@ec-lyon.fr>2023-11-14 17:45:45 +0000
committerClément Zrounba <clement.zrounba@ec-lyon.fr>2023-11-14 18:17:32 +0000
commitc8450b94be661a6d9d9d2718cc16befa4a5abae9 (patch)
tree099732f9f114d2cb3d20765664bfdbebe9fd719b /src/parser/parse_tree.cpp
parent1b0780d225707f2cd71e82eaab8df5318cd72bae (diff)
downloadspecs-c8450b94be661a6d9d9d2718cc16befa4a5abae9.tar.gz
specs-c8450b94be661a6d9d9d2718cc16befa4a5abae9.zip
Improve parsing
- Make multi-file more robust - Error reporting is more accurate (shows file:line and prints offending string) - Allow `.include` directives in subcircuits
Diffstat (limited to 'src/parser/parse_tree.cpp')
-rw-r--r--src/parser/parse_tree.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/parser/parse_tree.cpp b/src/parser/parse_tree.cpp
index 76c67b0..bbafeb8 100644
--- a/src/parser/parse_tree.cpp
+++ b/src/parser/parse_tree.cpp
@@ -1,6 +1,7 @@
#include "parse_tree.h"
#include "parse_directive.h"
#include "parse_element.h"
+#include "parser_state.h"
#include "specs.h"
#include <sstream>
@@ -310,9 +311,10 @@ ParseTree::ParseTree(const string &name, const ParseSubcircuit &subcircuit, cons
}
yyscan_t scanner;
+ ParserState *parser_state = new ParserState;
YY_BUFFER_STATE buf;
- yylex_init(&scanner);
+ yylex_init_extra(parser_state, &scanner);
buf = yy_scan_string(subcircuit.netlist.c_str(), scanner);
yy_switch_to_buffer(buf, scanner);
@@ -320,6 +322,7 @@ ParseTree::ParseTree(const string &name, const ParseSubcircuit &subcircuit, cons
//yy_delete_buffer(buf, scanner);
yylex_destroy(scanner);
+ delete parser_state;
// Return if unsuccessful
if (parsing_result != 0) {