未验证 提交 ec7bfc82 编写于 作者: P Phodal HUANG

fix: fix visitor

上级 39c7c01b
......@@ -27,4 +27,8 @@ TBD.
```
go get github.com/onsi/ginkgo
go get github.com/onsi/gomega
```
\ No newline at end of file
```
## Refs
[https://github.com/MontFerret/ferret](https://github.com/MontFerret/ferret)
\ No newline at end of file
......@@ -22,7 +22,12 @@ func analysisPath(codeDir string) {
files := javaFiles(codeDir)
for index := range files {
file := files[index]
Parser(file)
context := processFile(file)
v := &BaseJavaParserVisitor{}
visit := v.Visit(context)
fmt.Println(visit)
}
}
......@@ -37,11 +42,11 @@ func javaFiles(codeDir string) []string {
return files
}
func Parser(path string) ICompilationUnitContext {
func processFile(path string) ICompilationUnitContext {
is, _ := antlr.NewFileStream(path)
fmt.Println(is)
lexer := NewJavaLexer(is)
stream := antlr.NewCommonTokenStream(lexer, 0);
parser := NewJavaParser(stream)
parser.BuildParseTrees = true
return parser.CompilationUnit()
}
```
antlr -Dlanguage=Go -visitor -listener -lib . JavaParser
antlr -Dlanguage=Go -visitor -listener -lib . JavaParser.g4
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册