• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SyntaxException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中gnu.text.SyntaxException的典型用法代码示例。如果您正苦于以下问题:Java SyntaxException类的具体用法?Java SyntaxException怎么用?Java SyntaxException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SyntaxException类属于gnu.text包,在下文中一共展示了SyntaxException类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: read

import gnu.text.SyntaxException; //导入依赖的package包/类
public Object read (Lexer in, int ch, int count)
      throws java.io.IOException, SyntaxException {
      InPort port = in.getPort();
      StringBuilder buf = null;
      if (port instanceof BinaryInPort && checkEncodingSpec) {
          int lineno = port.getLineNumber();
          if (lineno == 0 || lineno == 1)
              buf = new StringBuilder();
      }
      do {
          ch = in.read();
          if (ch < 0)
              return Sequence.eofValue;
          if (buf != null)
              buf.append((char) ch);
      } while (ch != '\n' && ch!= '\r');
      if (buf != null) {
          ((LispReader) in).checkEncodingSpec(buf.toString());
      }
      in.unread(ch);
      return Values.empty;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:23,代码来源:ReaderIgnoreRestOfLine.java


示例2: read

import gnu.text.SyntaxException; //导入依赖的package包/类
public static Object read(LispReader reader,
                          Object magicSymbol,
                          char next, Object magicSymbol2)
        throws java.io.IOException, SyntaxException {
    String file = reader.getName();
    int line1 = reader.getLineNumber() + 1;
    int column1 = reader.getColumnNumber() + 1;
    Object magic = magicSymbol;
    if (next != '\0') {
        int ch = reader.read();
        if (ch == next)
            magic = magicSymbol2;
        else if (ch >= 0)
            reader.unread(ch);
    }
    int line2 = reader.getLineNumber() + 1;
    int column2 = reader.getColumnNumber() + 1;
    Object form = reader.readObject();
    form = PairWithPosition.make(form, reader.makeNil(),
                                 file, line2, column2);
    form = PairWithPosition.make(magic, form,
                                    file, line1, column1);
    return form;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:25,代码来源:ReaderQuote.java


示例3: skipOldComment

import gnu.text.SyntaxException; //导入依赖的package包/类
final void skipOldComment()
   throws java.io.IOException, SyntaxException
 {
   int seenDashes = 0;
   int startLine = getLineNumber() + 1;
   int startColumn = getColumnNumber() - 2;
   warnOldVersion("use (: :) instead of old-style comment {-- --}");
   for (;;)
     {
int ch = read();
if (ch == '-')
  seenDashes++;
else if (ch == '}' && seenDashes >= 2)
  return;
else if (ch < 0)
  {
    curLine = startLine;
    curColumn = startColumn;
    eofError("non-terminated comment starting here");
  }
else
  seenDashes = 0;
     }
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:25,代码来源:XQParser.java


示例4: match

import gnu.text.SyntaxException; //导入依赖的package包/类
boolean match (String word1, String word2, boolean force)
    throws java.io.IOException, SyntaxException
{
  if (match(word1))
    {
      mark();
      getRawToken();
      if (match(word2))
        {
          reset();
          getRawToken();
          return true;
        }
      reset();
      if (force)
        {
          error('e', "'"+word1+"' must be followed by '"+word2+"'",
                "XPST0003");
          return true;
        }
    }
  return false;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:24,代码来源:XQParser.java


示例5: parseUnaryExpr

import gnu.text.SyntaxException; //导入依赖的package包/类
Expression parseUnaryExpr()
    throws java.io.IOException, SyntaxException
{
  Expression exp;
  if (curToken == OP_SUB || curToken == OP_ADD)
    {
      int op = curToken;
      getRawToken();
      exp = parseUnaryExpr();
      Expression func
        = makeFunctionExp("gnu.xquery.util.ArithOp",
                          op == OP_ADD ? "plus" : "minus",
                          op == OP_ADD ? "+" : "-");
      exp = new ApplyExp(func, new Expression[] { exp });
    }
  else
    exp = parseUnionExpr();
  return exp;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:20,代码来源:XQParser.java


示例6: parseExprSequence

import gnu.text.SyntaxException; //导入依赖的package包/类
Expression parseExprSequence(int rightToken, boolean optional)
     throws java.io.IOException, SyntaxException
 {
   if (curToken == rightToken || curToken == EOF_TOKEN)
     {
       if (! optional)
         syntaxError("missing expression");
       return QuoteExp.voidObjectExp;
     }
   Expression exp = null;
   for (;;)
     {
Expression exp1 = parseExprSingle();

exp = exp == null ? exp1 : makeExprSequence(exp, exp1);
if (curToken == rightToken || curToken == EOF_TOKEN)
  break;
if (nesting == 0 && curToken == EOL_TOKEN)
  return exp;
if (curToken != ',')
  return syntaxError (rightToken == ')' ? "expected ')'"
		       : "confused by syntax error");
getRawToken();
     }
   return exp;
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:27,代码来源:XQParser.java


示例7: parseIfExpr

import gnu.text.SyntaxException; //导入依赖的package包/类
public Expression parseIfExpr()
    throws java.io.IOException, SyntaxException
{
  char saveReadState1 = pushNesting('i');
  getRawToken();
  char saveReadState2 = pushNesting('(');
  Expression cond = parseExprSequence(')', false);
  popNesting(saveReadState2);
  if (curToken == EOF_TOKEN)
    eofError("missing ')' - unexpected end-of-file");
  getRawToken();
  if (! match("then"))
    syntaxError("missing 'then'");
  else
    getRawToken();
  Expression thenPart = parseExpr();
  if (! match("else"))
    syntaxError("missing 'else'");
  else
    getRawToken();
  popNesting(saveReadState1);
  Expression elsePart = parseExpr();
  return new IfExp(booleanValue(cond), thenPart, elsePart);
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:25,代码来源:XQParser.java


示例8: parseVariable

import gnu.text.SyntaxException; //导入依赖的package包/类
/** Parse a Variable. */
public Object parseVariable ()
  throws java.io.IOException, SyntaxException
{
  if (curToken == '$')
    getRawToken();
  else
    syntaxError("missing '$' before variable name");
  String str = new String(tokenBuffer, 0, tokenBufferLength);
  // Note we cannot do namespace resolution here - see comment in
  // parseElementConstructor.
  if (curToken == QNAME_TOKEN)
    return str;
  else if (curToken == NCNAME_TOKEN)
    return Namespace.EmptyNamespace.getSymbol(str.intern());
  else
    return null;
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:19,代码来源:XQParser.java


示例9: parseSeparator

import gnu.text.SyntaxException; //导入依赖的package包/类
void parseSeparator ()
   throws java.io.IOException, SyntaxException
 {
   int startLine = port.getLineNumber() + 1;
   int startColumn = port.getColumnNumber() + 1;
   int next = skipSpace(nesting != 0);
   if (next == ';')
     return;
   if (warnOldVersion && next != '\n')
     {
curLine = startLine;
curColumn = startColumn;
error('w', "missing ';' after declaration");
     }
   if (next >= 0)
     unread(next);
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:18,代码来源:XQParser.java


示例10: syntaxError

import gnu.text.SyntaxException; //导入依赖的package包/类
/**
  * Handle syntax errors (at rewrite time).
  * @param message an error message to print out
  * @return an ErrorExp
  */
 public Expression syntaxError (String message, String code)
   throws java.io.IOException, SyntaxException
 {
   error('e', message, code);
   if (isInteractive())
     {
curToken = 0;
curValue = null;
nesting = 0;
((InPort) getPort()).readState = '\n';
for (;;)
  {
    int ch = read();
    if (ch < 0)
      break;
    if (ch == '\r' || ch == '\n')
      {
	unread(ch);
	break;
      }
  }
throw new SyntaxException(getMessages());
     }
   return new ErrorExp (message);
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:31,代码来源:XQParser.java


示例11: parsePrimaryExpression

import gnu.text.SyntaxException; //导入依赖的package包/类
public Expression parsePrimaryExpression()
   throws java.io.IOException, SyntaxException
 {
   Object result = getToken();
   if (result instanceof QuoteExp)
     return (QuoteExp) result;
   if (result instanceof String)
     return new ReferenceExp((String) result);
   if (result == Lexer.lparenToken)
     {
Expression expr = parseExpression();
Object token = getToken();
if (token != Lexer.rparenToken)
  return syntaxError("expected ')' - got:"+token);
return expr;
     }
   return syntaxError("unexpected token: "+result);
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:19,代码来源:Parser.java


示例12: parseArguments

import gnu.text.SyntaxException; //导入依赖的package包/类
public Expression[] parseArguments()
   throws java.io.IOException, SyntaxException
 {
   skipToken();
   Object token = peekToken();
   if (token == Lexer.rparenToken)
     {
skipToken();
return emptyArgs;
     }
   Vector args = new Vector(10);
   for (;;)
     {
Expression arg = parseAssignmentExpression();
args.addElement(arg);
token = getToken();
if (token == Lexer.rparenToken)
  break;
if (token != Lexer.commaToken)
  syntaxError("invalid token '"+token+"' in argument list");
     }
   Expression[] exps = new Expression[args.size()];
   args.copyInto(exps);
   return exps;
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:26,代码来源:Parser.java


示例13: parseBinaryExpression

import gnu.text.SyntaxException; //导入依赖的package包/类
public Expression parseBinaryExpression(int prio)
   throws java.io.IOException, SyntaxException
 {
   Expression exp1 = parseUnaryExpression();
   for (;;)
     {
token = peekToken();
if (! (token instanceof Reserved))
  return exp1;
Reserved op = (Reserved) token;
if (op.prio < prio)
  return exp1;
getToken();
Expression exp2 = parseBinaryExpression(op.prio+1);
Expression[] args = { exp1, exp2 };
exp1 = new ApplyExp(new QuoteExp(op.proc), args);
     }
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:19,代码来源:Parser.java


示例14: parseIfStatement

import gnu.text.SyntaxException; //导入依赖的package包/类
public Expression parseIfStatement()
   throws java.io.IOException, SyntaxException
 {
   skipToken();
   Object token = getToken();
   if (token != Lexer.lparenToken)
     return syntaxError("expected '(' - got:"+token);
   Expression test_part = parseExpression();
   token = getToken();
   if (token != Lexer.rparenToken)
     return syntaxError("expected ')' - got:"+token);
   Expression then_part = parseStatement();
   token = peekToken();
   Expression else_part;
   if (token == Lexer.elseToken)
     {
skipToken();
else_part = parseStatement();
     }
   else
     else_part = null;
   return new IfExp(test_part, then_part, else_part);
 }
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:24,代码来源:Parser.java


示例15: syntaxError

import gnu.text.SyntaxException; //导入依赖的package包/类
/**
  * Handle syntax errors (at rewrite time).
  * @param message an error message to print out
  * @return an ErrorExp
  */
 public Expression syntaxError (String message, String code)
   throws java.io.IOException, SyntaxException
 {
   error('e', message, code);
   if (interactive)
     {
curToken = 0;
curValue = null;
nesting = 0;
((InPort) getPort()).readState = '\n';
for (;;)
  {
    int ch = read();
    if (ch < 0)
      break;
    if (ch == '\r' || ch == '\n')
      {
	unread(ch);
	break;
      }
  }
throw new SyntaxException(getMessages());
     }
   return new ErrorExp (message);
 }
 
开发者ID:maoueh,项目名称:kawa-fork,代码行数:31,代码来源:XQParser.java


示例16: apply2

import gnu.text.SyntaxException; //导入依赖的package包/类
public final Object apply2 (Object name, Object arg2)
   throws Throwable
 {
   try
     {
Environment env = (Environment) arg2;
       Path path = Path.valueOf(name);
       if (relative)
         {
           Path curPath = (Path) Shell.currentLoadPath.get();
           if (curPath != null)
             path = curPath.resolve(path);
         }
       Shell.runFile(path.openInputStream(), path, env, true, 0);
return Values.empty;
     }
   catch (java.io.FileNotFoundException e)
     {
throw new RuntimeException ("cannot load "+e.getMessage());
     }
   catch (SyntaxException ex)
     {
throw new RuntimeException("load: errors while compiling '"+
			   name+"':\n"+ex.getMessages().toString(20));
     }
 }
 
开发者ID:mit-cml,项目名称:ai2-kawa,代码行数:27,代码来源:load.java


示例17: read

import gnu.text.SyntaxException; //导入依赖的package包/类
public Object read (Lexer in, int ch, int count)
   throws java.io.IOException, SyntaxException
 {
   LispReader reader = (LispReader) in;
   String file = reader.getName();
   int line1 = reader.getLineNumber() + 1;
   int column1 = reader.getColumnNumber() + 1;
   Object magic = magicSymbol;
   if (next != '\0')
     {
ch = reader.read();
if (ch == next)
  magic = magicSymbol2;
else if (ch >= 0)
  reader.unread(ch);
     }
   int line2 = reader.getLineNumber() + 1;
   int column2 = reader.getColumnNumber() + 1;
   Object operand = reader.readObject();
   return PairWithPosition.make(magic,
                                PairWithPosition.make(operand,
                                                      reader.makeNil(),
                                                      file, line2, column2),
                                file, line1, column1);
 }
 
开发者ID:mit-cml,项目名称:ai2-kawa,代码行数:26,代码来源:ReaderQuote.java


示例18: printError

import gnu.text.SyntaxException; //导入依赖的package包/类
public static void printError (Throwable ex, SourceMessages messages,
                               OutPort perr)
{
  if (ex instanceof WrongArguments)
    {
      WrongArguments e = (WrongArguments) ex;
      messages.printAll(perr, 20);
      if (e.usage != null)
        perr.println("usage: "+e.usage);
      e.printStackTrace(perr);
    }
  /*
  else if (ex instanceof java.io.IOException)
    {
      messages.printAll(perr, 20);
      String msg = new SourceError(inp, 'e', "").toString();
      msg = msg.substring(0, msg.length() - 2);
      perr.println(msg + " (or later): caught IOException");
      ex.printStackTrace(perr);
    }
  */
  else
    {
      SyntaxException se;
      if (ex instanceof SyntaxException
          && (se = (SyntaxException) ex).getMessages() == messages)
        {
          se.printAll(perr, 20);
          se.clear();
        }
      else
        {
          messages.printAll(perr, 20);
          ex.printStackTrace(perr);
        }
    }
  perr.flush();
}
 
开发者ID:spurious,项目名称:kawa-mirror,代码行数:39,代码来源:Shell.java



注:本文中的gnu.text.SyntaxException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TermPositionVector类代码示例发布时间:2022-05-15
下一篇:
Java ClientIdentifier类代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap