Skip to content
Snippets Groups Projects
Commit 52e37112 authored by Ondřej Štorc's avatar Ondřej Štorc
Browse files

cli: Check parser output before transforming AST

parent e2e66a22
No related branches found
No related tags found
1 merge request!256Parser replacement with ANTLR
...@@ -38,12 +38,17 @@ std::unique_ptr<CommandList> Parser2::parse(antlr4::CharStream& stream) ...@@ -38,12 +38,17 @@ std::unique_ptr<CommandList> Parser2::parse(antlr4::CharStream& stream)
parser.setErrorHandler(std::make_shared<antlr4::DefaultErrorStrategy>()); parser.setErrorHandler(std::make_shared<antlr4::DefaultErrorStrategy>());
   
AltCliParser::ParseContext* tree = parser.parse(); AltCliParser::ParseContext* tree = parser.parse();
auto command = AltVisitor().transform(tree);
if (listener->any()) { if (listener->any()) {
throw exception::CommonException(listener->getErrors()); throw exception::CommonException(listener->getErrors());
} }
   
if (tree == nullptr) {
throw exception::CommonException("Invalid parse");
}
auto command = AltVisitor().transform(tree);
return command; return command;
} }
} // cli } // cli
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment