Skip to content

Commit

Permalink
Fixed parser
Browse files Browse the repository at this point in the history
  • Loading branch information
kwrx committed Aug 21, 2021
1 parent 2c841e2 commit f2a72dd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/qasp/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static std::string parsePredicates(const std::vector<Token>& 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))



Expand Down Expand Up @@ -132,10 +132,24 @@ static std::string parsePredicates(const std::vector<Token>& 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;
Expand All @@ -144,6 +158,8 @@ static std::string parsePredicates(const std::vector<Token>& tokens, std::vector

}



} else {

if(unlikely(!EXPECT(it, TK_DOT) && !EXPECT(it, TK_COMMA))) {
Expand Down

0 comments on commit f2a72dd

Please sign in to comment.