You are here

function ARC_sparql_parser::parse_BuiltInCall in Taxonomy import/export via XML 6.2

Same name and namespace in other branches
  1. 5.2 arc/ARC_sparql_parser.php \ARC_sparql_parser::parse_BuiltInCall()
  2. 5 arc/ARC_sparql_parser.php \ARC_sparql_parser::parse_BuiltInCall()
  3. 6 arc/ARC_sparql_parser.php \ARC_sparql_parser::parse_BuiltInCall()
2 calls to ARC_sparql_parser::parse_BuiltInCall()
ARC_sparql_parser::parse_Constraint in arc/ARC_sparql_parser.php
ARC_sparql_parser::parse_PrimaryExpression in arc/ARC_sparql_parser.php

File

arc/ARC_sparql_parser.php, line 1328

Class

ARC_sparql_parser

Code

function parse_BuiltInCall($val = "") {

  /* bound */
  if (preg_match("/^BOUND\\s*\\([\\?\$]{1}([0-9a-z_]+)\\)/is", $val, $matches)) {
    return array(
      "type" => "built_in_call",
      "call" => "bound",
      "var" => $matches[1],
      "unparsed_val" => trim(substr($val, strlen($matches[0]))),
    );
  }

  /* str, lang, etc (single-entry argument lists) */
  if (preg_match("/^(STR|LANG|DATATYPE|isIRI|isURI|isBlank|isLiteral)(\\s*)(\\(.*)\$/is", $val, $matches)) {
    $bracket_data = $this
      ->extract_bracket_data($matches[3]);
    return array(
      "type" => "built_in_call",
      "call" => strtolower($matches[1]),
      "expression" => $this
        ->parse_Expression(trim($bracket_data)),
      "unparsed_val" => trim(substr($val, strlen($matches[1] . $matches[2] . $bracket_data) + 2)),
    );
  }

  /* langmatches (2 arguments) */
  if (preg_match("/^(langMatches)(\\s*)(\\(.*)\$/is", $val, $matches)) {
    $bracket_data = $this
      ->extract_bracket_data($matches[3]);
    $expr_1 = $this
      ->parse_Expression(trim($bracket_data));
    $rest = trim($expr_1["unparsed_val"]);
    $expr_2 = preg_match("/^,\\s*(.*)\$/s", $rest, $sub_matches) ? $this
      ->parse_Expression(trim($sub_matches[1])) : array();
    return array(
      "type" => "built_in_call",
      "call" => strtolower($matches[1]),
      "expressions" => array(
        $expr_1,
        $expr_2,
      ),
      "unparsed_val" => trim(substr($val, strlen($matches[1] . $matches[2] . $bracket_data) + 2)),
    );
  }

  /* regex */
  if (preg_match("/^(REGEX)(\\s*)(\\(.*)\$/is", $val, $matches)) {
    $bracket_data = $this
      ->extract_bracket_data($matches[3]);
    $expr_1 = $this
      ->parse_Expression(trim($bracket_data));
    $expr_2 = preg_match("/^,\\s*(.*)\$/s", trim($expr_1["unparsed_val"]), $sub_matches) ? $this
      ->parse_Expression(trim($sub_matches[1])) : array();
    $expr_3 = preg_match("/^,\\s*(.*)\$/s", trim($expr_2["unparsed_val"]), $sub_matches) ? $this
      ->parse_Expression(trim($sub_matches[1])) : array();
    return array(
      "type" => "built_in_call",
      "call" => strtolower($matches[1]),
      "expressions" => array(
        $expr_1,
        $expr_2,
        $expr_3,
      ),
      "unparsed_val" => trim(substr($val, strlen($matches[1] . $matches[2] . $bracket_data) + 2)),
    );
  }
  return false;
}