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

Usage questions and comments #19

Open
fruffy opened this issue Feb 24, 2021 · 0 comments
Open

Usage questions and comments #19

fruffy opened this issue Feb 24, 2021 · 0 comments

Comments

@fruffy
Copy link

fruffy commented Feb 24, 2021

First of all, thanks a lot for implementing this tool. I have generated a parser and visitor for the OpenCypher syntax using your generator. Everything has worked well out of the box.
I have two small usability questions about working with the DAG.

Is there a way to get the type of a node using a helper function? Right now I am using a hacky method:
ruleNames[parserNode.get_rule_index()], but this is a bit unwieldy. However, implementing a helper function seems complicated with the way the traits are set up.

Second, how can you visit a sub node explicitly using the visitor pattern? Currently, I am using child.accept(self);, but I am not sure if that is right way to visit or if it has unintended side effects.

I also have two minor comments on issues I encountered while using the generated code

There is a style issue regarding the generated code. The generated visitor and listener function calls use CamelCase style. Rust-analyzer complains about the lack of snake case, so I have to manually disable these checks. Are there plans to switch to snake case for the generated function calls?

Also another thing I have noticed is that the parser seems to continue even though it encounters an illegal expression. For example, for this piece of code:

let mut parser = CypherParser::new(token_source);
let result = parser.oC_Cypher();
match result {
    Err(e) => {
        log::error!("Error parsing query: {:?}", e);
    }
    Ok(v) => {
        to_ir::visit_result(v);
    }
}

I am unable to catch an error that is thrown in the parser. The program continues despite a parsing error. What is the right way to handle an error here?

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

No branches or pull requests

1 participant