我创建了一个源自ECMA Script语法的简化语法:
https://github.com/antlr/grammars-v4/blob/master/ecmascript/ECMAScript.g4
原始语法到目前为止工作得很好,我只添加了一些规则。但是,以下表达式是我的语法中的有效表达式,但在原始ECMA语法中引发错误:
round(frames++/((getTime()-start)/1000))
由引起的
帧++ /
表达。
以下类似的表达方式有效:
round(frames++*((getTime()-start)/1000))
round(frames++%((getTime()-start)/1000))
我的问题是如何让第一个表达式起作用,有什么区别?
答案 0 :(得分:0)
这可能是因为$result = mysql_query("SELECT * FROM tbl_lead WHERE pass_expiry=CURRENT_DATE()");
被解释为正则表达式分隔符的开头。
如果你看一下lexer-method,它确定/
何时是一个正则表达式文字和一个除法运算符:
/
然后,对于代币/**
* Returns {@code true} iff the lexer can match a regex literal.
*
* @return {@code true} iff the lexer can match a regex literal.
*/
private boolean isRegexPossible() {
if (this.lastToken == null) {
// No token has been produced yet: at the start of the input,
// no division is possible, so a regex literal _is_ possible.
return true;
}
switch (this.lastToken.getType()) {
case Identifier:
case NullLiteral:
case BooleanLiteral:
case This:
case CloseBracket:
case CloseParen:
case OctalIntegerLiteral:
case DecimalLiteral:
case HexIntegerLiteral:
case StringLiteral:
// After any of the tokens above, no regex literal can follow.
return false;
default:
// In all other cases, a regex literal _is_ possible.
return true;
}
}
和--
,这也应该返回false。
按如下方式调整++
:
isRegexPossible()