exit with error on csml brace mismatch

This commit is contained in:
anon 2023-11-18 02:07:07 +01:00
parent 56094fbf56
commit 5485e6bdd7
3 changed files with 8 additions and 1 deletions

View File

@ -8,7 +8,7 @@
#include "html_special.hpp"
#include "global.hpp"
static std::stack<std::string> tag_stack;
std::stack<std::string> tag_stack;
static std::string tag_candidate = "";
static

View File

@ -3,4 +3,5 @@ enum {
UNKNOWN_OPTION = 1,
IO_ERROR = 2,
UNKNOWN_SET = 3,
POPULATED_STACK = 4, // most likely signals that more tags were opened than closed, ie the user forgot adding a '}' somewhere
};

View File

@ -5,12 +5,15 @@
#include <libgen.h>
#include <vector>
#include <string>
#include <stack>
#include <map>
#include "cli.hpp"
#include "scanner.hpp"
#include "exit_values.hpp"
extern std::stack<std::string> tag_stack;
#define DECLARE_LEXER(x) \
extern FILE * x ## in; \
extern FILE * x ## out; \
@ -149,6 +152,9 @@ signed main(int argc, char * * argv) {
switch (input_type) {
case input_type_t::CSML: {
yylex(csmlin, csmlout, csmllex);
if (not tag_stack.empty()) {
exit(POPULATED_STACK);
}
} break;
case input_type_t::XML: {
yylex(xmlin, xmlout, xmllex);