Skip to content

Commit 2837272

Browse files
feat: Allow variables to have delimiters (introduces #116). (#114)
1 parent 73bc321 commit 2837272

File tree

1 file changed

+0
-45
lines changed

1 file changed

+0
-45
lines changed

src/log_surgeon/LogParser.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -94,51 +94,6 @@ auto LogParser::add_rules(std::unique_ptr<SchemaAST> schema_ast) -> void {
9494
// check if regex contains a delimiter
9595
std::array<bool, cSizeOfUnicode> is_possible_input{};
9696
rule->m_regex_ptr->set_possible_inputs_to_true(is_possible_input);
97-
bool contains_delimiter = false;
98-
uint32_t delimiter_name = 0;
99-
for (uint32_t delimiter : delimiters) {
100-
if (is_possible_input[delimiter]) {
101-
contains_delimiter = true;
102-
delimiter_name = delimiter;
103-
break;
104-
}
105-
}
106-
107-
// Error out if non-timestamp pattern contains a delimiter
108-
if (contains_delimiter) {
109-
FileReader schema_reader;
110-
ErrorCode error_code = schema_reader.try_open(schema_ast->m_file_path);
111-
if (ErrorCode::Success != error_code) {
112-
throw std::runtime_error(
113-
schema_ast->m_file_path + ":" + to_string(rule->m_line_num + 1)
114-
+ ": error: '" + rule->m_name
115-
+ "' has regex pattern which contains delimiter '" + char(delimiter_name)
116-
+ "'.\n"
117-
);
118-
}
119-
// more detailed debugging based on looking at the file
120-
string line;
121-
for (uint32_t i = 0; i <= rule->m_line_num; i++) {
122-
schema_reader.try_read_to_delimiter('\n', false, false, line);
123-
}
124-
uint32_t colon_pos = 0;
125-
for (char i : line) {
126-
colon_pos++;
127-
if (i == ':') {
128-
break;
129-
}
130-
}
131-
string indent(10, ' ');
132-
string spaces(colon_pos, ' ');
133-
string arrows(line.size() - colon_pos, '^');
134-
135-
throw std::runtime_error(
136-
schema_ast->m_file_path + ":" + to_string(rule->m_line_num + 1) + ": error: '"
137-
+ rule->m_name + "' has regex pattern which contains delimiter '"
138-
+ char(delimiter_name) + "'.\n" + indent + line + "\n" + indent + spaces
139-
+ arrows + "\n"
140-
);
141-
}
14297

14398
// For log-specific lexing: modify variable regex to contain a delimiter at the start.
14499
unique_ptr<RegexASTGroup<ByteNfaState>> delimiter_group

0 commit comments

Comments
 (0)