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

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

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

Parser.mustMatchToken介绍

暂无

代码示例

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

  1. private boolean mustMatchToken(int toMatch, String messageId)
  2. throws IOException
  3. {
  4. return mustMatchToken(toMatch, messageId, ts.tokenBeg,
  5. ts.tokenEnd - ts.tokenBeg);
  6. }

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

  1. private boolean mustMatchToken(int toMatch, String messageId)
  2. throws IOException
  3. {
  4. return mustMatchToken(toMatch, messageId, ts.tokenBeg,
  5. ts.tokenEnd - ts.tokenBeg);
  6. }

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

  1. private boolean mustMatchToken(int toMatch, String messageId)
  2. throws IOException
  3. {
  4. return mustMatchToken(toMatch, messageId, ts.tokenBeg,
  5. ts.tokenEnd - ts.tokenBeg);
  6. }

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

  1. private boolean mustMatchToken(int toMatch, String messageId)
  2. throws IOException
  3. {
  4. return mustMatchToken(toMatch, messageId, ts.tokenBeg,
  5. ts.tokenEnd - ts.tokenBeg);
  6. }

代码示例来源: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: 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: 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: 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: rhino/js

  1. private void plainProperty(ObjArray elems, Object property)
  2. throws IOException {
  3. mustMatchToken(Token.COLON, "msg.no.colon.prop");
  4. // OBJLIT is used as ':' in object literal for
  5. // decompilation to solve spacing ambiguity.
  6. decompiler.addToken(Token.OBJECTLIT);
  7. elems.add(property);
  8. elems.add(assignExpr(false));
  9. }

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

  1. private void plainProperty(ObjArray elems, Object property)
  2. throws IOException {
  3. mustMatchToken(Token.COLON, "msg.no.colon.prop");
  4. // OBJLIT is used as ':' in object literal for
  5. // decompilation to solve spacing ambiguity.
  6. decompiler.addToken(Token.OBJECTLIT);
  7. elems.add(property);
  8. elems.add(assignExpr(false));
  9. }

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

  1. private void plainProperty(ObjArray elems, Object property)
  2. throws IOException {
  3. mustMatchToken(Token.COLON, "msg.no.colon.prop");
  4. // OBJLIT is used as ':' in object literal for
  5. // decompilation to solve spacing ambiguity.
  6. decompiler.addToken(Token.OBJECTLIT);
  7. elems.add(property);
  8. elems.add(assignExpr(false));
  9. }

代码示例来源: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: 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: com.sun.phobos/phobos-rhino

  1. private Node condExpr(boolean inForInit)
  2. throws IOException, ParserException
  3. {
  4. Node pn = orExpr(inForInit);
  5. if (matchToken(Token.HOOK)) {
  6. decompiler.addToken(Token.HOOK);
  7. Node ifTrue = assignExpr(false);
  8. mustMatchToken(Token.COLON, "msg.no.colon.cond");
  9. decompiler.addToken(Token.COLON);
  10. Node ifFalse = assignExpr(inForInit);
  11. return nf.createCondExpr(pn, ifTrue, ifFalse);
  12. }
  13. return pn;
  14. }

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

  1. private void argumentList(Node listNode)
  2. throws IOException, ParserException
  3. {
  4. boolean matched;
  5. matched = matchToken(Token.RP);
  6. if (!matched) {
  7. boolean first = true;
  8. do {
  9. if (!first)
  10. decompiler.addToken(Token.COMMA);
  11. first = false;
  12. nf.addChildToBack(listNode, assignExpr(false));
  13. } while (matchToken(Token.COMMA));
  14. mustMatchToken(Token.RP, "msg.no.paren.arg");
  15. }
  16. decompiler.addToken(Token.RP);
  17. }

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

  1. private void argumentList(Node listNode)
  2. throws IOException, ParserException
  3. {
  4. boolean matched;
  5. matched = matchToken(Token.RP);
  6. if (!matched) {
  7. boolean first = true;
  8. do {
  9. if (!first)
  10. decompiler.addToken(Token.COMMA);
  11. first = false;
  12. nf.addChildToBack(listNode, assignExpr(false));
  13. } while (matchToken(Token.COMMA));
  14. mustMatchToken(Token.RP, "msg.no.paren.arg");
  15. }
  16. decompiler.addToken(Token.RP);
  17. }

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

  1. private Node condExpr(boolean inForInit)
  2. throws IOException, ParserException
  3. {
  4. Node pn = orExpr(inForInit);
  5. if (matchToken(Token.HOOK)) {
  6. decompiler.addToken(Token.HOOK);
  7. Node ifTrue = assignExpr(false);
  8. mustMatchToken(Token.COLON, "msg.no.colon.cond");
  9. decompiler.addToken(Token.COLON);
  10. Node ifFalse = assignExpr(inForInit);
  11. return nf.createCondExpr(pn, ifTrue, ifFalse);
  12. }
  13. return pn;
  14. }

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

  1. private Node condExpr(boolean inForInit)
  2. throws IOException, ParserException
  3. {
  4. Node pn = orExpr(inForInit);
  5. if (matchToken(Token.HOOK)) {
  6. decompiler.addToken(Token.HOOK);
  7. Node ifTrue = assignExpr(false);
  8. mustMatchToken(Token.COLON, "msg.no.colon.cond");
  9. decompiler.addToken(Token.COLON);
  10. Node ifFalse = assignExpr(inForInit);
  11. return nf.createCondExpr(pn, ifTrue, ifFalse);
  12. }
  13. return pn;
  14. }

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

  1. private AstNode block()
  2. throws IOException
  3. {
  4. if (currentToken != Token.LC) codeBug();
  5. consumeToken();
  6. int pos = ts.tokenBeg;
  7. Scope block = new Scope(pos);
  8. block.setLineno(ts.lineno);
  9. pushScope(block);
  10. try {
  11. statements(block);
  12. mustMatchToken(Token.RC, "msg.no.brace.block");
  13. block.setLength(ts.tokenEnd - pos);
  14. return block;
  15. } finally {
  16. popScope();
  17. }
  18. }

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

  1. private AstNode block()
  2. throws IOException
  3. {
  4. if (currentToken != Token.LC) codeBug();
  5. consumeToken();
  6. int pos = ts.tokenBeg;
  7. Scope block = new Scope(pos);
  8. block.setLineno(ts.lineno);
  9. pushScope(block);
  10. try {
  11. statements(block);
  12. mustMatchToken(Token.RC, "msg.no.brace.block");
  13. block.setLength(ts.tokenEnd - pos);
  14. return block;
  15. } finally {
  16. popScope();
  17. }
  18. }

相关文章

Parser类方法