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

Feature/semantic #253

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

Conversation

thamindumk
Copy link

add semantic analyzer

Dockerfile Outdated
@@ -16,6 +16,23 @@ RUN if [ "$DEBUG" = "true" ]; then apt-get update \
&& apt-get install --no-install-recommends -y gdb gdbserver \
&& apt-get clean; fi

WORKDIR "${HOME}"
RUN mkdir antlr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, variable HOME is pointing to /home/ubuntu. This antlr folder should get created inside the following path. Not at HOME.
/home/ubuntu/software

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sir, I'll put into this location, "/home/ubuntu/software". but after moving the generated files in to JasmineGraph, we don't need this folder anymore then this home/ubuntu/antlr folder get cleared.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

frontend_logger.log("AST is succssusfully analyzed", "log");
}else
{
frontend_logger.error("query isn't semantically correct");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets add the query also as part of the error message. This will give more details and support for debugging.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sir I will add.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

#include "ASTLeafValue.h"
#include "/home/ubuntu/software/jasminegraph/code_generated/antlr/CypherBaseVisitor.h"

any visitOC_Cypher(CypherParser::OC_CypherContext *ctx) ;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reorder the appearance of the function definitions in alphabetical order of the letters appearing after _. For example visitOC_Cypher we should use the letter C and the y if needed for alphabetical sorting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order is very similar to hierarchy of the cypher grammar rule set. and this order was defined by antlr4 then it can be helpful for debugging. if it is necessary, I can re-order it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case lets not re-order the functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sir.




any ASTBuilder::visitOC_Cypher(CypherParser::OC_CypherContext *ctx) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets arrange these function declarations also based on the order of the function definitions appearance.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the order is very similar to hierarchy of the cypher grammar rule set. and this order was defined by antlr4 then it can be helpful for debugging. if it is necessary, I can re-arrange it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case lets not re-order the functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sir.

Copy link
Owner

@miyurud miyurud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put some comments. Please address each of them and explain how you handled it.

{
return false;
}
}else if(root->nodeType == "VARIABLE")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these literals to some constants and refer them here? I see same literal repeated several times here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure sir, I will do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

sir, is it okay to move the constants to the const.cpp file in the util folder ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Its ok the way you have set the util folder currently.

}else if (root->nodeType == "AS")
{
string ntype;
if (root->elements[0]->nodeType == "LIST" || root->elements[0]->nodeType == "LIST_COMPREHENSION")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can there be scenario where root->elements becoming null?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sir, it cannot be null, but it can be empty.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok


// Report errors
void SemanticAnalyzer::reportError(const std::string &message, ASTNode* node) {
std::cerr << "Error: " << message << std::endl;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a logger here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure sir, I will fix that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but there are some further changes required. Please check my new comments.

Copy link
Owner

@miyurud miyurud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have put some comments on this PR. Please address them all and explain in each comment on how you addressed those.

CMakeLists.txt Outdated
)

if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_compile_options(-DUNIT_TEST)
endif ()

add_library(JasmineGraphLib ${HEADERS} ${SOURCES})
file(GLOB GENERATED_SRC ${CMAKE_SOURCE_DIR}/code_generated/antlr/*.cpp)
Copy link
Owner

@miyurud miyurud Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where we will have the code_generated folder in the directory structure?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

home/ubuntu/software/jasminegraph/code_generated/antlr/*.cpp

this is the path to the code_generated folder

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Dockerfile Outdated
@@ -1,4 +1,4 @@
FROM miyurud/jasminegraph-prerequisites:20240101T095619
FROM pre:latest
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we change the base image here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was mistakenly commited my locally used prerequisite image. now I edited it and push it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link

sonarcloud bot commented Oct 31, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants