⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serqlparser.java

📁 这是外国一个开源推理机
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      ;    }                        if (projection == null) {                                // "SELECT *", take all shared variables from the graph pattern                                Set gpVariables = new HashSet();                                graphPattern.getVariables(gpVariables);                                List projVars = new ArrayList(_sharedVars);                                projVars.retainAll(gpVariables);                                projection = new ArrayList(projVars.size());                                // Create ProjectionElem objects for all gathered variables                                for (int i = 0; i < projVars.size(); i++) {                                        Var var = (Var)projVars.get(i);                                        projection.add( new ProjectionElem(var) );                                }                        }                        if (projection.isEmpty()) {                                {if (true) throw new ParseException("Select clause does not contain any variables.");}                        }                        SelectQuery result = new SelectQuery(distinct, projection, graphPattern);                        if (hasLimit) {                                result.setLimit(limit);                        }                        if (hasOffset) {                                result.setOffset(offset);                        }                        {if (true) return result;}    throw new Error("Missing return statement in function");  }  final public Query construct_query() throws ParseException {        boolean distinct = false;        GraphPattern constructExpressions = null;        GraphPattern graphPattern = new GraphPattern();        boolean hasLimit = false, hasOffset = false;        int limit = -1, offset = -1;    jj_consume_token(CONSTRUCT);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case DISTINCT:      jj_consume_token(DISTINCT);                       distinct = true;      break;    default:      jj_la1[15] = jj_gen;      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case STAR:      jj_consume_token(STAR);      break;    case LBRACE:    case LBRACK:                  constructExpressions = new GraphPattern();      path_expr_list(constructExpressions);      break;    default:      jj_la1[16] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case FROM:      jj_consume_token(FROM);      graph_pattern(graphPattern);      break;    default:      jj_la1[17] = jj_gen;      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case LIMIT:      jj_consume_token(LIMIT);      limit = pos_integer();                                          hasLimit = true;      break;    default:      jj_la1[18] = jj_gen;      ;    }    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case OFFSET:      jj_consume_token(OFFSET);      offset = pos_integer();                                            hasOffset = true;      break;    default:      jj_la1[19] = jj_gen;      ;    }                        // Check if '*' was used in the construct clause                        if (constructExpressions == null) {                                constructExpressions = graphPattern;                        }                        // List of TriplePattern objects                        List constructList = new ArrayList(constructExpressions.getPathExpressionsRecursively());                        ConstructQuery result = new ConstructQuery(distinct, constructList, graphPattern);                        if (hasLimit) {                                result.setLimit(limit);                        }                        if (hasOffset) {                                result.setOffset(offset);                        }                        {if (true) return result;}    throw new Error("Missing return statement in function");  }  final public List projection() throws ParseException {        ProjectionElem projElem;        List projection = new ArrayList(16);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case STAR:      jj_consume_token(STAR);                 {if (true) return null;}      break;    case UNDERSCORE:    case NAMESPACE:    case LABEL:    case LANG:    case DATATYPE:    case LOCALNAME:    case NULL:    case LITERAL:    case FULL_URI:    case BNODE:    case QNAME:    case PREFIX_NAME:    case POS_INTEGER:    case NEG_INTEGER:    case DECIMAL:      projElem = projection_elem();                                        projection.add(projElem);      label_2:      while (true) {        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case COMMA:          ;          break;        default:          jj_la1[20] = jj_gen;          break label_2;        }        jj_consume_token(COMMA);        projElem = projection_elem();                                                        projection.add(projElem);      }                        {if (true) return projection;}      break;    default:      jj_la1[21] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }    throw new Error("Missing return statement in function");  }  final public ProjectionElem projection_elem() throws ParseException {        ValueExpr item;        String alias = null;    item = var_or_value();    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case AS:      jj_consume_token(AS);      alias = string();      break;    default:      jj_la1[22] = jj_gen;      ;    }                {if (true) return new ProjectionElem(item, alias);}    throw new Error("Missing return statement in function");  }  final public void graph_pattern(GraphPattern graphPattern) throws ParseException {        BooleanExpr where;    path_expr_list(graphPattern);    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case WHERE:      jj_consume_token(WHERE);      where = boolean_expr();                        graphPattern.addConstraint(where);      break;    default:      jj_la1[23] = jj_gen;      ;    }  }  final public void path_expr_list(GraphPattern graphPattern) throws ParseException {    path_expr(graphPattern);    label_3:    while (true) {      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case COMMA:        ;        break;      default:        jj_la1[24] = jj_gen;        break label_3;      }      jj_consume_token(COMMA);      path_expr(graphPattern);    }  }  final public void path_expr(GraphPattern graphPattern) throws ParseException {        PathElement pe;        GraphPattern optionalGP;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case LBRACE:      pe = path_expr_head(graphPattern);      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case SEMICOLON:      case LBRACK:      case UNDERSCORE:      case FULL_URI:      case QNAME:      case PREFIX_NAME:        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case LBRACK:        case UNDERSCORE:        case FULL_URI:        case QNAME:        case PREFIX_NAME:          path_expr_tail(pe.getObjectVars(), graphPattern);          break;        case SEMICOLON:          jj_consume_token(SEMICOLON);          path_expr_tail(pe.getSubjectVars(), graphPattern);          break;        default:          jj_la1[25] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }        break;      default:        jj_la1[26] = jj_gen;        ;      }      break;    case LBRACK:      jj_consume_token(LBRACK);                        optionalGP = new GraphPattern();                        // Create new variable scope                        VarTreeNode node = new VarTreeNode();                        _currentTreeNode.addChild(node);                        _currentTreeNode = node;      graph_pattern(optionalGP);      jj_consume_token(RBRACK);                        graphPattern.addOptional(optionalGP);                        // Restore variable scope                        _currentTreeNode = _currentTreeNode.getParent();      break;    default:      jj_la1[27] = jj_gen;      jj_consume_token(-1);      throw new ParseException();    }  }  final public PathElement path_expr_head(GraphPattern graphPattern) throws ParseException {        List leftNode, rightNode;        Var edge;    leftNode = node(graphPattern);    edge = edge();    rightNode = node(graphPattern);                        PathElement pe = new PathElement(leftNode, edge, rightNode);                        graphPattern.addAll( pe.getTriplePatterns() );                        {if (true) return pe;}    throw new Error("Missing return statement in function");  }  final public void path_expr_tail(List leftNode, GraphPattern graphPattern) throws ParseException {        Var edge;        List rightNode;        PathElement pe;        GraphPattern optionalGP;        BooleanExpr where;    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {    case UNDERSCORE:    case FULL_URI:    case QNAME:    case PREFIX_NAME:      edge = edge();      rightNode = node(graphPattern);                        pe = new PathElement(leftNode, edge, rightNode);                        graphPattern.addAll( pe.getTriplePatterns() );      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case SEMICOLON:      case LBRACK:      case UNDERSCORE:      case FULL_URI:      case QNAME:      case PREFIX_NAME:        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case LBRACK:        case UNDERSCORE:        case FULL_URI:        case QNAME:        case PREFIX_NAME:          path_expr_tail(rightNode, graphPattern);          break;        case SEMICOLON:          jj_consume_token(SEMICOLON);          path_expr_tail(leftNode, graphPattern);          break;        default:          jj_la1[28] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }        break;      default:        jj_la1[29] = jj_gen;        ;      }      break;    case LBRACK:      jj_consume_token(LBRACK);                        optionalGP = new GraphPattern();                        // Create new variable scope                        VarTreeNode node = new VarTreeNode();                        _currentTreeNode.addChild(node);                        _currentTreeNode = node;      edge = edge();      rightNode = node(optionalGP);                        pe = new PathElement(leftNode, edge, rightNode);                        optionalGP.addAll( pe.getTriplePatterns() );      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case SEMICOLON:      case LBRACK:      case UNDERSCORE:      case FULL_URI:      case QNAME:      case PREFIX_NAME:        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {        case LBRACK:        case UNDERSCORE:        case FULL_URI:        case QNAME:        case PREFIX_NAME:          path_expr_tail(rightNode, optionalGP);          break;        case SEMICOLON:          jj_consume_token(SEMICOLON);          path_expr_tail(leftNode, optionalGP);          break;        default:          jj_la1[30] = jj_gen;          jj_consume_token(-1);          throw new ParseException();        }        break;      default:        jj_la1[31] = jj_gen;        ;      }      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case WHERE:        jj_consume_token(WHERE);        where = boolean_expr();                        optionalGP.addConstraint(where);        break;      default:        jj_la1[32] = jj_gen;        ;      }      jj_consume_token(RBRACK);                        graphPattern.addOptional(optionalGP);                        // Restore variable scope                        _currentTreeNode = _currentTreeNode.getParent();      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {      case SEMICOLON:        jj_consume_token(SEMICOLON);        path_expr_tail(leftNode, graphPattern);        break;      default:        jj_la1[33] = jj_gen;        ;      }      break;    default:      jj_la1[34] = jj_gen;      jj_consume_token(-1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -