Skip to content

Commit

Permalink
feat(hog): parser updates for lambdas (#24575)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Aug 27, 2024
1 parent 4cb0b9e commit 397919d
Show file tree
Hide file tree
Showing 26 changed files with 3,530 additions and 3,575 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-hog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ jobs:
antlr | grep "Version"
npm run grammar:build && git diff --exit-code
env:
# Installing a version of ANTLR compatible with what's in Homebrew as of October 2023 (version 4.13),
# Installing a version of ANTLR compatible with what's in Homebrew as of August 2024 (version 4.13.2),
# as apt-get is quite out of date. The same version must be set in hogql_parser/pyproject.toml
ANTLR_VERSION: '4.13.1'
ANTLR_VERSION: '4.13.2'

- name: Run HogVM Python tests
if: needs.changes.outputs.hog == 'true'
Expand Down
6 changes: 3 additions & 3 deletions hogql_parser/HogQLLexer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLLexer.g4 by ANTLR 4.13.1
// Generated from HogQLLexer.g4 by ANTLR 4.13.2


#include "HogQLLexer.h"
Expand Down Expand Up @@ -45,7 +45,7 @@ ::antlr4::internal::OnceFlag hogqllexerLexerOnceFlag;
#if ANTLR4_USE_THREAD_LOCAL_CACHE
static thread_local
#endif
HogQLLexerStaticData *hogqllexerLexerStaticData = nullptr;
std::unique_ptr<HogQLLexerStaticData> hogqllexerLexerStaticData = nullptr;

void hogqllexerLexerInitialize() {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
Expand Down Expand Up @@ -673,7 +673,7 @@ void hogqllexerLexerInitialize() {
for (size_t i = 0; i < count; i++) {
staticData->decisionToDFA.emplace_back(staticData->atn->getDecisionState(i), i);
}
hogqllexerLexerStaticData = staticData.release();
hogqllexerLexerStaticData = std::move(staticData);
}

}
Expand Down
2 changes: 1 addition & 1 deletion hogql_parser/HogQLLexer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLLexer.g4 by ANTLR 4.13.1
// Generated from HogQLLexer.g4 by ANTLR 4.13.2

#pragma once

Expand Down
3,325 changes: 1,589 additions & 1,736 deletions hogql_parser/HogQLParser.cpp

Large diffs are not rendered by default.

95 changes: 45 additions & 50 deletions hogql_parser/HogQLParser.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLParser.g4 by ANTLR 4.13.1
// Generated from HogQLParser.g4 by ANTLR 4.13.2

#pragma once

Expand Down Expand Up @@ -61,16 +61,15 @@ class HogQLParser : public antlr4::Parser {
RuleSettingExprList = 47, RuleSettingExpr = 48, RuleWindowExpr = 49,
RuleWinPartitionByClause = 50, RuleWinOrderByClause = 51, RuleWinFrameClause = 52,
RuleWinFrameExtend = 53, RuleWinFrameBound = 54, RuleExpr = 55, RuleColumnTypeExpr = 56,
RuleColumnExprList = 57, RuleColumnExpr = 58, RuleColumnArgList = 59,
RuleColumnArgExpr = 60, RuleColumnLambdaExpr = 61, RuleHogqlxTagElement = 62,
RuleHogqlxTagAttribute = 63, RuleWithExprList = 64, RuleWithExpr = 65,
RuleColumnIdentifier = 66, RuleNestedIdentifier = 67, RuleTableExpr = 68,
RuleTableFunctionExpr = 69, RuleTableIdentifier = 70, RuleTableArgList = 71,
RuleDatabaseIdentifier = 72, RuleFloatingLiteral = 73, RuleNumberLiteral = 74,
RuleLiteral = 75, RuleInterval = 76, RuleKeyword = 77, RuleKeywordForAlias = 78,
RuleAlias = 79, RuleIdentifier = 80, RuleEnumValue = 81, RulePlaceholder = 82,
RuleString = 83, RuleTemplateString = 84, RuleStringContents = 85, RuleFullTemplateString = 86,
RuleStringContentsFull = 87
RuleColumnExprList = 57, RuleColumnExpr = 58, RuleColumnLambdaExpr = 59,
RuleHogqlxTagElement = 60, RuleHogqlxTagAttribute = 61, RuleWithExprList = 62,
RuleWithExpr = 63, RuleColumnIdentifier = 64, RuleNestedIdentifier = 65,
RuleTableExpr = 66, RuleTableFunctionExpr = 67, RuleTableIdentifier = 68,
RuleTableArgList = 69, RuleDatabaseIdentifier = 70, RuleFloatingLiteral = 71,
RuleNumberLiteral = 72, RuleLiteral = 73, RuleInterval = 74, RuleKeyword = 75,
RuleKeywordForAlias = 76, RuleAlias = 77, RuleIdentifier = 78, RuleEnumValue = 79,
RulePlaceholder = 80, RuleString = 81, RuleTemplateString = 82, RuleStringContents = 83,
RuleFullTemplateString = 84, RuleStringContentsFull = 85
};

explicit HogQLParser(antlr4::TokenStream *input);
Expand Down Expand Up @@ -149,8 +148,6 @@ class HogQLParser : public antlr4::Parser {
class ColumnTypeExprContext;
class ColumnExprListContext;
class ColumnExprContext;
class ColumnArgListContext;
class ColumnArgExprContext;
class ColumnLambdaExprContext;
class HogqlxTagElementContext;
class HogqlxTagAttributeContext;
Expand Down Expand Up @@ -1567,16 +1564,18 @@ class HogQLParser : public antlr4::Parser {
public:
ColumnExprWinFunctionTargetContext(ColumnExprContext *ctx);

HogQLParser::ColumnExprListContext *columnExprs = nullptr;
HogQLParser::ColumnExprListContext *columnArgList = nullptr;
std::vector<IdentifierContext *> identifier();
IdentifierContext* identifier(size_t i);
antlr4::tree::TerminalNode *OVER();
std::vector<antlr4::tree::TerminalNode *> LPAREN();
antlr4::tree::TerminalNode* LPAREN(size_t i);
std::vector<antlr4::tree::TerminalNode *> RPAREN();
antlr4::tree::TerminalNode* RPAREN(size_t i);
ColumnExprListContext *columnExprList();
std::vector<ColumnExprListContext *> columnExprList();
ColumnExprListContext* columnExprList(size_t i);
antlr4::tree::TerminalNode *DISTINCT();
ColumnArgListContext *columnArgList();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};
Expand Down Expand Up @@ -1638,6 +1637,18 @@ class HogQLParser : public antlr4::Parser {
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};

class ColumnExprCallContext : public ColumnExprContext {
public:
ColumnExprCallContext(ColumnExprContext *ctx);

ColumnExprContext *columnExpr();
antlr4::tree::TerminalNode *LPAREN();
antlr4::tree::TerminalNode *RPAREN();
ColumnExprListContext *columnExprList();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};

class ColumnExprArrayAccessContext : public ColumnExprContext {
public:
ColumnExprArrayAccessContext(ColumnExprContext *ctx);
Expand Down Expand Up @@ -1786,16 +1797,27 @@ class HogQLParser : public antlr4::Parser {
public:
ColumnExprWinFunctionContext(ColumnExprContext *ctx);

HogQLParser::ColumnExprListContext *columnExprs = nullptr;
HogQLParser::ColumnExprListContext *columnArgList = nullptr;
IdentifierContext *identifier();
antlr4::tree::TerminalNode *OVER();
std::vector<antlr4::tree::TerminalNode *> LPAREN();
antlr4::tree::TerminalNode* LPAREN(size_t i);
WindowExprContext *windowExpr();
std::vector<antlr4::tree::TerminalNode *> RPAREN();
antlr4::tree::TerminalNode* RPAREN(size_t i);
ColumnExprListContext *columnExprList();
std::vector<ColumnExprListContext *> columnExprList();
ColumnExprListContext* columnExprList(size_t i);
antlr4::tree::TerminalNode *DISTINCT();
ColumnArgListContext *columnArgList();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};

class ColumnExprLambdaContext : public ColumnExprContext {
public:
ColumnExprLambdaContext(ColumnExprContext *ctx);

ColumnLambdaExprContext *columnLambdaExpr();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};
Expand All @@ -1813,14 +1835,16 @@ class HogQLParser : public antlr4::Parser {
public:
ColumnExprFunctionContext(ColumnExprContext *ctx);

HogQLParser::ColumnExprListContext *columnExprs = nullptr;
HogQLParser::ColumnExprListContext *columnArgList = nullptr;
IdentifierContext *identifier();
std::vector<antlr4::tree::TerminalNode *> LPAREN();
antlr4::tree::TerminalNode* LPAREN(size_t i);
std::vector<antlr4::tree::TerminalNode *> RPAREN();
antlr4::tree::TerminalNode* RPAREN(size_t i);
antlr4::tree::TerminalNode *DISTINCT();
ColumnArgListContext *columnArgList();
ColumnExprListContext *columnExprList();
std::vector<ColumnExprListContext *> columnExprList();
ColumnExprListContext* columnExprList(size_t i);

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};
Expand All @@ -1838,46 +1862,17 @@ class HogQLParser : public antlr4::Parser {

ColumnExprContext* columnExpr();
ColumnExprContext* columnExpr(int precedence);
class ColumnArgListContext : public antlr4::ParserRuleContext {
public:
ColumnArgListContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
std::vector<ColumnArgExprContext *> columnArgExpr();
ColumnArgExprContext* columnArgExpr(size_t i);
std::vector<antlr4::tree::TerminalNode *> COMMA();
antlr4::tree::TerminalNode* COMMA(size_t i);


virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;

};

ColumnArgListContext* columnArgList();

class ColumnArgExprContext : public antlr4::ParserRuleContext {
public:
ColumnArgExprContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
ColumnLambdaExprContext *columnLambdaExpr();
ColumnExprContext *columnExpr();


virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;

};

ColumnArgExprContext* columnArgExpr();

class ColumnLambdaExprContext : public antlr4::ParserRuleContext {
public:
ColumnLambdaExprContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
antlr4::tree::TerminalNode *ARROW();
ColumnExprContext *columnExpr();
antlr4::tree::TerminalNode *LPAREN();
std::vector<IdentifierContext *> identifier();
IdentifierContext* identifier(size_t i);
antlr4::tree::TerminalNode *RPAREN();
ColumnExprContext *columnExpr();
BlockContext *block();
std::vector<antlr4::tree::TerminalNode *> COMMA();
antlr4::tree::TerminalNode* COMMA(size_t i);

Expand Down
4 changes: 1 addition & 3 deletions hogql_parser/HogQLParser.interp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion hogql_parser/HogQLParserBaseVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLParser.g4 by ANTLR 4.13.1
// Generated from HogQLParser.g4 by ANTLR 4.13.2


#include "HogQLParserBaseVisitor.h"
Expand Down
18 changes: 9 additions & 9 deletions hogql_parser/HogQLParserBaseVisitor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLParser.g4 by ANTLR 4.13.1
// Generated from HogQLParser.g4 by ANTLR 4.13.2

#pragma once

Expand Down Expand Up @@ -375,6 +375,10 @@ class HogQLParserBaseVisitor : public HogQLParserVisitor {
return visitChildren(ctx);
}

virtual std::any visitColumnExprCall(HogQLParser::ColumnExprCallContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitColumnExprArrayAccess(HogQLParser::ColumnExprArrayAccessContext *ctx) override {
return visitChildren(ctx);
}
Expand Down Expand Up @@ -427,23 +431,19 @@ class HogQLParserBaseVisitor : public HogQLParserVisitor {
return visitChildren(ctx);
}

virtual std::any visitColumnExprIdentifier(HogQLParser::ColumnExprIdentifierContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitColumnExprFunction(HogQLParser::ColumnExprFunctionContext *ctx) override {
virtual std::any visitColumnExprLambda(HogQLParser::ColumnExprLambdaContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitColumnExprAsterisk(HogQLParser::ColumnExprAsteriskContext *ctx) override {
virtual std::any visitColumnExprIdentifier(HogQLParser::ColumnExprIdentifierContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitColumnArgList(HogQLParser::ColumnArgListContext *ctx) override {
virtual std::any visitColumnExprFunction(HogQLParser::ColumnExprFunctionContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitColumnArgExpr(HogQLParser::ColumnArgExprContext *ctx) override {
virtual std::any visitColumnExprAsterisk(HogQLParser::ColumnExprAsteriskContext *ctx) override {
return visitChildren(ctx);
}

Expand Down
2 changes: 1 addition & 1 deletion hogql_parser/HogQLParserVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLParser.g4 by ANTLR 4.13.1
// Generated from HogQLParser.g4 by ANTLR 4.13.2


#include "HogQLParserVisitor.h"
Expand Down
10 changes: 5 additions & 5 deletions hogql_parser/HogQLParserVisitor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from HogQLParser.g4 by ANTLR 4.13.1
// Generated from HogQLParser.g4 by ANTLR 4.13.2

#pragma once

Expand Down Expand Up @@ -199,6 +199,8 @@ class HogQLParserVisitor : public antlr4::tree::AbstractParseTreeVisitor {

virtual std::any visitColumnExprTuple(HogQLParser::ColumnExprTupleContext *context) = 0;

virtual std::any visitColumnExprCall(HogQLParser::ColumnExprCallContext *context) = 0;

virtual std::any visitColumnExprArrayAccess(HogQLParser::ColumnExprArrayAccessContext *context) = 0;

virtual std::any visitColumnExprBetween(HogQLParser::ColumnExprBetweenContext *context) = 0;
Expand All @@ -225,16 +227,14 @@ class HogQLParserVisitor : public antlr4::tree::AbstractParseTreeVisitor {

virtual std::any visitColumnExprWinFunction(HogQLParser::ColumnExprWinFunctionContext *context) = 0;

virtual std::any visitColumnExprLambda(HogQLParser::ColumnExprLambdaContext *context) = 0;

virtual std::any visitColumnExprIdentifier(HogQLParser::ColumnExprIdentifierContext *context) = 0;

virtual std::any visitColumnExprFunction(HogQLParser::ColumnExprFunctionContext *context) = 0;

virtual std::any visitColumnExprAsterisk(HogQLParser::ColumnExprAsteriskContext *context) = 0;

virtual std::any visitColumnArgList(HogQLParser::ColumnArgListContext *context) = 0;

virtual std::any visitColumnArgExpr(HogQLParser::ColumnArgExprContext *context) = 0;

virtual std::any visitColumnLambdaExpr(HogQLParser::ColumnLambdaExprContext *context) = 0;

virtual std::any visitHogqlxTagElementClosed(HogQLParser::HogqlxTagElementClosedContext *context) = 0;
Expand Down
Loading

0 comments on commit 397919d

Please sign in to comment.