本文整理了Java中org.mozilla.javascript.Parser.expr()
方法的一些代码示例,展示了Parser.expr()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.expr()
方法的具体详情如下:
包路径:org.mozilla.javascript.Parser
类名称:Parser
方法名:expr
暂无
代码示例来源:origin: io.apigee/rhino
private AstNode forLoopInit(int tt) throws IOException {
try {
inForInit = true; // checked by variables() and relExpr()
AstNode init = null;
if (tt == Token.SEMI) {
init = new EmptyExpression(ts.tokenBeg, 1);
init.setLineno(ts.lineno);
} else if (tt == Token.VAR || tt == Token.LET) {
consumeToken();
init = variables(tt, ts.tokenBeg, false);
} else {
init = expr();
markDestructuring(init);
}
return init;
} finally {
inForInit = false;
}
}
代码示例来源:origin: geogebra/geogebra
private AstNode forLoopInit(int tt) throws IOException {
try {
inForInit = true; // checked by variables() and relExpr()
AstNode init = null;
if (tt == Token.SEMI) {
init = new EmptyExpression(ts.tokenBeg, 1);
init.setLineno(ts.lineno);
} else if (tt == Token.VAR || tt == Token.LET) {
consumeToken();
init = variables(tt, ts.tokenBeg, false);
} else {
init = expr();
markDestructuring(init);
}
return init;
} finally {
inForInit = false;
}
}
代码示例来源:origin: com.github.tntim96/rhino
private AstNode forLoopInit(int tt) throws IOException {
try {
inForInit = true; // checked by variables() and relExpr()
AstNode init = null;
if (tt == Token.SEMI) {
init = new EmptyExpression(ts.tokenBeg, 1);
init.setLineno(ts.lineno);
} else if (tt == Token.VAR || tt == Token.LET) {
consumeToken();
init = variables(tt, ts.tokenBeg, false);
} else {
init = expr();
markDestructuring(init);
}
return init;
} finally {
inForInit = false;
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private AstNode forLoopInit(int tt) throws IOException {
try {
inForInit = true; // checked by variables() and relExpr()
AstNode init = null;
if (tt == Token.SEMI) {
init = new EmptyExpression(ts.tokenBeg, 1);
init.setLineno(ts.lineno);
} else if (tt == Token.VAR || tt == Token.LET) {
consumeToken();
init = variables(tt, ts.tokenBeg, false);
} else {
init = expr();
markDestructuring(init);
}
return init;
} finally {
inForInit = false;
}
}
代码示例来源:origin: geogebra/geogebra
private ConditionData condition()
throws IOException
{
ConditionData data = new ConditionData();
if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
data.lp = ts.tokenBeg;
data.condition = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
data.rp = ts.tokenBeg;
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (data.condition instanceof Assignment) {
addStrictWarning("msg.equal.as.assign", "",
data.condition.getPosition(),
data.condition.getLength());
}
return data;
}
代码示例来源:origin: io.apigee/rhino
private ConditionData condition()
throws IOException
{
ConditionData data = new ConditionData();
if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
data.lp = ts.tokenBeg;
data.condition = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
data.rp = ts.tokenBeg;
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (data.condition instanceof Assignment) {
addStrictWarning("msg.equal.as.assign", "",
data.condition.getPosition(),
data.condition.getLength());
}
return data;
}
代码示例来源:origin: com.github.tntim96/rhino
private ConditionData condition()
throws IOException
{
ConditionData data = new ConditionData();
if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
data.lp = ts.tokenBeg;
data.condition = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
data.rp = ts.tokenBeg;
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (data.condition instanceof Assignment) {
addStrictWarning("msg.equal.as.assign", "",
data.condition.getPosition(),
data.condition.getLength());
}
return data;
}
代码示例来源:origin: com.github.tntim96/rhino
private ThrowStatement throwStatement()
throws IOException
{
if (currentToken != Token.THROW) codeBug();
consumeToken();
int pos = ts.tokenBeg, lineno = ts.lineno;
if (peekTokenOrEOL() == Token.EOL) {
// ECMAScript does not allow new lines before throw expression,
// see bug 256617
reportError("msg.bad.throw.eol");
}
AstNode expr = expr();
ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private ConditionData condition()
throws IOException
{
ConditionData data = new ConditionData();
if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
data.lp = ts.tokenBeg;
data.condition = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
data.rp = ts.tokenBeg;
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (data.condition instanceof Assignment) {
addStrictWarning("msg.equal.as.assign", "",
data.condition.getPosition(),
data.condition.getLength());
}
return data;
}
代码示例来源:origin: geogebra/geogebra
private ThrowStatement throwStatement()
throws IOException
{
if (currentToken != Token.THROW) codeBug();
consumeToken();
int pos = ts.tokenBeg, lineno = ts.lineno;
if (peekTokenOrEOL() == Token.EOL) {
// ECMAScript does not allow new lines before throw expression,
// see bug 256617
reportError("msg.bad.throw.eol");
}
AstNode expr = expr();
ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private ThrowStatement throwStatement()
throws IOException
{
if (currentToken != Token.THROW) codeBug();
consumeToken();
int pos = ts.tokenBeg, lineno = ts.lineno;
if (peekTokenOrEOL() == Token.EOL) {
// ECMAScript does not allow new lines before throw expression,
// see bug 256617
reportError("msg.bad.throw.eol");
}
AstNode expr = expr();
ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: io.apigee/rhino
private ThrowStatement throwStatement()
throws IOException
{
if (currentToken != Token.THROW) codeBug();
consumeToken();
int pos = ts.tokenBeg, lineno = ts.lineno;
if (peekTokenOrEOL() == Token.EOL) {
// ECMAScript does not allow new lines before throw expression,
// see bug 256617
reportError("msg.bad.throw.eol");
}
AstNode expr = expr();
ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: rhino/js
private Node condition()
throws IOException, ParserException
{
mustMatchToken(Token.LP, "msg.no.paren.cond");
decompiler.addToken(Token.LP);
Node pn = expr(false);
mustMatchToken(Token.RP, "msg.no.paren.after.cond");
decompiler.addToken(Token.RP);
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
(pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
pn.getType() == Token.SETELEM))
{
addStrictWarning("msg.equal.as.assign", "");
}
return pn;
}
代码示例来源:origin: geogebra/geogebra
/**
* Parse the [expr] portion of an xml element reference, e.g.
* @[expr], @*::[expr], or ns::[expr].
*/
private XmlElemRef xmlElemRef(int atPos, Name namespace, int colonPos)
throws IOException
{
int lb = ts.tokenBeg, rb = -1, pos = atPos != -1 ? atPos : lb;
AstNode expr = expr();
int end = getNodeEnd(expr);
if (mustMatchToken(Token.RB, "msg.no.bracket.index")) {
rb = ts.tokenBeg;
end = ts.tokenEnd;
}
XmlElemRef ref = new XmlElemRef(pos, end - pos);
ref.setNamespace(namespace);
ref.setColonPos(colonPos);
ref.setAtPos(atPos);
ref.setExpression(expr);
ref.setBrackets(lb, rb);
return ref;
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
private Node condition()
throws IOException, ParserException
{
mustMatchToken(Token.LP, "msg.no.paren.cond");
decompiler.addToken(Token.LP);
Node pn = expr(false);
mustMatchToken(Token.RP, "msg.no.paren.after.cond");
decompiler.addToken(Token.RP);
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
(pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
pn.getType() == Token.SETELEM))
{
addStrictWarning("msg.equal.as.assign", "");
}
return pn;
}
代码示例来源:origin: com.yahoo/yuicompressor
private Node condition()
throws IOException, ParserException
{
mustMatchToken(Token.LP, "msg.no.paren.cond");
decompiler.addToken(Token.LP);
Node pn = expr(false);
mustMatchToken(Token.RP, "msg.no.paren.after.cond");
decompiler.addToken(Token.RP);
// Report strict warning on code like "if (a = 7) ...". Suppress the
// warning if the condition is parenthesized, like "if ((a = 7)) ...".
if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
(pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
pn.getType() == Token.SETELEM))
{
addStrictWarning("msg.equal.as.assign", "");
}
return pn;
}
代码示例来源:origin: geogebra/geogebra
private WithStatement withStatement()
throws IOException
{
if (currentToken != Token.WITH) codeBug();
consumeToken();
Comment withComment = getAndResetJsDoc();
int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
if (mustMatchToken(Token.LP, "msg.no.paren.with"))
lp = ts.tokenBeg;
AstNode obj = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
rp = ts.tokenBeg;
AstNode body = statement();
WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
pn.setJsDocNode(withComment);
pn.setExpression(obj);
pn.setStatement(body);
pn.setParens(lp, rp);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: com.github.tntim96/rhino
private WithStatement withStatement()
throws IOException
{
if (currentToken != Token.WITH) codeBug();
consumeToken();
Comment withComment = getAndResetJsDoc();
int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
if (mustMatchToken(Token.LP, "msg.no.paren.with"))
lp = ts.tokenBeg;
AstNode obj = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
rp = ts.tokenBeg;
AstNode body = statement();
WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
pn.setJsDocNode(withComment);
pn.setExpression(obj);
pn.setStatement(body);
pn.setParens(lp, rp);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private WithStatement withStatement()
throws IOException
{
if (currentToken != Token.WITH) codeBug();
consumeToken();
Comment withComment = getAndResetJsDoc();
int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
if (mustMatchToken(Token.LP, "msg.no.paren.with"))
lp = ts.tokenBeg;
AstNode obj = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
rp = ts.tokenBeg;
AstNode body = statement();
WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
pn.setJsDocNode(withComment);
pn.setExpression(obj);
pn.setStatement(body);
pn.setParens(lp, rp);
pn.setLineno(lineno);
return pn;
}
代码示例来源:origin: io.apigee/rhino
private WithStatement withStatement()
throws IOException
{
if (currentToken != Token.WITH) codeBug();
consumeToken();
Comment withComment = getAndResetJsDoc();
int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
if (mustMatchToken(Token.LP, "msg.no.paren.with"))
lp = ts.tokenBeg;
AstNode obj = expr();
if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
rp = ts.tokenBeg;
AstNode body = statement();
WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
pn.setJsDocNode(withComment);
pn.setExpression(obj);
pn.setStatement(body);
pn.setParens(lp, rp);
pn.setLineno(lineno);
return pn;
}
内容来源于网络,如有侵权,请联系作者删除!