You are here

function ARC_sparql_parser::parse_NumericLiteral in Taxonomy import/export via XML 5

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

File

arc/ARC_sparql_parser.php, line 1518

Class

ARC_sparql_parser

Code

function parse_NumericLiteral($val = "") {

  /* double */
  if (preg_match("/^[0-9]*\\.?[0-9]*[eE][+-]?[0-9]+/", $val, $matches)) {
    return array(
      "type" => "numeric",
      "val" => $matches[0],
      "sub_type" => "double",
      "unparsed_val" => trim(substr($val, strlen($matches[0]))),
    );
  }

  /* decimal 1 */
  if (preg_match("/^[0-9]+\\.[0-9]+/", $val, $matches)) {
    return array(
      "type" => "numeric",
      "val" => $matches[0],
      "sub_type" => "decimal",
      "unparsed_val" => trim(substr($val, strlen($matches[0]))),
    );
  }

  /* decimal 2 */
  if (preg_match("/^[0-9]+\\.[0-9]*/", $val, $matches)) {
    return array(
      "type" => "numeric",
      "val" => $matches[0],
      "sub_type" => "decimal",
      "unparsed_val" => trim(substr($val, strlen($matches[0]))),
    );
  }

  /* decimal 3 */
  if (preg_match("/^[0-9]*\\.[0-9]+/", $val, $matches)) {
    return array(
      "type" => "numeric",
      "val" => $matches[0],
      "sub_type" => "decimal",
      "unparsed_val" => trim(substr($val, strlen($matches[0]))),
    );
  }

  /* integer */
  if (preg_match("/^[0-9]+/", $val, $matches)) {
    return array(
      "type" => "numeric",
      "val" => $matches[0],
      "sub_type" => "integer",
      "unparsed_val" => trim(substr($val, strlen($matches[0]))),
    );
  }

  /* else */
  return false;
}