From f2a72ddc60e54a62a6ae54bd14e741b0e31bfcd2 Mon Sep 17 00:00:00 2001 From: Antonino Natale Date: Sat, 21 Aug 2021 21:36:21 +0200 Subject: [PATCH] Fixed parser --- src/qasp/parser/Parser.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/qasp/parser/Parser.cpp b/src/qasp/parser/Parser.cpp index 528f8ee..c309c78 100644 --- a/src/qasp/parser/Parser.cpp +++ b/src/qasp/parser/Parser.cpp @@ -94,7 +94,7 @@ static std::string parsePredicates(const std::vector& tokens, std::vector (EXPECT(it, TK_SOURCE) && (isalnum(VALUE(it)) || VALUE(it) == '_')) #define VALID_EXTENSIONS(it) \ - (EXPECT(it, TK_SOURCE) || EXPECT(it, TK_DOT) || EXPECT(it, TK_COMMA)) + (EXPECT(it, TK_SOURCE) || EXPECT(it, TK_DOT) || EXPECT(it, TK_COMMA) || EXPECT(it, TK_LEFT_PAREN) || EXPECT(it, TK_RIGHT_PAREN)) @@ -132,10 +132,24 @@ static std::string parsePredicates(const std::vector& tokens, std::vector if(EXPECT(it, TK_LEFT_PAREN)) { + uint16_t scope = 1; + while(GOOD(++it) && VALID_EXTENSIONS(it)) { - extensions << VALUE(it); + + if(unlikely(EXPECT(it, TK_LEFT_PAREN))) + scope++; + + if(unlikely(EXPECT(it, TK_RIGHT_PAREN))) + scope--; + + if(unlikely(scope == 0)) + break; + + extensions << VALUE(it); + } + if(unlikely(!EXPECT(it, TK_RIGHT_PAREN))) { LOG(__FILE__, ERROR) << "Expected a RIGHT_PAREN after extensions list" << std::endl; @@ -144,6 +158,8 @@ static std::string parsePredicates(const std::vector& tokens, std::vector } + + } else { if(unlikely(!EXPECT(it, TK_DOT) && !EXPECT(it, TK_COMMA))) {