我正在使用GitHub中的antlr4 解析器语法和词法分析器语法来解析Python3中的PHP.
当我直接使用这些语法时,我的PoC代码可以工作:
antlr-test.py
from antlr4 import *
# from PHPParentLexer import PHPParentLexer
# from PHPParentParser import PHPParentParser
# from PHPParentParser import PHPParentListener
from PHPLexer import PHPLexer as PHPParentLexer
from PHPParser import PHPParser as PHPParentParser
from PHPParser import PHPParserListener as PHPParentListener
class PhpGrammarListener(PHPParentListener):
def enterFunctionInvocation(self, ctx):
print("enterFunctionInvocation " + ctx.getText())
if __name__ == "__main__":
scanner_input = FileStream('test.php')
lexer = PHPParentLexer(scanner_input)
stream = CommonTokenStream(lexer)
parser = PHPParentParser(stream)
tree = parser.htmlDocument()
walker = ParseTreeWalker()
printer = PhpGrammarListener()
walker.walk(printer, tree) …Run Code Online (Sandbox Code Playgroud) 问题:
Hibernate没有正确执行查询.它出现问题似乎与slf4j有关,但使用任何推荐的修复似乎不起作用.
我已经为createQuery调用尝试了各种变量名称组合,希望我是在做错误(TM),但到目前为止还没有运气.这个问题真让我难过,有没有人遇到过类似的东西?
堆栈跟踪:
Exception in thread "main" java.lang.NoSuchFieldError: NONE
at org.hibernate.ejb.QueryImpl.<init>(QueryImpl.java:604)
at org.hibernate.ejb.QueryImpl.<init>(QueryImpl.java:79)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:268)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:341)
at $Proxy12.createQuery(Unknown Source)
at com.package.mvcfromscratch.dao.PostgresEventDao.numberOfEvents(PostgresEventDao.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy11.numberOfEvents(Unknown Source)
at com.package.mvcfromscratch.main.UserInterface.main(UserInterface.java:27)
Run Code Online (Sandbox Code Playgroud)
Maven依赖树:
[INFO] com.package:mvcFromScratch:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-context:jar:3.0.3.RELEASE:compile
[INFO] | +- org.springframework:spring-expression:jar:3.0.3.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-beans:jar:3.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.0.3.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-web:jar:3.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:3.0.3.RELEASE:compile …Run Code Online (Sandbox Code Playgroud)