-
Notifications
You must be signed in to change notification settings - Fork 62
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
#132 Add a CMake build for C++ port #133
Conversation
5145871
to
14478bd
Compare
@@ -188,7 +188,7 @@ bool CodeCompletionCore::translateStackToRuleIndex(RuleWithStartTokenList const& | |||
if (translateRulesTopDown) { | |||
// Loop over the rule stack from lowest to highest rule level. This will prioritize a lower preferred rule | |||
// if it is a child of a higher one that is also a preferred rule. | |||
for (size_t i = ruleWithStartTokenList.size() - 1; i >= 0; i--) { | |||
for (int64_t i = ruleWithStartTokenList.size() - 1; i >= 0; i--) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here was a possible bug with overflow, which can cause an infinite loop. Caught by compiler with warnings enabled :)
return { | ||
.sets = sets, | ||
.combined = combined, | ||
.isExhaustive = isExhaustive, | ||
.combined = combined | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to fix compiler warning about parameters ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, what an effort to make this work, but nice to see you have thought about every aspect!
return { | ||
.sets = sets, | ||
.combined = combined, | ||
.isExhaustive = isExhaustive, | ||
.combined = combined | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with that syntax. Is that C++20? Only know that from Swift (with a different meaning).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand, it is called Aggregate Initialization and exists to simplify object creation. Something like named args for trivial autogenerated by compiler constructors.
So it lets you initialize plain structs this way:
struct Point {
std::size_t x;
std::size_t y;
}
Point point = {.x = 10, .y = 10};
It is since C++20
.
ports/cpp/test/expr/ExprTest.cpp
Outdated
// FIXME: it returns empty lists as tokens are ignored, but in TS not | ||
// EXPECT_THAT(candidates.tokens[ExprLexer::VAR], | ||
// UnorderedElementsAre(ExprLexer::ID, ExprLexer::EQUAL)); | ||
// EXPECT_THAT(candidates.tokens[ExprLexer::LET], | ||
// UnorderedElementsAre(ExprLexer::ID, ExprLexer::EQUAL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an interesting thing, because this port gives us an empty following token list, as that tokens were ignored.
Java
port has the same behavior, that can be observed here.
But TypeScript
tells us a different story.
What is a desired behavior? I propose just to document this "feature" is in the tests to begin with.
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
c64205c
to
9114c2d
Compare
ports/cpp/CMakeLists.txt
Outdated
@@ -0,0 +1,24 @@ | |||
cmake_minimum_required(VERSION 3.7) | |||
project(antlr4-c3 VERSION 0.1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is an actual version of C++
port? I would like to keep it with zero major version for now because it is still in progress, because of some major CMake
structure changes may be required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very fond of a zero major version for published libraries, but ok, let's start with 0.1.0.
This CMake project structure was inspired by the project twist and many others, that I |
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
Oh, I eventually defeated that problem with an absence of @mike-lischke, the PR is ready for review. |
@@ -0,0 +1 @@ | |||
# ANTLRv4 C3 C++ Port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a bit more information, like required C++ and CMake versions and some instructions to build and run the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Signed-off-by: vityaman <[email protected]>
Signed-off-by: vityaman <[email protected]>
@@ -0,0 +1,24 @@ | |||
cmake_minimum_required(VERSION 3.7) | |||
project(antlr4-c3 VERSION 1.1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering the previous version as "1.0.0", "1.1.0" means the addition of CMake build.
Thanks! |
The part of issue #132.
libantlr4-c3.a
that is statically linked withlibantlr4-runtime.a
.GTest
withGMock
,Java
port test forExpr.g4
was ported.ANTLRv4 Runtime
via downloadingv4.13.1
distribution.ANTLRv4 Tool
via downloading fromwww.antlr.org
.lldb
by pressing aF5
key atVSCode
,clangd
forVSCode
support.Adding this library as a dependency via
FetchContent
or something like this is not supported, because requiring to write some config and adding some demo project to test it.There are not all changes here. Planning to add in the nearest future at next PRs: