org.mozilla.javascript.Parser.expr()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 JavaScript  
字(10.9k)|赞(0)|评价(0)|浏览(327)

本文整理了Java中org.mozilla.javascript.Parser.expr()方法的一些代码示例,展示了Parser.expr()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Parser.expr()方法的具体详情如下:
包路径:org.mozilla.javascript.Parser
类名称:Parser
方法名:expr

Parser.expr介绍

暂无

代码示例

代码示例来源:origin: io.apigee/rhino

  1. private AstNode forLoopInit(int tt) throws IOException {
  2. try {
  3. inForInit = true; // checked by variables() and relExpr()
  4. AstNode init = null;
  5. if (tt == Token.SEMI) {
  6. init = new EmptyExpression(ts.tokenBeg, 1);
  7. init.setLineno(ts.lineno);
  8. } else if (tt == Token.VAR || tt == Token.LET) {
  9. consumeToken();
  10. init = variables(tt, ts.tokenBeg, false);
  11. } else {
  12. init = expr();
  13. markDestructuring(init);
  14. }
  15. return init;
  16. } finally {
  17. inForInit = false;
  18. }
  19. }

代码示例来源:origin: geogebra/geogebra

  1. private AstNode forLoopInit(int tt) throws IOException {
  2. try {
  3. inForInit = true; // checked by variables() and relExpr()
  4. AstNode init = null;
  5. if (tt == Token.SEMI) {
  6. init = new EmptyExpression(ts.tokenBeg, 1);
  7. init.setLineno(ts.lineno);
  8. } else if (tt == Token.VAR || tt == Token.LET) {
  9. consumeToken();
  10. init = variables(tt, ts.tokenBeg, false);
  11. } else {
  12. init = expr();
  13. markDestructuring(init);
  14. }
  15. return init;
  16. } finally {
  17. inForInit = false;
  18. }
  19. }

代码示例来源:origin: com.github.tntim96/rhino

  1. private AstNode forLoopInit(int tt) throws IOException {
  2. try {
  3. inForInit = true; // checked by variables() and relExpr()
  4. AstNode init = null;
  5. if (tt == Token.SEMI) {
  6. init = new EmptyExpression(ts.tokenBeg, 1);
  7. init.setLineno(ts.lineno);
  8. } else if (tt == Token.VAR || tt == Token.LET) {
  9. consumeToken();
  10. init = variables(tt, ts.tokenBeg, false);
  11. } else {
  12. init = expr();
  13. markDestructuring(init);
  14. }
  15. return init;
  16. } finally {
  17. inForInit = false;
  18. }
  19. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. private AstNode forLoopInit(int tt) throws IOException {
  2. try {
  3. inForInit = true; // checked by variables() and relExpr()
  4. AstNode init = null;
  5. if (tt == Token.SEMI) {
  6. init = new EmptyExpression(ts.tokenBeg, 1);
  7. init.setLineno(ts.lineno);
  8. } else if (tt == Token.VAR || tt == Token.LET) {
  9. consumeToken();
  10. init = variables(tt, ts.tokenBeg, false);
  11. } else {
  12. init = expr();
  13. markDestructuring(init);
  14. }
  15. return init;
  16. } finally {
  17. inForInit = false;
  18. }
  19. }

代码示例来源:origin: geogebra/geogebra

  1. private ConditionData condition()
  2. throws IOException
  3. {
  4. ConditionData data = new ConditionData();
  5. if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
  6. data.lp = ts.tokenBeg;
  7. data.condition = expr();
  8. if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
  9. data.rp = ts.tokenBeg;
  10. // Report strict warning on code like "if (a = 7) ...". Suppress the
  11. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  12. if (data.condition instanceof Assignment) {
  13. addStrictWarning("msg.equal.as.assign", "",
  14. data.condition.getPosition(),
  15. data.condition.getLength());
  16. }
  17. return data;
  18. }

代码示例来源:origin: io.apigee/rhino

  1. private ConditionData condition()
  2. throws IOException
  3. {
  4. ConditionData data = new ConditionData();
  5. if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
  6. data.lp = ts.tokenBeg;
  7. data.condition = expr();
  8. if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
  9. data.rp = ts.tokenBeg;
  10. // Report strict warning on code like "if (a = 7) ...". Suppress the
  11. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  12. if (data.condition instanceof Assignment) {
  13. addStrictWarning("msg.equal.as.assign", "",
  14. data.condition.getPosition(),
  15. data.condition.getLength());
  16. }
  17. return data;
  18. }

代码示例来源:origin: com.github.tntim96/rhino

  1. private ConditionData condition()
  2. throws IOException
  3. {
  4. ConditionData data = new ConditionData();
  5. if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
  6. data.lp = ts.tokenBeg;
  7. data.condition = expr();
  8. if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
  9. data.rp = ts.tokenBeg;
  10. // Report strict warning on code like "if (a = 7) ...". Suppress the
  11. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  12. if (data.condition instanceof Assignment) {
  13. addStrictWarning("msg.equal.as.assign", "",
  14. data.condition.getPosition(),
  15. data.condition.getLength());
  16. }
  17. return data;
  18. }

代码示例来源:origin: com.github.tntim96/rhino

  1. private ThrowStatement throwStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.THROW) codeBug();
  5. consumeToken();
  6. int pos = ts.tokenBeg, lineno = ts.lineno;
  7. if (peekTokenOrEOL() == Token.EOL) {
  8. // ECMAScript does not allow new lines before throw expression,
  9. // see bug 256617
  10. reportError("msg.bad.throw.eol");
  11. }
  12. AstNode expr = expr();
  13. ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
  14. pn.setLineno(lineno);
  15. return pn;
  16. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. private ConditionData condition()
  2. throws IOException
  3. {
  4. ConditionData data = new ConditionData();
  5. if (mustMatchToken(Token.LP, "msg.no.paren.cond"))
  6. data.lp = ts.tokenBeg;
  7. data.condition = expr();
  8. if (mustMatchToken(Token.RP, "msg.no.paren.after.cond"))
  9. data.rp = ts.tokenBeg;
  10. // Report strict warning on code like "if (a = 7) ...". Suppress the
  11. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  12. if (data.condition instanceof Assignment) {
  13. addStrictWarning("msg.equal.as.assign", "",
  14. data.condition.getPosition(),
  15. data.condition.getLength());
  16. }
  17. return data;
  18. }

代码示例来源:origin: geogebra/geogebra

  1. private ThrowStatement throwStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.THROW) codeBug();
  5. consumeToken();
  6. int pos = ts.tokenBeg, lineno = ts.lineno;
  7. if (peekTokenOrEOL() == Token.EOL) {
  8. // ECMAScript does not allow new lines before throw expression,
  9. // see bug 256617
  10. reportError("msg.bad.throw.eol");
  11. }
  12. AstNode expr = expr();
  13. ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
  14. pn.setLineno(lineno);
  15. return pn;
  16. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. private ThrowStatement throwStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.THROW) codeBug();
  5. consumeToken();
  6. int pos = ts.tokenBeg, lineno = ts.lineno;
  7. if (peekTokenOrEOL() == Token.EOL) {
  8. // ECMAScript does not allow new lines before throw expression,
  9. // see bug 256617
  10. reportError("msg.bad.throw.eol");
  11. }
  12. AstNode expr = expr();
  13. ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
  14. pn.setLineno(lineno);
  15. return pn;
  16. }

代码示例来源:origin: io.apigee/rhino

  1. private ThrowStatement throwStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.THROW) codeBug();
  5. consumeToken();
  6. int pos = ts.tokenBeg, lineno = ts.lineno;
  7. if (peekTokenOrEOL() == Token.EOL) {
  8. // ECMAScript does not allow new lines before throw expression,
  9. // see bug 256617
  10. reportError("msg.bad.throw.eol");
  11. }
  12. AstNode expr = expr();
  13. ThrowStatement pn = new ThrowStatement(pos, getNodeEnd(expr), expr);
  14. pn.setLineno(lineno);
  15. return pn;
  16. }

代码示例来源:origin: rhino/js

  1. private Node condition()
  2. throws IOException, ParserException
  3. {
  4. mustMatchToken(Token.LP, "msg.no.paren.cond");
  5. decompiler.addToken(Token.LP);
  6. Node pn = expr(false);
  7. mustMatchToken(Token.RP, "msg.no.paren.after.cond");
  8. decompiler.addToken(Token.RP);
  9. // Report strict warning on code like "if (a = 7) ...". Suppress the
  10. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  11. if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
  12. (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
  13. pn.getType() == Token.SETELEM))
  14. {
  15. addStrictWarning("msg.equal.as.assign", "");
  16. }
  17. return pn;
  18. }

代码示例来源:origin: geogebra/geogebra

  1. /**
  2. * Parse the [expr] portion of an xml element reference, e.g.
  3. * @[expr], @*::[expr], or ns::[expr].
  4. */
  5. private XmlElemRef xmlElemRef(int atPos, Name namespace, int colonPos)
  6. throws IOException
  7. {
  8. int lb = ts.tokenBeg, rb = -1, pos = atPos != -1 ? atPos : lb;
  9. AstNode expr = expr();
  10. int end = getNodeEnd(expr);
  11. if (mustMatchToken(Token.RB, "msg.no.bracket.index")) {
  12. rb = ts.tokenBeg;
  13. end = ts.tokenEnd;
  14. }
  15. XmlElemRef ref = new XmlElemRef(pos, end - pos);
  16. ref.setNamespace(namespace);
  17. ref.setColonPos(colonPos);
  18. ref.setAtPos(atPos);
  19. ref.setExpression(expr);
  20. ref.setBrackets(lb, rb);
  21. return ref;
  22. }

代码示例来源:origin: com.sun.phobos/phobos-rhino

  1. private Node condition()
  2. throws IOException, ParserException
  3. {
  4. mustMatchToken(Token.LP, "msg.no.paren.cond");
  5. decompiler.addToken(Token.LP);
  6. Node pn = expr(false);
  7. mustMatchToken(Token.RP, "msg.no.paren.after.cond");
  8. decompiler.addToken(Token.RP);
  9. // Report strict warning on code like "if (a = 7) ...". Suppress the
  10. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  11. if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
  12. (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
  13. pn.getType() == Token.SETELEM))
  14. {
  15. addStrictWarning("msg.equal.as.assign", "");
  16. }
  17. return pn;
  18. }

代码示例来源:origin: com.yahoo/yuicompressor

  1. private Node condition()
  2. throws IOException, ParserException
  3. {
  4. mustMatchToken(Token.LP, "msg.no.paren.cond");
  5. decompiler.addToken(Token.LP);
  6. Node pn = expr(false);
  7. mustMatchToken(Token.RP, "msg.no.paren.after.cond");
  8. decompiler.addToken(Token.RP);
  9. // Report strict warning on code like "if (a = 7) ...". Suppress the
  10. // warning if the condition is parenthesized, like "if ((a = 7)) ...".
  11. if (pn.getProp(Node.PARENTHESIZED_PROP) == null &&
  12. (pn.getType() == Token.SETNAME || pn.getType() == Token.SETPROP ||
  13. pn.getType() == Token.SETELEM))
  14. {
  15. addStrictWarning("msg.equal.as.assign", "");
  16. }
  17. return pn;
  18. }

代码示例来源:origin: geogebra/geogebra

  1. private WithStatement withStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.WITH) codeBug();
  5. consumeToken();
  6. Comment withComment = getAndResetJsDoc();
  7. int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
  8. if (mustMatchToken(Token.LP, "msg.no.paren.with"))
  9. lp = ts.tokenBeg;
  10. AstNode obj = expr();
  11. if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
  12. rp = ts.tokenBeg;
  13. AstNode body = statement();
  14. WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
  15. pn.setJsDocNode(withComment);
  16. pn.setExpression(obj);
  17. pn.setStatement(body);
  18. pn.setParens(lp, rp);
  19. pn.setLineno(lineno);
  20. return pn;
  21. }

代码示例来源:origin: com.github.tntim96/rhino

  1. private WithStatement withStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.WITH) codeBug();
  5. consumeToken();
  6. Comment withComment = getAndResetJsDoc();
  7. int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
  8. if (mustMatchToken(Token.LP, "msg.no.paren.with"))
  9. lp = ts.tokenBeg;
  10. AstNode obj = expr();
  11. if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
  12. rp = ts.tokenBeg;
  13. AstNode body = statement();
  14. WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
  15. pn.setJsDocNode(withComment);
  16. pn.setExpression(obj);
  17. pn.setStatement(body);
  18. pn.setParens(lp, rp);
  19. pn.setLineno(lineno);
  20. return pn;
  21. }

代码示例来源:origin: ro.isdc.wro4j/rhino

  1. private WithStatement withStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.WITH) codeBug();
  5. consumeToken();
  6. Comment withComment = getAndResetJsDoc();
  7. int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
  8. if (mustMatchToken(Token.LP, "msg.no.paren.with"))
  9. lp = ts.tokenBeg;
  10. AstNode obj = expr();
  11. if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
  12. rp = ts.tokenBeg;
  13. AstNode body = statement();
  14. WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
  15. pn.setJsDocNode(withComment);
  16. pn.setExpression(obj);
  17. pn.setStatement(body);
  18. pn.setParens(lp, rp);
  19. pn.setLineno(lineno);
  20. return pn;
  21. }

代码示例来源:origin: io.apigee/rhino

  1. private WithStatement withStatement()
  2. throws IOException
  3. {
  4. if (currentToken != Token.WITH) codeBug();
  5. consumeToken();
  6. Comment withComment = getAndResetJsDoc();
  7. int lineno = ts.lineno, pos = ts.tokenBeg, lp = -1, rp = -1;
  8. if (mustMatchToken(Token.LP, "msg.no.paren.with"))
  9. lp = ts.tokenBeg;
  10. AstNode obj = expr();
  11. if (mustMatchToken(Token.RP, "msg.no.paren.after.with"))
  12. rp = ts.tokenBeg;
  13. AstNode body = statement();
  14. WithStatement pn = new WithStatement(pos, getNodeEnd(body) - pos);
  15. pn.setJsDocNode(withComment);
  16. pn.setExpression(obj);
  17. pn.setStatement(body);
  18. pn.setParens(lp, rp);
  19. pn.setLineno(lineno);
  20. return pn;
  21. }

相关文章

Parser类方法