You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by jr...@apache.org on 2017/09/27 17:00:44 UTC

qpid-proton git commit: PROTON-1368: Remove the unused parser and scanner code

Repository: qpid-proton
Updated Branches:
  refs/heads/master a181656d2 -> ea02b9337


PROTON-1368: Remove the unused parser and scanner code


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ea02b933
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ea02b933
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ea02b933

Branch: refs/heads/master
Commit: ea02b93374b527206eef3a1c7def939eff7804fb
Parents: a181656
Author: Justin Ross <jr...@apache.org>
Authored: Wed Sep 27 10:00:31 2017 -0700
Committer: Justin Ross <jr...@apache.org>
Committed: Wed Sep 27 10:00:31 2017 -0700

----------------------------------------------------------------------
 proton-c/CMakeLists.txt           |   4 -
 proton-c/docs/api/user.doxygen.in |   1 -
 proton-c/include/proton/parser.h  |  52 ----
 proton-c/src/core/message.c       |   1 -
 proton-c/src/extra/parser.c       | 423 ---------------------------------
 proton-c/src/extra/scanner.c      | 401 -------------------------------
 proton-c/src/extra/scanner.h      |  74 ------
 7 files changed, 956 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 8c64099..9248068 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -404,7 +404,6 @@ set (qpid-proton-include-generated
   )
 
 set (qpid-proton-private-includes
-  src/extra/scanner.h
   src/messenger/store.h
   src/messenger/subscription.h
   src/messenger/messenger.h
@@ -437,8 +436,6 @@ set (qpid-proton-private-includes
   )
 
 set (qpid-proton-extra
-  src/extra/parser.c
-  src/extra/scanner.c
   src/extra/url.c
 
   src/reactor/reactor.c
@@ -490,7 +487,6 @@ set (qpid-proton-include
 set (qpid-proton-include-extra
   include/proton/handlers.h
   include/proton/messenger.h
-  include/proton/parser.h
   include/proton/reactor.h
   include/proton/selectable.h
   include/proton/url.h

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/docs/api/user.doxygen.in
----------------------------------------------------------------------
diff --git a/proton-c/docs/api/user.doxygen.in b/proton-c/docs/api/user.doxygen.in
index eb20317..7b8f809 100644
--- a/proton-c/docs/api/user.doxygen.in
+++ b/proton-c/docs/api/user.doxygen.in
@@ -62,7 +62,6 @@ EXCLUDE_PATTERNS        = */examples/*.c \
                           */include/proton/import_export.h \
                           */include/proton/log.h \
                           */include/proton/object.h \
-                          */include/proton/parser.h \
                           */include/proton/reactor.h \
                           */include/proton/sasl-plugin.h \
                           */include/proton/selectable.h \

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/include/proton/parser.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/parser.h b/proton-c/include/proton/parser.h
deleted file mode 100644
index a95ca86..0000000
--- a/proton-c/include/proton/parser.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef PROTON_PARSER_H
-#define PROTON_PARSER_H 1
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include <proton/import_export.h>
-#include <proton/codec.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * @cond INTERNAL
- */
-
-typedef struct pn_parser_t pn_parser_t;
-
-PN_EXTERN pn_parser_t *pn_parser(void);
-PN_EXTERN int pn_parser_parse(pn_parser_t *parser, const char *str, pn_data_t *data);
-PN_EXTERN int pn_parser_errno(pn_parser_t *parser);
-PN_EXTERN const char *pn_parser_error(pn_parser_t *parser);
-PN_EXTERN void pn_parser_free(pn_parser_t *parser);
-
-/**
- * @endcond
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* parser.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/src/core/message.c
----------------------------------------------------------------------
diff --git a/proton-c/src/core/message.c b/proton-c/src/core/message.c
index ecf8f43..038c836 100644
--- a/proton-c/src/core/message.c
+++ b/proton-c/src/core/message.c
@@ -29,7 +29,6 @@
 #include <proton/object.h>
 #include <proton/codec.h>
 #include <proton/error.h>
-#include <proton/parser.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/src/extra/parser.c
----------------------------------------------------------------------
diff --git a/proton-c/src/extra/parser.c b/proton-c/src/extra/parser.c
deleted file mode 100644
index 36fb4fb..0000000
--- a/proton-c/src/extra/parser.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include <proton/parser.h>
-
-#include "platform/platform.h"
-#include "scanner.h"
-
-#include <proton/error.h>
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-struct pn_parser_t {
-  pn_scanner_t *scanner;
-  char *atoms;
-  size_t size;
-  size_t capacity;
-  int error_code;
-};
-
-pn_parser_t *pn_parser()
-{
-  pn_parser_t *parser = (pn_parser_t *) malloc(sizeof(pn_parser_t));
-  if (parser != NULL) {
-    parser->scanner = pn_scanner();
-    parser->atoms = NULL;
-    parser->size = 0;
-    parser->capacity = 0;
-  }
-  return parser;
-}
-
-static void pni_parser_ensure(pn_parser_t *parser, size_t size)
-{
-  while (parser->capacity - parser->size < size) {
-    parser->capacity = parser->capacity ? 2 * parser->capacity : 1024;
-    parser->atoms = (char *) realloc(parser->atoms, parser->capacity);
-  }
-}
-
-int pn_parser_err(pn_parser_t *parser, int code, const char *fmt, ...)
-{
-  va_list ap;
-  va_start(ap, fmt);
-  int err = pn_scanner_verr(parser->scanner, code, fmt, ap);
-  va_end(ap);
-  return err;
-}
-
-int pn_parser_errno(pn_parser_t *parser)
-{
-  return pn_scanner_errno(parser->scanner);
-}
-
-const char *pn_parser_error(pn_parser_t *parser)
-{
-  return pn_scanner_error(parser->scanner);
-}
-
-void pn_parser_free(pn_parser_t *parser)
-{
-  if (parser) {
-    pn_scanner_free(parser->scanner);
-    free(parser->atoms);
-    free(parser);
-  }
-}
-
-static int pni_parser_shift(pn_parser_t *parser)
-{
-  return pn_scanner_shift(parser->scanner);
-}
-
-static pn_token_t pni_parser_token(pn_parser_t *parser)
-{
-  return pn_scanner_token(parser->scanner);
-}
-
-static int pni_parser_value(pn_parser_t *parser, pn_data_t *data);
-
-static int pni_parser_descriptor(pn_parser_t *parser, pn_data_t *data)
-{
-  if (pni_parser_token(parser).type == PN_TOK_AT) {
-    int err = pni_parser_shift(parser);
-    if (err) return err;
-
-    err = pn_data_put_described(data);
-    if (err) return pn_parser_err(parser, err, "error writing described");
-    pn_data_enter(data);
-    for (int i = 0; i < 2; i++) {
-      err = pni_parser_value(parser, data);
-      if (err) return err;
-    }
-    pn_data_exit(data);
-    return 0;
-  } else {
-    return pn_parser_err(parser, PN_ERR, "expecting '@'");
-  }
-}
-
-static int pni_parser_map(pn_parser_t *parser, pn_data_t *data)
-{
-  if (pni_parser_token(parser).type == PN_TOK_LBRACE) {
-    int err = pni_parser_shift(parser);
-    if (err) return err;
-
-    err = pn_data_put_map(data);
-    if (err) return pn_parser_err(parser, err, "error writing map");
-
-    pn_data_enter(data);
-
-    if (pni_parser_token(parser).type != PN_TOK_RBRACE) {
-      while (true) {
-        err = pni_parser_value(parser, data);
-        if (err) return err;
-
-        if (pni_parser_token(parser).type == PN_TOK_EQUAL) {
-          err = pni_parser_shift(parser);
-          if (err) return err;
-        } else {
-          return pn_parser_err(parser, PN_ERR, "expecting '='");
-        }
-
-        err = pni_parser_value(parser, data);
-        if (err) return err;
-
-        if (pni_parser_token(parser).type == PN_TOK_COMMA) {
-          err = pni_parser_shift(parser);
-          if (err) return err;
-        } else {
-          break;
-        }
-      }
-    }
-
-    pn_data_exit(data);
-
-    if (pni_parser_token(parser).type == PN_TOK_RBRACE) {
-      return pni_parser_shift(parser);
-    } else {
-      return pn_parser_err(parser, PN_ERR, "expecting '}'");
-    }
-  } else {
-    return pn_parser_err(parser, PN_ERR, "expecting '{'");
-  }
-}
-
-static int pni_parser_list(pn_parser_t *parser, pn_data_t *data)
-{
-  int err;
-
-  if (pni_parser_token(parser).type == PN_TOK_LBRACKET) {
-    err = pni_parser_shift(parser);
-    if (err) return err;
-
-    err = pn_data_put_list(data);
-    if (err) return pn_parser_err(parser, err, "error writing list");
-
-    pn_data_enter(data);
-
-    if (pni_parser_token(parser).type != PN_TOK_RBRACKET) {
-      while (true) {
-        err = pni_parser_value(parser, data);
-        if (err) return err;
-
-        if (pni_parser_token(parser).type == PN_TOK_COMMA) {
-          err = pni_parser_shift(parser);
-          if (err) return err;
-        } else {
-          break;
-        }
-      }
-    }
-
-    pn_data_exit(data);
-
-    if (pni_parser_token(parser).type == PN_TOK_RBRACKET) {
-      return pni_parser_shift(parser);
-    } else {
-      return pn_parser_err(parser, PN_ERR, "expecting ']'");
-    }
-  } else {
-    return pn_parser_err(parser, PN_ERR, "expecting '['");
-  }
-}
-
-static void pni_parser_append_tok(pn_parser_t *parser, char *dst, int *idx)
-{
-  memcpy(dst + *idx, pni_parser_token(parser).start, pni_parser_token(parser).size);
-  *idx += pni_parser_token(parser).size;
-}
-
-static int pni_parser_number(pn_parser_t *parser, pn_data_t *data)
-{
-  bool dbl = false;
-  char number[1024];
-  int idx = 0;
-  int err;
-
-  bool negate = false;
-
-  if (pni_parser_token(parser).type == PN_TOK_NEG || pni_parser_token(parser).type == PN_TOK_POS) {
-    if (pni_parser_token(parser).type == PN_TOK_NEG)
-      negate = !negate;
-    err = pni_parser_shift(parser);
-    if (err) return err;
-  }
-
-  if (pni_parser_token(parser).type == PN_TOK_FLOAT || pni_parser_token(parser).type == PN_TOK_INT) {
-    dbl = pni_parser_token(parser).type == PN_TOK_FLOAT;
-    pni_parser_append_tok(parser, number, &idx);
-    err = pni_parser_shift(parser);
-    if (err) return err;
-  } else {
-    return pn_parser_err(parser, PN_ERR, "expecting FLOAT or INT");
-  }
-
-  number[idx] = '\0';
-
-  if (dbl) {
-    double value = atof(number);
-    if (negate) {
-      value = -value;
-    }
-    err = pn_data_put_double(data, value);
-    if (err) return pn_parser_err(parser, err, "error writing double");
-  } else {
-    int64_t value = pn_i_atoll(number);
-    if (negate) {
-      value = -value;
-    }
-    err = pn_data_put_long(data, value);
-    if (err) return pn_parser_err(parser, err, "error writing long");
-  }
-
-  return 0;
-}
-
-static int pni_parser_unquote(pn_parser_t *parser, char *dst, const char *src, size_t *n)
-{
-  size_t idx = 0;
-  bool escape = false;
-  int start, end;
-  if (src[0] != '"') {
-    if (src[1] == '"') {
-      start = 2;
-      end = *n - 1;
-    } else {
-      start = 1;
-      end = *n;
-    }
-  } else {
-    start = 1;
-    end = *n - 1;
-  }
-  for (int i = start; i < end; i++)
-  {
-    char c = src[i];
-    if (escape) {
-      switch (c) {
-      case '"':
-      case '\\':
-      case '/':
-        dst[idx++] = c;
-        escape = false;
-        break;
-      case 'b':
-        dst[idx++] = '\b';
-        break;
-      case 'f':
-        dst[idx++] = '\f';
-        break;
-      case 'n':
-        dst[idx++] = '\n';
-        break;
-      case 'r':
-        dst[idx++] = '\r';
-        break;
-      case 't':
-        dst[idx++] = '\t';
-        break;
-      case 'x':
-        {
-          char n1 = toupper(src[i+1]);
-          char n2 = n1 ? toupper(src[i+2]) : 0;
-          if (!n2) {
-            return pn_parser_err(parser, PN_ERR, "truncated escape code");
-          }
-          int d1 = isdigit(n1) ? n1 - '0' : n1 - 'A' + 10;
-          int d2 = isdigit(n2) ? n2 - '0' : n2 - 'A' + 10;
-          dst[idx++] = d1*16 + d2;
-          i += 2;
-        }
-        break;
-      // XXX: need to handle unicode escapes: 'u'
-      default:
-        return pn_parser_err(parser, PN_ERR, "unrecognized escape code");
-      }
-      escape = false;
-    } else {
-      switch (c)
-      {
-      case '\\':
-        escape = true;
-        break;
-      default:
-        dst[idx++] = c;
-        break;
-      }
-    }
-  }
-  dst[idx++] = '\0';
-  *n = idx;
-  return 0;
-}
-
-static int pni_parser_value(pn_parser_t *parser, pn_data_t *data)
-{
-  int err;
-  size_t n;
-  char *dst;
-
-  pn_token_t tok = pni_parser_token(parser);
-
-  switch (tok.type)
-  {
-  case PN_TOK_AT:
-    return pni_parser_descriptor(parser, data);
-  case PN_TOK_LBRACE:
-    return pni_parser_map(parser, data);
-  case PN_TOK_LBRACKET:
-    return pni_parser_list(parser, data);
-  case PN_TOK_BINARY:
-  case PN_TOK_SYMBOL:
-  case PN_TOK_STRING:
-    n = tok.size;
-    pni_parser_ensure(parser, n);
-    dst = parser->atoms + parser->size;
-    err = pni_parser_unquote(parser, dst, tok.start, &n);
-    if (err) return err;
-    parser->size += n;
-    switch (tok.type) {
-    case PN_TOK_BINARY:
-      err = pn_data_put_binary(data, pn_bytes(n - 1, dst));
-      break;
-    case PN_TOK_STRING:
-      err = pn_data_put_string(data, pn_bytes(n - 1, dst));
-      break;
-    case PN_TOK_SYMBOL:
-      err = pn_data_put_symbol(data, pn_bytes(n - 1, dst));
-      break;
-    default:
-      return pn_parser_err(parser, PN_ERR, "internal error");
-    }
-    if (err) return pn_parser_err(parser, err, "error writing string/binary/symbol");
-    return pni_parser_shift(parser);
-  case PN_TOK_POS:
-  case PN_TOK_NEG:
-  case PN_TOK_FLOAT:
-  case PN_TOK_INT:
-    return pni_parser_number(parser, data);
-  case PN_TOK_TRUE:
-    err = pn_data_put_bool(data, true);
-    if (err) return pn_parser_err(parser, err, "error writing boolean");
-    return pni_parser_shift(parser);
-  case PN_TOK_FALSE:
-    err = pn_data_put_bool(data, false);
-    if (err) return pn_parser_err(parser, err, "error writing boolean");
-    return pni_parser_shift(parser);
-  case PN_TOK_NULL:
-    err = pn_data_put_null(data);
-    if (err) return pn_parser_err(parser, err, "error writing null");
-    return pni_parser_shift(parser);
-  default:
-    return pn_parser_err(parser, PN_ERR, "expecting one of '[', '{', STRING, "
-                         "SYMBOL, BINARY, true, false, null, NUMBER");
-  }
-}
-
-static int pni_parser_parse_r(pn_parser_t *parser, pn_data_t *data)
-{
-  while (true) {
-    int err;
-    switch (pni_parser_token(parser).type)
-    {
-    case PN_TOK_EOS:
-      return 0;
-    case PN_TOK_ERR:
-      return PN_ERR;
-    default:
-      err = pni_parser_value(parser, data);
-      if (err) return err;
-    }
-  }
-}
-
-int pn_parser_parse(pn_parser_t *parser, const char *str, pn_data_t *data)
-{
-  int err = pn_scanner_start(parser->scanner, str);
-  if (err) return err;
-  parser->size = 0;
-  return pni_parser_parse_r(parser, data);
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/src/extra/scanner.c
----------------------------------------------------------------------
diff --git a/proton-c/src/extra/scanner.c b/proton-c/src/extra/scanner.c
deleted file mode 100644
index 99c35d2..0000000
--- a/proton-c/src/extra/scanner.c
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include "scanner.h"
-#include "../core/util.h"
-
-#include "platform/platform.h"
-
-#include <proton/error.h>
-#ifndef __cplusplus
-#include <stdbool.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#define ERROR_SIZE (1024)
-
-struct pn_scanner_t {
-  const char *input;
-  const char *position;
-  pn_token_t token;
-  char *atoms;
-  size_t size;
-  size_t capacity;
-  pn_error_t *error;
-};
-
-static const char *pni_token_type(pn_token_type_t type)
-{
-  switch (type)
-  {
-  case PN_TOK_LBRACE: return "LBRACE";
-  case PN_TOK_RBRACE: return "RBRACE";
-  case PN_TOK_LBRACKET: return "LBRACKET";
-  case PN_TOK_RBRACKET: return "RBRACKET";
-  case PN_TOK_EQUAL: return "EQUAL";
-  case PN_TOK_COMMA: return "COMMA";
-  case PN_TOK_POS: return "POS";
-  case PN_TOK_NEG: return "NEG";
-  case PN_TOK_DOT: return "DOT";
-  case PN_TOK_AT: return "AT";
-  case PN_TOK_DOLLAR: return "DOLLAR";
-  case PN_TOK_BINARY: return "BINARY";
-  case PN_TOK_STRING: return "STRING";
-  case PN_TOK_SYMBOL: return "SYMBOL";
-  case PN_TOK_ID: return "ID";
-  case PN_TOK_FLOAT: return "FLOAT";
-  case PN_TOK_INT: return "INT";
-  case PN_TOK_TRUE: return "TRUE";
-  case PN_TOK_FALSE: return "FALSE";
-  case PN_TOK_NULL: return "NULL";
-  case PN_TOK_EOS: return "EOS";
-  case PN_TOK_ERR: return "ERR";
-  default: return "<UNKNOWN>";
-  }
-}
-
-pn_scanner_t *pn_scanner()
-{
-  pn_scanner_t *scanner = (pn_scanner_t *) malloc(sizeof(pn_scanner_t));
-  if (scanner) {
-    scanner->input = NULL;
-    scanner->error = pn_error();
-  }
-  return scanner;
-}
-
-void pn_scanner_free(pn_scanner_t *scanner)
-{
-  if (scanner) {
-    pn_error_free(scanner->error);
-    free(scanner);
-  }
-}
-
-pn_token_t pn_scanner_token(pn_scanner_t *scanner)
-{
-  if (scanner) {
-    return scanner->token;
-  } else {
-    pn_token_t tok = {PN_TOK_ERR, 0, (size_t)0};
-    return tok;
-  }
-}
-
-void pn_scanner_line_info(pn_scanner_t *scanner, int *line, int *col)
-{
-  *line = 1;
-  *col = 0;
-
-  for (const char *c = scanner->input; *c && c <= scanner->token.start; c++) {
-    if (*c == '\n') {
-      *line += 1;
-      *col = -1;
-    } else {
-      *col += 1;
-    }
-  }
-}
-
-int pn_scanner_err(pn_scanner_t *scanner, int code, const char *fmt, ...)
-{
-  va_list ap;
-  va_start(ap, fmt);
-  int err = pn_scanner_verr(scanner, code, fmt, ap);
-  va_end(ap);
-  return err;
-}
-
-int pn_scanner_verr(pn_scanner_t *scanner, int code, const char *fmt, va_list ap)
-{
-  char error[ERROR_SIZE];
-
-  int line, col;
-  pn_scanner_line_info(scanner, &line, &col);
-  int size = scanner->token.size;
-  int ln = pni_snprintf(error, ERROR_SIZE,
-                    "input line %i column %i %s:'%.*s': ", line, col,
-                    pni_token_type(scanner->token.type),
-                    size, scanner->token.start);
-  if (ln >= ERROR_SIZE) {
-    return pn_scanner_err(scanner, code, "error info truncated");
-  } else if (ln < 0) {
-    error[0] = '\0';
-  }
-
-  int n = pni_snprintf(error + ln, ERROR_SIZE - ln, fmt, ap);
-
-  if (n >= ERROR_SIZE - ln) {
-    return pn_scanner_err(scanner, code, "error info truncated");
-  } else if (n < 0) {
-    error[0] = '\0';
-  }
-
-  return pn_error_set(scanner->error, code, error);
-}
-
-int pn_scanner_errno(pn_scanner_t *scanner)
-{
-  return pn_error_code(scanner->error);
-}
-
-const char *pn_scanner_error(pn_scanner_t *scanner)
-{
-  return pn_error_text(scanner->error);
-}
-
-static void pni_scanner_emit(pn_scanner_t *scanner, pn_token_type_t type, const char *start, size_t size)
-{
-  scanner->token.type = type;
-  scanner->token.start = start;
-  scanner->token.size = size;
-}
-
-static int pni_scanner_quoted(pn_scanner_t *scanner, const char *str, int start,
-                      pn_token_type_t type)
-{
-  bool escape = false;
-
-  for (int i = start; true; i++) {
-    char c = str[i];
-    if (escape) {
-      escape = false;
-    } else {
-      switch (c) {
-      case '\0':
-      case '"':
-        pni_scanner_emit(scanner, c ? type : PN_TOK_ERR,
-                        str, c ? i + 1 : i);
-        return c ? 0 : pn_scanner_err(scanner, PN_ERR, "missmatched quote");
-      case '\\':
-        escape = true;
-        break;
-      }
-    }
-  }
-}
-
-static int pni_scanner_binary(pn_scanner_t *scanner, const char *str)
-{
-  return pni_scanner_quoted(scanner, str, 2, PN_TOK_BINARY);
-}
-
-static int pni_scanner_string(pn_scanner_t *scanner, const char *str)
-{
-  return pni_scanner_quoted(scanner, str, 1, PN_TOK_STRING);
-}
-
-static int pni_scanner_alpha_end(pn_scanner_t *scanner, const char *str, int start)
-{
-  for (int i = start; true; i++) {
-    char c = str[i];
-    if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) {
-      return i;
-    }
-  }
-}
-
-static int pni_scanner_alpha(pn_scanner_t *scanner, const char *str)
-{
-  int n = pni_scanner_alpha_end(scanner, str, 0);
-  pn_bytes_t b = pn_bytes(n, str);
-  pn_token_type_t type;
-  if (pn_bytes_equal(b, PN_BYTES_LITERAL(true))) {
-    type = PN_TOK_TRUE;
-  } else if (pn_bytes_equal(b, PN_BYTES_LITERAL(false))) {
-    type = PN_TOK_FALSE;
-  } else if (pn_bytes_equal(b, PN_BYTES_LITERAL(null))) {
-    type = PN_TOK_NULL;
-  } else {
-    type = PN_TOK_ID;
-  }
-
-  pni_scanner_emit(scanner, type, str, n);
-  return 0;
-}
-
-static int pni_scanner_symbol(pn_scanner_t *scanner, const char *str)
-{
-  char c = str[1];
-
-  if (c == '"') {
-    return pni_scanner_quoted(scanner, str, 2, PN_TOK_SYMBOL);
-  } else {
-    int n = pni_scanner_alpha_end(scanner, str, 1);
-    pni_scanner_emit(scanner, PN_TOK_SYMBOL, str, n);
-    return 0;
-  }
-}
-
-static int pni_scanner_number(pn_scanner_t *scanner, const char *str)
-{
-  bool dot = false;
-  bool exp = false;
-
-  int i = 0;
-
-  if (str[i] == '+' || str[i] == '-') {
-    i++;
-  }
-
-  for ( ; true; i++) {
-    char c = str[i];
-    switch (c) {
-    case '0': case '1': case '2': case '3': case '4': case '5': case '6':
-    case '7': case '8': case '9':
-      continue;
-    case '.':
-      if (dot) {
-        pni_scanner_emit(scanner, PN_TOK_FLOAT, str, i);
-        return 0;
-      } else {
-        dot = true;
-      }
-      continue;
-    case 'e':
-    case 'E':
-      if (exp) {
-        pni_scanner_emit(scanner, PN_TOK_FLOAT, str, i);
-        return 0;
-      } else {
-        dot = true;
-        exp = true;
-        if (str[i+1] == '+' || str[i+1] == '-') {
-          i++;
-        }
-        continue;
-      }
-    default:
-      if (dot || exp) {
-        pni_scanner_emit(scanner, PN_TOK_FLOAT, str, i);
-        return 0;
-      } else {
-        pni_scanner_emit(scanner, PN_TOK_INT, str, i);
-        return 0;
-      }
-    }
-  }
-}
-
-static int pni_scanner_single(pn_scanner_t *scanner, const char *str, pn_token_type_t type)
-{
-  pni_scanner_emit(scanner, type, str, 1);
-  return 0;
-}
-
-int pn_scanner_start(pn_scanner_t *scanner, const char *input)
-{
-  if (!scanner || !input) return PN_ARG_ERR;
-  scanner->input = input;
-  scanner->position = input;
-  return pn_scanner_scan(scanner);
-}
-
-int pn_scanner_scan(pn_scanner_t *scanner)
-{
-  const char *str = scanner->position;
-  char n;
-
-  for (char c; true; str++) {
-    c = *str;
-    switch (c)
-    {
-    case '{':
-      return pni_scanner_single(scanner, str, PN_TOK_LBRACE);
-    case '}':
-      return pni_scanner_single(scanner, str, PN_TOK_RBRACE);
-    case'[':
-      return pni_scanner_single(scanner, str, PN_TOK_LBRACKET);
-    case ']':
-      return pni_scanner_single(scanner, str, PN_TOK_RBRACKET);
-    case '=':
-      return pni_scanner_single(scanner, str, PN_TOK_EQUAL);
-    case ',':
-      return pni_scanner_single(scanner, str, PN_TOK_COMMA);
-    case '.':
-      n = *(str+1);
-      if ((n >= '0' && n <= '9')) {
-        return pni_scanner_number(scanner, str);
-      } else {
-        return pni_scanner_single(scanner, str, PN_TOK_DOT);
-      }
-    case '@':
-      return pni_scanner_single(scanner, str, PN_TOK_AT);
-    case '$':
-      return pni_scanner_single(scanner, str, PN_TOK_DOLLAR);
-    case '-':
-      n = *(str+1);
-      if ((n >= '0' && n <= '9') || n == '.') {
-        return pni_scanner_number(scanner, str);
-      } else {
-        return pni_scanner_single(scanner, str, PN_TOK_NEG);
-      }
-    case '+':
-      n = *(str+1);
-      if ((n >= '0' && n <= '9') || n == '.') {
-        return pni_scanner_number(scanner, str);
-      } else {
-        return pni_scanner_single(scanner, str, PN_TOK_POS);
-      }
-    case ' ': case '\t': case '\r': case '\v': case '\f': case '\n':
-      break;
-    case '0': case '1': case '2': case '3': case '4': case '5': case '6':
-    case '7': case '8': case '9':
-      return pni_scanner_number(scanner, str);
-    case ':':
-      return pni_scanner_symbol(scanner, str);
-    case '"':
-      return pni_scanner_string(scanner, str);
-    case 'b':
-      if (str[1] == '"') {
-        return pni_scanner_binary(scanner, str);
-      }
-    case 'a': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
-    case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o':
-    case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v':
-    case 'w': case 'x': case 'y': case 'z': case 'A': case 'B': case 'C':
-    case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J':
-    case 'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q':
-    case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
-    case 'Y': case 'Z':
-      return pni_scanner_alpha(scanner, str);
-    case '\0':
-      pni_scanner_emit(scanner, PN_TOK_EOS, str, 0);
-      return PN_EOS;
-    default:
-      pni_scanner_emit(scanner, PN_TOK_ERR, str, 1);
-      return pn_scanner_err(scanner, PN_ERR, "illegal character");
-    }
-  }
-}
-
-int pn_scanner_shift(pn_scanner_t *scanner)
-{
-  scanner->position = scanner->token.start + scanner->token.size;
-  int err = pn_scanner_scan(scanner);
-  if (err == PN_EOS) {
-    return 0;
-  } else {
-    return err;
-  }
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ea02b933/proton-c/src/extra/scanner.h
----------------------------------------------------------------------
diff --git a/proton-c/src/extra/scanner.h b/proton-c/src/extra/scanner.h
deleted file mode 100644
index 218babe..0000000
--- a/proton-c/src/extra/scanner.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef PROTON_SCANNER_H
-#define PROTON_SCANNER_H 1
-
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-
-#include <proton/import_export.h>
-#include <stddef.h>
-#include <stdarg.h>
-
-typedef enum {
-  PN_TOK_LBRACE,
-  PN_TOK_RBRACE,
-  PN_TOK_LBRACKET,
-  PN_TOK_RBRACKET,
-  PN_TOK_EQUAL,
-  PN_TOK_COMMA,
-  PN_TOK_POS,
-  PN_TOK_NEG,
-  PN_TOK_DOT,
-  PN_TOK_AT,
-  PN_TOK_DOLLAR,
-  PN_TOK_BINARY,
-  PN_TOK_STRING,
-  PN_TOK_SYMBOL,
-  PN_TOK_ID,
-  PN_TOK_FLOAT,
-  PN_TOK_INT,
-  PN_TOK_TRUE,
-  PN_TOK_FALSE,
-  PN_TOK_NULL,
-  PN_TOK_EOS,
-  PN_TOK_ERR
-} pn_token_type_t;
-
-typedef struct pn_scanner_t pn_scanner_t;
-
-typedef struct {
-  pn_token_type_t type;
-  const char *start;
-  size_t size;
-} pn_token_t;
-
-PN_EXTERN pn_scanner_t *pn_scanner(void);
-PN_EXTERN void pn_scanner_free(pn_scanner_t *scanner);
-PN_EXTERN pn_token_t pn_scanner_token(pn_scanner_t *scanner);
-PN_EXTERN int pn_scanner_err(pn_scanner_t *scanner, int code, const char *fmt, ...);
-PN_EXTERN int pn_scanner_verr(pn_scanner_t *scanner, int code, const char *fmt, va_list ap);
-PN_EXTERN void pn_scanner_line_info(pn_scanner_t *scanner, int *line, int *col);
-PN_EXTERN int pn_scanner_errno(pn_scanner_t *scanner);
-PN_EXTERN const char *pn_scanner_error(pn_scanner_t *scanner);
-PN_EXTERN int pn_scanner_start(pn_scanner_t *scanner, const char *input);
-PN_EXTERN int pn_scanner_scan(pn_scanner_t *scanner);
-PN_EXTERN int pn_scanner_shift(pn_scanner_t *scanner);
-
-#endif /* scanner.h */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org