Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump antlr #111

Merged
merged 7 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,14 @@ repos:
- --safe
- --target-version=py38
exclude: ^src/pytsql/grammar/
- repo: https://github.com/Quantco/pre-commit-mirrors-flake8
rev: 6.1.0
- repo: https://github.com/Quantco/pre-commit-mirrors-ruff
rev: 0.1.3
hooks:
- id: flake8-conda
exclude: ^src/pytsql/grammar/
- repo: https://github.com/Quantco/pre-commit-mirrors-isort
rev: 5.12.0
hooks:
- id: isort-conda
additional_dependencies: [toml]
- id: ruff-conda
exclude: ^src/pytsql/grammar/
- repo: https://github.com/Quantco/pre-commit-mirrors-mypy
rev: "1.5.1"
hooks:
- id: mypy-conda
additional_dependencies: [ -c, conda-forge, types-setuptools ]
exclude: ^src/pytsql/grammar/
- repo: https://github.com/Quantco/pre-commit-mirrors-pyupgrade
rev: 3.13.0
hooks:
- id: pyupgrade-conda
exclude: ^src/pytsql/grammar/
args:
- --py38-plus
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
- sphinxcontrib-apidoc
- sqlalchemy>=1.4
- pyodbc
- speedy-antlr-tool==1.4.1
- antlr4-python3-runtime==4.11.1
- speedy-antlr-tool==1.4.3
- antlr4-python3-runtime==4.13.1
- click
- openjdk
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,24 @@ default_section = 'THIRDPARTY'
[[tool.mypy.overrides]]
module = "pytsql.grammar.*"
follow_imports = "silent"

[tool.ruff]
ignore = ["E501", "N803", "N806"]
line-length = 88
select = [
# pyflakes
"F",
# pycodestyle
"E", "W",
# isort
"I",
# pep8-naming
"N",
# pyupgrade
"UP",
]
target-version = "py38"
exclude=["src/pytsql/grammar/**/*.py"]

[tool.ruff.isort]
known-first-party = ["pytsql"]
4 changes: 2 additions & 2 deletions src/pytsql/grammar/TSqlLexer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated from TSqlLexer.g4 by ANTLR 4.11.1
# Generated from TSqlLexer.g4 by ANTLR 4.13.1
from antlr4 import *
from io import StringIO
import sys
Expand Down Expand Up @@ -7781,7 +7781,7 @@ class TSqlLexer(Lexer):

def __init__(self, input=None, output:TextIO = sys.stdout):
super().__init__(input, output)
self.checkVersion("4.11.1")
self.checkVersion("4.13.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None
Expand Down
146 changes: 73 additions & 73 deletions src/pytsql/grammar/TSqlParser.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/pytsql/grammar/TSqlParserListener.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated from TSqlParser.g4 by ANTLR 4.11.1
# Generated from TSqlParser.g4 by ANTLR 4.13.1
from antlr4 import *
if __name__ is not None and "." in __name__:
if "." in __name__:
from .TSqlParser import TSqlParser
svengiegerich marked this conversation as resolved.
Show resolved Hide resolved
else:
from TSqlParser import TSqlParser
Expand Down
15 changes: 14 additions & 1 deletion src/pytsql/grammar/cpp_src/TSqlLexer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from TSqlLexer.g4 by ANTLR 4.11.1
// Generated from TSqlLexer.g4 by ANTLR 4.13.1


#include "TSqlLexer.h"
Expand Down Expand Up @@ -42,10 +42,19 @@ struct TSqlLexerStaticData final {
};

::antlr4::internal::OnceFlag tsqllexerLexerOnceFlag;
#if ANTLR4_USE_THREAD_LOCAL_CACHE
static thread_local
#endif
TSqlLexerStaticData *tsqllexerLexerStaticData = nullptr;

void tsqllexerLexerInitialize() {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
if (tsqllexerLexerStaticData != nullptr) {
return;
}
#else
assert(tsqllexerLexerStaticData == nullptr);
#endif
auto staticData = std::make_unique<TSqlLexerStaticData>(
std::vector<std::string>{
"ABORT", "ABORT_AFTER_WAIT", "ABSENT", "ABSOLUTE", "ACCELERATED_DATABASE_RECOVERY",
Expand Down Expand Up @@ -6160,5 +6169,9 @@ const atn::ATN& TSqlLexer::getATN() const {


void TSqlLexer::initialize() {
#if ANTLR4_USE_THREAD_LOCAL_CACHE
tsqllexerLexerInitialize();
#else
::antlr4::internal::call_once(tsqllexerLexerOnceFlag, tsqllexerLexerInitialize);
#endif
}
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/TSqlLexer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#undef PLATFORM
// Generated from TSqlLexer.g4 by ANTLR 4.11.1
// Generated from TSqlLexer.g4 by ANTLR 4.13.1

#pragma once

Expand Down
1,795 changes: 904 additions & 891 deletions src/pytsql/grammar/cpp_src/TSqlParser.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/TSqlParser.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from TSqlParser.g4 by ANTLR 4.11.1
// Generated from TSqlParser.g4 by ANTLR 4.13.1

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/TSqlParserBaseVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from TSqlParser.g4 by ANTLR 4.11.1
// Generated from TSqlParser.g4 by ANTLR 4.13.1


#include "TSqlParserBaseVisitor.h"
Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/TSqlParserBaseVisitor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from TSqlParser.g4 by ANTLR 4.11.1
// Generated from TSqlParser.g4 by ANTLR 4.13.1

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/TSqlParserVisitor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from TSqlParser.g4 by ANTLR 4.11.1
// Generated from TSqlParser.g4 by ANTLR 4.13.1


#include "TSqlParserVisitor.h"
Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/TSqlParserVisitor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Generated from TSqlParser.g4 by ANTLR 4.11.1
// Generated from TSqlParser.g4 by ANTLR 4.13.1

#pragma once

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/sa_tsql_cpp_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file was auto-generated by speedy-antlr-tool v1.4.1
* This file was auto-generated by speedy-antlr-tool v1.4.3
* https://github.com/amykyta3/speedy-antlr-tool
*/

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/sa_tsql_translator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file was auto-generated by speedy-antlr-tool v1.4.1
* This file was auto-generated by speedy-antlr-tool v1.4.3
* https://github.com/amykyta3/speedy-antlr-tool
*/

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/sa_tsql_translator.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file was auto-generated by speedy-antlr-tool v1.4.1
* This file was auto-generated by speedy-antlr-tool v1.4.3
* https://github.com/amykyta3/speedy-antlr-tool
*/

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/speedy_antlr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file was auto-generated by speedy-antlr-tool v1.4.1
* This file was auto-generated by speedy-antlr-tool v1.4.3
* https://github.com/amykyta3/speedy-antlr-tool
*/

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/cpp_src/speedy_antlr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This file was auto-generated by speedy-antlr-tool v1.4.1
* This file was auto-generated by speedy-antlr-tool v1.4.3
* https://github.com/amykyta3/speedy-antlr-tool
*/

Expand Down
2 changes: 1 addition & 1 deletion src/pytsql/grammar/sa_tsql.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was auto-generated by speedy-antlr-tool v1.4.1
# This file was auto-generated by speedy-antlr-tool v1.4.3
# https://github.com/amykyta3/speedy-antlr-tool

import sys
Expand Down
10 changes: 5 additions & 5 deletions src/pytsql/tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def visit(

return " ".join(dynamics + chunks)

def visitChildren(self, node: antlr4.ParserRuleContext) -> List[str]:
def visitChildren(self, node: antlr4.ParserRuleContext) -> List[str]: # noqa: N802
if isinstance(node, TSqlParser.Print_statementContext):
# Print statements are replaced by inserts into a temporary table so that they can be evaluated
# at the right time and fetched afterwards.
Expand All @@ -129,20 +129,20 @@ def visitChildren(self, node: antlr4.ParserRuleContext) -> List[str]:

return result

def visitTerminal(self, node: antlr4.TerminalNode) -> List[str]:
def visitTerminal(self, node: antlr4.TerminalNode) -> List[str]: # noqa: N802
return [str(node)]

def defaultResult(self) -> List[str]:
def defaultResult(self) -> List[str]: # noqa: N802
return []

def aggregateResult(
def aggregateResult( # noqa: N802
self, aggregate: List[str], next_result: List[str]
) -> List[str]:
return aggregate + next_result


class _RaisingErrorListener(SA_ErrorListener):
def syntaxError(
def syntaxError( # noqa: N802
self,
input_stream: InputStream,
offendingSymbol: Optional[Token],
Expand Down
Loading