示例#1
0
  public static Expr parse(Query query, String s, boolean checkAllUsed) {
    try {
      Reader in = new StringReader(s);
      ARQParser parser = new ARQParser(in);
      parser.setQuery(query);
      Expr expr = parser.Expression();

      if (checkAllUsed) {
        Token t = parser.getNextToken();
        if (t.kind != ARQParserTokenManager.EOF)
          throw new QueryParseException(
              "Extra tokens beginning \""
                  + t.image
                  + "\" starting line "
                  + t.beginLine
                  + ", column "
                  + t.beginColumn,
              t.beginLine,
              t.beginColumn);
      }
      return expr;
    } catch (ParseException ex) {
      throw new QueryParseException(
          ex.getMessage(), ex.currentToken.beginLine, ex.currentToken.beginLine);
    } catch (TokenMgrError tErr) {
      throw new QueryParseException(tErr.getMessage(), -1, -1);
    } catch (Error err) {
      // The token stream can throw java.lang.Error's
      String tmp = err.getMessage();
      if (tmp == null) throw new QueryParseException(err, -1, -1);
      throw new QueryParseException(tmp, -1, -1);
    }
  }
 public ExParValue getExParValue() {
   ExParValue v = null;
   try {
     // ExDesignTreeParser parser = new ExDesignTreeParser(new
     // StringReader(text.getText()), Base.getEncoding());
     ExDesignTreeParser parser = new ExDesignTreeParser(new StringReader(text.getText()));
     v = parser.assignableParameterValue();
   } catch (ParseException pex) {
     new de.pxlab.pxl.NonFatalError(pex.getMessage());
   } catch (TokenMgrError tex) {
     new de.pxlab.pxl.NonFatalError(tex.getMessage());
   }
   return v;
 }