使用DataWay写接口的时候遇到了一个报错:
{
"success": false,
"message": "line 11:4 mismatched input 'fun1' expecting {'if', 'return', 'throw', 'exit', 'var', 'run', 'hint', '}'}",
"code": 500,
"lifeCycleTime": "7",
"executionTime": -1,
"value": {
"code": 500,
"data": {
"className": "net.hasor.dataql.compiler.parser.ThrowingErrorListener",
"fileName": "ThrowingErrorListener.java",
"lineNumber": 33,
"methodName": "syntaxError",
"nativeMethod": false
},
"msg": "line 11:4 mismatched input 'fun1' expecting {'if', 'return', 'throw', 'exit', 'var', 'run', 'hint', '}'}"
}
}
百度上没有答案,官方文档又实在太烂,没有啥用。碰巧自己改成功了,下面说解决方案和我的看法。
解决方案:
报错信息显示,第11行出错,改成 run fun1(); 或者 var str = fun1(); 即可。
个人看法:
官方文档:https://www.hasor.net/doc/pages/viewpage.action?pageId=1573235,关于语句这一章节,有说明var和run的作用:执行语句。
猜测:dataQL没有像其他语言一样,直接写函数名就能执行函数,而是要通过 run 或者 var 来显式声明执行函数。