Is it somehow possible to use this javacc jar to parse a jjt and jj file
See original GitHub issueI want to construct some tests depending on the tokens used in a specific rule of my grammar.
void myrule() : {} {
<K_MYKEYWORD1>
| <K_MYKEYWORD2>
}
So I have a jjt file and need to transform this in a jj file and then parse this and get the AST - node tree, to traverse it.
My first attempt was this:
var parser = new JJTreeParser(
Files.newInputStream(Paths.get("src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt"))
) {
public ASTGrammar getRoot() {
return (ASTGrammar)jjtree.rootNode());
}
};
parser.javacc_input();
new JavaCodeGenerator().visit(parser.getRoot(), io);
But I have to fight method and class visibility issues:
IO is only package private, ASTGrammer.generate is package private as well.
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top Results From Across the Web
JavaCC | The most popular parser generator for use with Java ...
The most popular parser generator for use with Java applications.
Read more >Using JavaCC
JavaCC is a lexer and parser generator for LL(k) grammars. You specify a language's lexical and syntactic description in a JJ file, then...
Read more >Java – How to implement JJTree on grammar – iTecNote
I have an assignment to use JavaCC to make a Top-Down Parser with Semantic ... invoke jjtree on your jjt grammar, which will...
Read more >How to modularize a JavaCC grammar file (.jj)? - Stack Overflow
There is no way built in to JavaCC to modularize .jj files. The best thing to do is often to use JJT, as...
Read more >javacc-7.0.2.javacc-releases.notes Maven / Gradle / Ivy
JavaCC [tm]: Release Notes THIS FILE IS A COMPLETE LOG OF ALL CHANGES THAT HAVE ... .jjt file if the .jj file is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or in other words: What would be the best (e.g. simplest and most robust) to extract the actual Tokens from a jj Grammar File, without running JTREE first and also considering Composite Tokens.
For reference, below is the code which finally returns all Keywords from a Grammar:
We can close this issue.