From 818c2339c1639eb035b0504f13f4d31f8da678dd Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 4 Jan 2012 09:07:33 +0100 Subject: [PATCH] cleanup --- JsonParserX/InputParser.cpp | 777 +++++++++ JsonParserX/InputParser.h | 363 ++++ JsonParserX/JsonParserX.cpp | 1186 ------------- JsonParserX/JsonParserX.h | 363 ---- JsonParserX/JsonParserX.yy | 45 +- JsonParserX/JsonParserXDriver.cpp | 22 +- JsonParserX/JsonScannerX.cpp | 2704 ----------------------------- JsonParserX/location.hh | 161 -- JsonParserX/position.hh | 157 -- JsonParserX/stack.hh | 133 -- 10 files changed, 1174 insertions(+), 4737 deletions(-) create mode 100644 JsonParserX/InputParser.cpp create mode 100644 JsonParserX/InputParser.h delete mode 100644 JsonParserX/JsonParserX.cpp delete mode 100644 JsonParserX/JsonParserX.h delete mode 100644 JsonParserX/JsonScannerX.cpp delete mode 100644 JsonParserX/location.hh delete mode 100644 JsonParserX/position.hh delete mode 100644 JsonParserX/stack.hh diff --git a/JsonParserX/InputParser.cpp b/JsonParserX/InputParser.cpp new file mode 100644 index 0000000000..d89f82a4ac --- /dev/null +++ b/JsonParserX/InputParser.cpp @@ -0,0 +1,777 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief input parsers +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2011 triagens GmbH, Cologne, Germany +/// +/// Licensed 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. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Dr. Frank Celler +/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#include "InputParser.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "JsonParserX/JsonParserXDriver.h" + +using namespace std; +using namespace triagens::basics; +using namespace triagens::rest; + +// ----------------------------------------------------------------------------- +// helper functions +// ----------------------------------------------------------------------------- + +namespace triagens { + namespace rest { + enum ObjectDescriptionType { + OD_BOOLEAN, + OD_DOUBLE, + OD_INTEGER, + OD_STRING, + OD_STRING_LIST, + OD_VARIANT_ARRAY, + OD_VARIANT_BOOLEAN, + OD_VARIANT_DOUBLE, + OD_VARIANT_INTEGER, + OD_VARIANT_NULL, + OD_VARIANT_STRING, + OD_VARIANT_STRING_LIST, + OD_VARIANT_VECTOR + }; + + + + struct AttributeDescription { + AttributeDescription () { + } + + AttributeDescription (ObjectDescriptionType type, void* store, bool* hasAttribute) + : type(type), store(store), hasAttribute(hasAttribute) { + } + + ObjectDescriptionType type; + void* store; + bool* hasAttribute; + }; + } +} + + + +namespace { + void clearObject (ObjectDescriptionType type, void* store) { + switch (type) { + case OD_BOOLEAN: + *reinterpret_cast(store) = false; + break; + + case OD_DOUBLE: + *reinterpret_cast(store) = false; + break; + + case OD_INTEGER: + *reinterpret_cast(store) = 0; + break; + + case OD_STRING: + *reinterpret_cast(store) = ""; + break; + + case OD_VARIANT_ARRAY: + case OD_VARIANT_BOOLEAN: + case OD_VARIANT_DOUBLE: + case OD_VARIANT_INTEGER: + case OD_VARIANT_NULL: + case OD_VARIANT_STRING: + case OD_VARIANT_VECTOR: + *reinterpret_cast(store) = 0; + break; + + case OD_STRING_LIST: + case OD_VARIANT_STRING_LIST: + break; + } + } + + + + bool checkObjectType (string const& name, ObjectDescriptionType type, VariantObject* object, string& errorMessage) { + char const* expecting; + VariantObject::ObjectType otype; + + switch (type) { + case OD_VARIANT_ARRAY: + expecting = "ARRAY"; + otype = VariantObject::VARIANT_ARRAY; + break; + + case OD_BOOLEAN: + case OD_VARIANT_BOOLEAN: + expecting = "BOOLEAN"; + otype = VariantObject::VARIANT_BOOLEAN; + break; + + case OD_DOUBLE: + case OD_VARIANT_DOUBLE: + expecting = "DOUBLE"; + otype = VariantObject::VARIANT_DOUBLE; + break; + + case OD_INTEGER: + case OD_VARIANT_INTEGER: + expecting = "INTEGER"; + otype = VariantObject::VARIANT_INT64; + break; + + case OD_VARIANT_NULL: + expecting = "NULL"; + otype = VariantObject::VARIANT_NULL; + break; + + case OD_STRING: + case OD_VARIANT_STRING: + expecting = "STRING"; + otype = VariantObject::VARIANT_STRING; + break; + + case OD_STRING_LIST: + case OD_VARIANT_STRING_LIST: + expecting = "VECTOR OF STRINGS"; + otype = VariantObject::VARIANT_VECTOR; + break; + + case OD_VARIANT_VECTOR: + expecting = "VECTOR"; + otype = VariantObject::VARIANT_VECTOR; + break; + + default: + THROW_INTERNAL_ERROR("wrong type"); + } + + if (otype != object->type()) { + errorMessage = "attribute '" + + name + + "' is of wrong type (expecting " + + expecting + + ", got " + + VariantObject::NameObjectType(object->type()) + + ")"; + + return false; + } + else { + return true; + } + } + + + + template + bool extractObjects (string const& name, + VariantVector* list, + ObjectDescriptionType type, + vector< VT* >* store, + string& errorMessage) { + vector const& values = list->getValues(); + + for (vector::const_iterator i = values.begin(); i != values.end(); ++i) { + VariantObject* object = *i; + + bool ok = checkObjectType(name, type, object, errorMessage); + + if (! ok) { + return false; + } + + VT* vt = object->as(); + + store->push_back(vt); + } + + return true; + } + + + + template + bool extractObjects (string const& name, + VariantVector* list, + ObjectDescriptionType type, + vector< T >* store, + string& errorMessage) { + vector const& values = list->getValues(); + + for (vector::const_iterator i = values.begin(); i != values.end(); ++i) { + VariantObject* object = *i; + + bool ok = checkObjectType(name, type, object, errorMessage); + + if (! ok) { + return false; + } + + VT* vt = object->as(); + + store->push_back(vt->getValue()); + } + + return true; + } + + + + bool extractObject (string const& name, + VariantObject* object, + AttributeDescription const& desc, + string& errorMessage) { + + switch (desc.type) { + case OD_VARIANT_ARRAY: + *reinterpret_cast(desc.store) = object->as(); + return true; + + case OD_BOOLEAN: + *reinterpret_cast(desc.store) = object->as()->getValue(); + return true; + + case OD_VARIANT_BOOLEAN: + *reinterpret_cast(desc.store) = object->as(); + return true; + + case OD_DOUBLE: + *reinterpret_cast(desc.store) = object->as()->getValue(); + return true; + + case OD_VARIANT_DOUBLE: + *reinterpret_cast(desc.store) = object->as(); + return true; + + case OD_INTEGER: + *reinterpret_cast(desc.store) = object->as()->getValue(); + return true; + + case OD_VARIANT_INTEGER: + *reinterpret_cast(desc.store) = object->as(); + return true; + + case OD_VARIANT_NULL: + *reinterpret_cast(desc.store) = object->as(); + return true; + + case OD_STRING: + *reinterpret_cast(desc.store) = object->as()->getValue(); + return true; + + case OD_VARIANT_STRING: + *reinterpret_cast(desc.store) = object->as(); + return true; + + case OD_STRING_LIST: + return extractObjects(name, + object->as(), + OD_VARIANT_STRING, + reinterpret_cast< vector* >(desc.store), + errorMessage); + + case OD_VARIANT_STRING_LIST: + return extractObjects(name, + object->as(), + OD_VARIANT_STRING, + reinterpret_cast< vector* >(desc.store), + errorMessage); + + case OD_VARIANT_VECTOR: + *reinterpret_cast(desc.store) = object->as(); + return true; + + default: + THROW_INTERNAL_ERROR("wrong type"); + } + } + + + + bool loadObject (VariantArray* array, string const& name, AttributeDescription const& desc, bool optional, string& errorMessage) { + clearObject(desc.type, desc.store); + + if (desc.hasAttribute != 0) { + *desc.hasAttribute = false; + } + + VariantObject* object = array->lookup(name); + + if (object == 0) { + if (optional) { + return true; + } + else { + errorMessage = "attribute '" + name + "' not found"; + + return false; + } + } + + if (object->is() && optional) { + return true; + } + + if (desc.hasAttribute != 0) { + *desc.hasAttribute = true; + } + + bool ok = checkObjectType(name, desc.type, object, errorMessage); + + if (! ok) { + return false; + } + + return extractObject(name, object, desc, errorMessage); + } + + + + bool loadAlternatives (VariantArray* array, + string const& name, + vector const& alternatives, + string& errorMessage) { + for (vector::const_iterator i = alternatives.begin(); i != alternatives.end(); ++i) { + clearObject(i->type, i->store); + } + + VariantObject* object = array->lookup(name); + + if (object == 0) { + return true; + } + + for (vector::const_iterator i = alternatives.begin(); i != alternatives.end(); ++i) { + AttributeDescription const& desc = *i; + + if (checkObjectType(name, desc.type, object, errorMessage)) { + return extractObject(name, object, desc, errorMessage); + } + } + + errorMessage = "attribute '" + name + "' is of wrong type"; + + return false; + } +} + +namespace triagens { + namespace rest { + namespace InputParser { + + // ----------------------------------------------------------------------------- + // object description implementation + // ----------------------------------------------------------------------------- + + struct ObjectDescriptionImpl { + map< string, AttributeDescription > attributes; + map< string, AttributeDescription > optionals; + map< string, vector > alternatives; + + string lastError; + }; + + // ----------------------------------------------------------------------------- + // object description + // ----------------------------------------------------------------------------- + + ObjectDescription::ObjectDescription () { + impl = new ObjectDescriptionImpl(); + } + + + + ObjectDescription::~ObjectDescription () { + delete impl; + } + + + + string const& ObjectDescription::lastError () { + return impl->lastError; + } + + + + bool ObjectDescription::parse (VariantObject* object) { + impl->lastError.clear(); + + // object must be a json array + if (object == 0) { + impl->lastError = "cannot parse object"; + + return false; + } + + if (! object->is()) { + impl->lastError = "not an object"; + + return false; + } + + VariantArray* array = object->as(); + + // now find the attributes, optionals, and alternatives + for (map::iterator i = impl->attributes.begin(); i != impl->attributes.end(); ++i) { + string const& name = i->first; + AttributeDescription& desc = i->second; + + bool ok = loadObject(array, name, desc, false, impl->lastError); + + if (! ok) { + return false; + } + } + + for (map::iterator i = impl->optionals.begin(); i != impl->optionals.end(); ++i) { + string const& name = i->first; + AttributeDescription& desc = i->second; + + bool ok = loadObject(array, name, desc, true, impl->lastError); + + if (! ok) { + return false; + } + } + + for (map< string, vector >::iterator i = impl->alternatives.begin(); i != impl->alternatives.end(); ++i) { + string const& name = i->first; + + bool ok = loadAlternatives(array, name, i->second, impl->lastError); + + if (! ok) { + return false; + } + } + + transform(); + + return true; + } + + + + void ObjectDescription::transform () { + } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // attribute + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantArray*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_ARRAY, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantBoolean*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_BOOLEAN, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, bool& store) { + impl->attributes[name] = AttributeDescription(OD_BOOLEAN, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantDouble*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_DOUBLE, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, double& store) { + impl->attributes[name] = AttributeDescription(OD_DOUBLE, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantInt64*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_INTEGER, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, int64_t& store) { + impl->attributes[name] = AttributeDescription(OD_INTEGER, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantNull*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_NULL, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantString*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_STRING, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, string& store) { + impl->attributes[name] = AttributeDescription(OD_STRING, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, vector& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_STRING_LIST, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, vector& store) { + impl->attributes[name] = AttributeDescription(OD_STRING_LIST, reinterpret_cast(&store), 0); + return *this; + } + + + + ObjectDescription& ObjectDescription::attribute (string const& name, VariantVector*& store) { + impl->attributes[name] = AttributeDescription(OD_VARIANT_VECTOR, reinterpret_cast(&store), 0); + return *this; + } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // optional + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantArray*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_ARRAY, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantBoolean*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_BOOLEAN, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, bool& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_BOOLEAN, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantDouble*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_DOUBLE, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, double& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_DOUBLE, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantInt64*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_INTEGER, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, int64_t& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_INTEGER, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantNull*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_NULL, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantString*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_STRING, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, string& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_STRING, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, vector& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_STRING_LIST, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, vector& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_STRING_LIST, reinterpret_cast(&store), hasAttribute); + return *this; + } + + + + ObjectDescription& ObjectDescription::optional (string const& name, VariantVector*& store, bool* hasAttribute) { + impl->optionals[name] = AttributeDescription(OD_VARIANT_VECTOR, reinterpret_cast(&store), hasAttribute); + return *this; + } + + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // alternative + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + ObjectDescription& ObjectDescription::alternative (string const& name, VariantArray*& store) { + impl->alternatives[name].push_back(AttributeDescription(OD_VARIANT_ARRAY, reinterpret_cast(&store), 0)); + return *this; + } + + + + ObjectDescription& ObjectDescription::alternative (string const& name, VariantBoolean*& store) { + impl->alternatives[name].push_back(AttributeDescription(OD_VARIANT_BOOLEAN, reinterpret_cast(&store), 0)); + return *this; + } + + + + ObjectDescription& ObjectDescription::alternative (string const& name, VariantInt64*& store) { + impl->alternatives[name].push_back(AttributeDescription(OD_VARIANT_INTEGER, reinterpret_cast(&store), 0)); + return *this; + } + + + + ObjectDescription& ObjectDescription::alternative (string const& name, VariantNull*& store) { + impl->alternatives[name].push_back(AttributeDescription(OD_VARIANT_NULL, reinterpret_cast(&store), 0)); + return *this; + } + + + + ObjectDescription& ObjectDescription::alternative (string const& name, VariantString*& store) { + impl->alternatives[name].push_back(AttributeDescription(OD_VARIANT_STRING, reinterpret_cast(&store), 0)); + return *this; + } + + + + ObjectDescription& ObjectDescription::alternative (string const& name, VariantVector*& store) { + impl->alternatives[name].push_back(AttributeDescription(OD_VARIANT_VECTOR, reinterpret_cast(&store), 0)); + return *this; + } + + // ----------------------------------------------------------------------------- + // public fucntions + // ----------------------------------------------------------------------------- + + VariantObject* json (string const& input) { + JsonParserXDriver parser; + + return parser.parse(input); + } + + + + VariantObject* json (HttpRequest* request) { + JsonParserXDriver parser; + + return parser.parse(request->body()); + } + + + + VariantArray* jsonArray (string const& input) { + JsonParserXDriver parser; + + VariantObject* object = parser.parse(input); + + if (object == 0) { + return 0; + } + else if (object->type() == VariantObject::VARIANT_ARRAY) { + return dynamic_cast(object); + } + else { + delete object; + return 0; + } + } + + + + VariantArray* jsonArray (HttpRequest* request) { + JsonParserXDriver parser; + + VariantObject* object = parser.parse(request->body()); + + if (object == 0) { + return 0; + } + else if (object->type() == VariantObject::VARIANT_ARRAY) { + return dynamic_cast(object); + } + else { + delete object; + return 0; + } + } + } + } +} diff --git a/JsonParserX/InputParser.h b/JsonParserX/InputParser.h new file mode 100644 index 0000000000..d1ea94aa0a --- /dev/null +++ b/JsonParserX/InputParser.h @@ -0,0 +1,363 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief input parsers +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2011 triagens GmbH, Cologne, Germany +/// +/// Licensed 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. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Dr. Frank Celler +/// @author Copyright 2009-2011, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_FYN_REST_INPUT_PARSER_H +#define TRIAGENS_FYN_REST_INPUT_PARSER_H 1 + +#include + +namespace triagens { + namespace basics { + class VariantArray; + class VariantBoolean; + class VariantDouble; + class VariantInt64; + class VariantNull; + class VariantObject; + class VariantString; + class VariantVector; + } + + namespace rest { + class HttpRequest; + + namespace InputParser { + class ObjectDescriptionImpl; + + //////////////////////////////////////////////////////////////////////////////// + /// @ingroup Utilities + /// @brief object description + //////////////////////////////////////////////////////////////////////////////// + + class ObjectDescription { + private: + ObjectDescription (ObjectDescription const&); + ObjectDescription& operator= (ObjectDescription const&); + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief creates a new description + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription (); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief destroys a description + //////////////////////////////////////////////////////////////////////////////// + + virtual ~ObjectDescription (); + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief loads an object + //////////////////////////////////////////////////////////////////////////////// + + bool parse (basics::VariantObject*); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief returns the last error message + //////////////////////////////////////////////////////////////////////////////// + + string const& lastError (); + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief applys transformations after parsing + //////////////////////////////////////////////////////////////////////////////// + + virtual void transform (); + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an array attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantArray*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a boolean attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantBoolean*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a boolean attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, bool&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a double attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantDouble*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a double attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, double&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an integer attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantInt64*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an integer attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, int64_t&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an null attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantNull*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a string attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantString*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a string attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, string&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a string vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, vector&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a string vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, vector&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds a vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& attribute (string const& name, basics::VariantVector*&); + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional attribute field + //////////////////////////////////////////////////////////////////////////////// + + template + ObjectDescription& optional (string const& name, T& t, bool& hasAttribute) { + return optional(name, t, &hasAttribute); + } + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional attribute field + //////////////////////////////////////////////////////////////////////////////// + + template + ObjectDescription& optional (string const& name, T& t) { + return optional(name, t, 0); + } + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional array attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantArray*&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional boolean attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantBoolean*&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional boolean attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, bool&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional double attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantDouble*&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional double attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, double&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional integer attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantInt64*&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional integer attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, int64_t&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional null attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantNull*&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional string attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantString*&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional string attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, string&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional string vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, vector&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional string vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, vector&, bool* hasAttribute); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an optional vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& optional (string const& name, basics::VariantVector*&, bool* hasAttribute); + + public: + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative array attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantArray*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative boolean attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantBoolean*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative double attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantDouble*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative integer attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantInt64*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative null attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantNull*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative string attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantString*&); + + //////////////////////////////////////////////////////////////////////////////// + /// @brief adds an alternative vector attribute field + //////////////////////////////////////////////////////////////////////////////// + + ObjectDescription& alternative (string const& name, basics::VariantVector*&); + + private: + ObjectDescriptionImpl* impl; + }; + + //////////////////////////////////////////////////////////////////////////////// + /// @ingroup Utilities + /// @brief a json parser + //////////////////////////////////////////////////////////////////////////////// + + basics::VariantObject* json (string const& input); + + //////////////////////////////////////////////////////////////////////////////// + /// @ingroup Utilities + /// @brief a json parser + //////////////////////////////////////////////////////////////////////////////// + + basics::VariantObject* json (HttpRequest*); + + //////////////////////////////////////////////////////////////////////////////// + /// @ingroup Utilities + /// @brief a json parser for an array + //////////////////////////////////////////////////////////////////////////////// + + basics::VariantArray* jsonArray (string const& input); + + //////////////////////////////////////////////////////////////////////////////// + /// @ingroup Utilities + /// @brief a json parser for an array + //////////////////////////////////////////////////////////////////////////////// + + basics::VariantArray* jsonArray (HttpRequest*); + + //////////////////////////////////////////////////////////////////////////////// + /// @ingroup Utilities + /// @brief a json-to-object parser + //////////////////////////////////////////////////////////////////////////////// + + bool json2object (ObjectDescription&, string const& input); + } + } +} + +#endif diff --git a/JsonParserX/JsonParserX.cpp b/JsonParserX/JsonParserX.cpp deleted file mode 100644 index e726e41578..0000000000 --- a/JsonParserX/JsonParserX.cpp +++ /dev/null @@ -1,1186 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Skeleton implementation for Bison LALR(1) parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software - Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - - -/* First part of user declarations. */ - - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace triagens::basics; - -#define YYSCANNER driver.scanner -#define YYENABLE_NLS 0 // warning should be suppressed in newer releases of bison - - - - -#include "JsonParserX.h" - -/* User implementation prologue. */ - - -YY_DECL; - - - -#ifndef YY_ -# if defined(YYENABLE_NLS) && YYENABLE_NLS -# if ENABLE_NLS -# include /* FIXME: INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#define YYUSE(e) ((void) (e)) - -/* Enable debugging if requested. */ -#if YYDEBUG - -/* A pseudo ostream that takes yydebug_ into account. */ -# define YYCDEBUG if (yydebug_) (*yycdebug_) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug_) \ - { \ - *yycdebug_ << Title << ' '; \ - yy_symbol_print_ ((Type), (Value), (Location)); \ - *yycdebug_ << std::endl; \ - } \ -} while (false) - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug_) \ - yy_reduce_print_ (Rule); \ -} while (false) - -# define YY_STACK_PRINT() \ -do { \ - if (yydebug_) \ - yystack_print_ (); \ -} while (false) - -#else /* !YYDEBUG */ - -# define YYCDEBUG if (false) std::cerr -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_REDUCE_PRINT(Rule) -# define YY_STACK_PRINT() - -#endif /* !YYDEBUG */ - -#define yyerrok (yyerrstatus_ = 0) -#define yyclearin (yychar = yyempty_) - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab -#define YYRECOVERING() (!!yyerrstatus_) - - -namespace triagens { namespace json_parser { - -#if YYERROR_VERBOSE - - /* Return YYSTR after stripping away unnecessary quotes and - backslashes, so that it's suitable for yyerror. The heuristic is - that double-quoting is unnecessary unless the string contains an - apostrophe, a comma, or backslash (other than backslash-backslash). - YYSTR is taken from yytname. */ - std::string - JsonParserX::yytnamerr_ (const char *yystr) - { - if (*yystr == '"') - { - std::string yyr = ""; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - yyr += *yyp; - break; - - case '"': - return yyr; - } - do_not_strip_quotes: ; - } - - return yystr; - } - -#endif - - /// Build a parser object. - JsonParserX::JsonParserX (triagens::rest::JsonParserXDriver& driver_yyarg) - : -#if YYDEBUG - yydebug_ (false), - yycdebug_ (&std::cerr), -#endif - driver (driver_yyarg) - { - } - - JsonParserX::~JsonParserX () - { - } - -#if YYDEBUG - /*--------------------------------. - | Print this symbol on YYOUTPUT. | - `--------------------------------*/ - - inline void - JsonParserX::yy_symbol_value_print_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) - { - YYUSE (yylocationp); - YYUSE (yyvaluep); - switch (yytype) - { - case 10: /* "\"string constant\"" */ - - { debug_stream() << *(yyvaluep->str); }; - - break; - default: - break; - } - } - - - void - JsonParserX::yy_symbol_print_ (int yytype, - const semantic_type* yyvaluep, const location_type* yylocationp) - { - *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") - << ' ' << yytname_[yytype] << " (" - << *yylocationp << ": "; - yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); - *yycdebug_ << ')'; - } -#endif - - void - JsonParserX::yydestruct_ (const char* yymsg, - int yytype, semantic_type* yyvaluep, location_type* yylocationp) - { - YYUSE (yylocationp); - YYUSE (yymsg); - YYUSE (yyvaluep); - - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - - default: - break; - } - } - - void - JsonParserX::yypop_ (unsigned int n) - { - yystate_stack_.pop (n); - yysemantic_stack_.pop (n); - yylocation_stack_.pop (n); - } - -#if YYDEBUG - std::ostream& - JsonParserX::debug_stream () const - { - return *yycdebug_; - } - - void - JsonParserX::set_debug_stream (std::ostream& o) - { - yycdebug_ = &o; - } - - - JsonParserX::debug_level_type - JsonParserX::debug_level () const - { - return yydebug_; - } - - void - JsonParserX::set_debug_level (debug_level_type l) - { - yydebug_ = l; - } -#endif - - int - JsonParserX::parse () - { - /// Lookahead and lookahead in internal form. - int yychar = yyempty_; - int yytoken = 0; - - /* State. */ - int yyn; - int yylen = 0; - int yystate = 0; - - /* Error handling. */ - int yynerrs_ = 0; - int yyerrstatus_ = 0; - - /// Semantic value of the lookahead. - semantic_type yylval; - /// Location of the lookahead. - location_type yylloc; - /// The locations where the error started and ended. - location_type yyerror_range[2]; - - /// $$. - semantic_type yyval; - /// @$. - location_type yyloc; - - int yyresult; - - YYCDEBUG << "Starting parse" << std::endl; - - - /* User initialization code. */ - -{ - // reset the location - yylloc.step(); -} - - - /* Initialize the stacks. The initial state will be pushed in - yynewstate, since the latter expects the semantical and the - location values to have been already stored, initialize these - stacks with a primary value. */ - yystate_stack_ = state_stack_type (0); - yysemantic_stack_ = semantic_stack_type (0); - yylocation_stack_ = location_stack_type (0); - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yylloc); - - /* New state. */ - yynewstate: - yystate_stack_.push (yystate); - YYCDEBUG << "Entering state " << yystate << std::endl; - - /* Accept? */ - if (yystate == yyfinal_) - goto yyacceptlab; - - goto yybackup; - - /* Backup. */ - yybackup: - - /* Try to take a decision without lookahead. */ - yyn = yypact_[yystate]; - if (yyn == yypact_ninf_) - goto yydefault; - - /* Read a lookahead token. */ - if (yychar == yyempty_) - { - YYCDEBUG << "Reading a token: "; - yychar = yylex (&yylval, &yylloc, YYSCANNER); - } - - - /* Convert token to internal form. */ - if (yychar <= yyeof_) - { - yychar = yytoken = yyeof_; - YYCDEBUG << "Now at end of input." << std::endl; - } - else - { - yytoken = yytranslate_ (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) - goto yydefault; - - /* Reduce or error. */ - yyn = yytable_[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == yytable_ninf_) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the token being shifted. */ - yychar = yyempty_; - - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yylloc); - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus_) - --yyerrstatus_; - - yystate = yyn; - goto yynewstate; - - /*-----------------------------------------------------------. - | yydefault -- do the default action for the current state. | - `-----------------------------------------------------------*/ - yydefault: - yyn = yydefact_[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - /*-----------------------------. - | yyreduce -- Do a reduction. | - `-----------------------------*/ - yyreduce: - yylen = yyr2_[yyn]; - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. Otherwise, use the top of the stack. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. */ - if (yylen) - yyval = yysemantic_stack_[yylen - 1]; - else - yyval = yysemantic_stack_[0]; - - { - slice slice (yylocation_stack_, yylen); - YYLLOC_DEFAULT (yyloc, slice, yylen); - } - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 2: - - { - driver.addVariantArray((yysemantic_stack_[(1) - (1)].variantArray)); - } - break; - - case 3: - - { - driver.addVariantDouble((yysemantic_stack_[(1) - (1)].double_type)); - } - break; - - case 4: - - { - driver.addVariantBoolean(false); - } - break; - - case 5: - - { - driver.addVariantNull(); - } - break; - - case 6: - - { - driver.addVariantInt32((yysemantic_stack_[(1) - (1)].int32_type)); - } - break; - - case 7: - - { - driver.addVariantInt64((yysemantic_stack_[(1) - (1)].int64_type)); - } - break; - - case 8: - - { - driver.addVariantString(*(yysemantic_stack_[(1) - (1)].str)); - delete (yysemantic_stack_[(1) - (1)].str); - } - break; - - case 9: - - { - driver.addVariantBoolean(true); - } - break; - - case 10: - - { - driver.addVariantUInt32((yysemantic_stack_[(1) - (1)].uint32_type)); - } - break; - - case 11: - - { - driver.addVariantUInt64((yysemantic_stack_[(1) - (1)].uint64_type)); - } - break; - - case 12: - - { - driver.addVariantVector((yysemantic_stack_[(1) - (1)].variantVector)); - } - break; - - case 13: - - { - (yyval.variantArray) = (yysemantic_stack_[(3) - (2)].keyValueList); - } - break; - - case 14: - - { - (yyval.variantArray) = new VariantArray(); - } - break; - - case 15: - - { - (yyval.variantVector) = (yysemantic_stack_[(3) - (2)].valueList); - } - break; - - case 16: - - { - (yyval.variantVector) = new VariantVector(); - } - break; - - case 17: - - { - (yyval.keyValueList) = new VariantArray(); - (yyval.keyValueList)->add(*(yysemantic_stack_[(3) - (1)].str),(yysemantic_stack_[(3) - (3)].variantObject)); - delete (yysemantic_stack_[(3) - (1)].str); - } - break; - - case 18: - - { - // nothing to add - } - break; - - case 19: - - { - (yyval.keyValueList)->add(*(yysemantic_stack_[(5) - (3)].str),(yysemantic_stack_[(5) - (5)].variantObject)); - delete (yysemantic_stack_[(5) - (3)].str); - } - break; - - case 20: - - { - (yyval.valueList) = new VariantVector(); - (yyval.valueList)->add((yysemantic_stack_[(1) - (1)].variantObject)); - } - break; - - case 21: - - { - // nothing to add - } - break; - - case 22: - - { - (yysemantic_stack_[(3) - (1)].valueList)->add((yysemantic_stack_[(3) - (3)].variantObject)); - } - break; - - case 23: - - { - (yyval.variantObject) = new VariantDouble((yysemantic_stack_[(1) - (1)].double_type)); - } - break; - - case 24: - - { - (yyval.variantObject) = new VariantDouble(StringUtils::doubleDecimal(*(yysemantic_stack_[(1) - (1)].str))); - } - break; - - case 25: - - { - (yyval.variantObject) = new VariantInt32((yysemantic_stack_[(1) - (1)].int32_type)); - } - break; - - case 26: - - { - (yyval.variantObject) = new VariantInt32(StringUtils::int32(*(yysemantic_stack_[(1) - (1)].str))); - } - break; - - case 27: - - { - (yyval.variantObject) = new VariantInt64((yysemantic_stack_[(1) - (1)].int64_type)); - } - break; - - case 28: - - { - (yyval.variantObject) = new VariantInt64(StringUtils::int64(*(yysemantic_stack_[(1) - (1)].str))); - } - break; - - case 29: - - { - (yyval.variantObject) = new VariantString(*(yysemantic_stack_[(1) - (1)].str)); - delete (yysemantic_stack_[(1) - (1)].str); - } - break; - - case 30: - - { - (yyval.variantObject) = new VariantBoolean(false); - } - break; - - case 31: - - { - (yyval.variantObject) = new VariantBoolean(true); - } - break; - - case 32: - - { - (yyval.variantObject) = new VariantNull(); - } - break; - - case 33: - - { - (yyval.variantObject) = new VariantUInt32((yysemantic_stack_[(1) - (1)].uint32_type)); - } - break; - - case 34: - - { - (yyval.variantObject) = new VariantUInt32(StringUtils::uint32(*(yysemantic_stack_[(1) - (1)].str))); - } - break; - - case 35: - - { - (yyval.variantObject) = new VariantUInt64((yysemantic_stack_[(1) - (1)].uint64_type)); - } - break; - - case 36: - - { - (yyval.variantObject) = new VariantUInt64(StringUtils::uint64(*(yysemantic_stack_[(1) - (1)].str))); - } - break; - - case 37: - - { - (yyval.variantObject) = (yysemantic_stack_[(1) - (1)].variantArray); - } - break; - - case 38: - - { - (yyval.variantObject) = (yysemantic_stack_[(1) - (1)].variantVector); - } - break; - - - - default: - break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); - - yypop_ (yylen); - yylen = 0; - YY_STACK_PRINT (); - - yysemantic_stack_.push (yyval); - yylocation_stack_.push (yyloc); - - /* Shift the result of the reduction. */ - yyn = yyr1_[yyn]; - yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; - if (0 <= yystate && yystate <= yylast_ - && yycheck_[yystate] == yystate_stack_[0]) - yystate = yytable_[yystate]; - else - yystate = yydefgoto_[yyn - yyntokens_]; - goto yynewstate; - - /*------------------------------------. - | yyerrlab -- here on detecting error | - `------------------------------------*/ - yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus_) - { - ++yynerrs_; - error (yylloc, yysyntax_error_ (yystate, yytoken)); - } - - yyerror_range[0] = yylloc; - if (yyerrstatus_ == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= yyeof_) - { - /* Return failure if at end of input. */ - if (yychar == yyeof_) - YYABORT; - } - else - { - yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); - yychar = yyempty_; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - - /*---------------------------------------------------. - | yyerrorlab -- error raised explicitly by YYERROR. | - `---------------------------------------------------*/ - yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (false) - goto yyerrorlab; - - yyerror_range[0] = yylocation_stack_[yylen - 1]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - yypop_ (yylen); - yylen = 0; - yystate = yystate_stack_[0]; - goto yyerrlab1; - - /*-------------------------------------------------------------. - | yyerrlab1 -- common code for both syntax error and YYERROR. | - `-------------------------------------------------------------*/ - yyerrlab1: - yyerrstatus_ = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact_[yystate]; - if (yyn != yypact_ninf_) - { - yyn += yyterror_; - if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) - { - yyn = yytable_[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yystate_stack_.height () == 1) - YYABORT; - - yyerror_range[0] = yylocation_stack_[0]; - yydestruct_ ("Error: popping", - yystos_[yystate], - &yysemantic_stack_[0], &yylocation_stack_[0]); - yypop_ (); - yystate = yystate_stack_[0]; - YY_STACK_PRINT (); - } - - yyerror_range[1] = yylloc; - // Using YYLLOC is tempting, but would change the location of - // the lookahead. YYLOC is available though. - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); - yysemantic_stack_.push (yylval); - yylocation_stack_.push (yyloc); - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], - &yysemantic_stack_[0], &yylocation_stack_[0]); - - yystate = yyn; - goto yynewstate; - - /* Accept. */ - yyacceptlab: - yyresult = 0; - goto yyreturn; - - /* Abort. */ - yyabortlab: - yyresult = 1; - goto yyreturn; - - yyreturn: - if (yychar != yyempty_) - yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); - - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - yypop_ (yylen); - while (yystate_stack_.height () != 1) - { - yydestruct_ ("Cleanup: popping", - yystos_[yystate_stack_[0]], - &yysemantic_stack_[0], - &yylocation_stack_[0]); - yypop_ (); - } - - return yyresult; - } - - // Generate an error message. - std::string - JsonParserX::yysyntax_error_ (int yystate, int tok) - { - std::string res; - YYUSE (yystate); -#if YYERROR_VERBOSE - int yyn = yypact_[yystate]; - if (yypact_ninf_ < yyn && yyn <= yylast_) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = yylast_ - yyn + 1; - int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; - int count = 0; - for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn] == x && x != yyterror_) - ++count; - - // FIXME: This method of building the message is not compatible - // with internationalization. It should work like yacc.c does it. - // That is, first build a string that looks like this: - // "syntax error, unexpected %s or %s or %s" - // Then, invoke YY_ on this string. - // Finally, use the string as a format to output - // yytname_[tok], etc. - // Until this gets fixed, this message appears in English only. - res = "syntax error, unexpected "; - res += yytnamerr_ (yytname_[tok]); - if (count < 5) - { - count = 0; - for (int x = yyxbegin; x < yyxend; ++x) - if (yycheck_[x + yyn] == x && x != yyterror_) - { - res += (!count++) ? ", expecting " : " or "; - res += yytnamerr_ (yytname_[x]); - } - } - } - else -#endif - res = YY_("syntax error"); - return res; - } - - - /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ - const signed char JsonParserX::yypact_ninf_ = -27; - const signed char - JsonParserX::yypact_[] = - { - 44, -27, -27, -27, -27, -27, -27, -27, -27, 7, - -3, -27, 2, -27, -27, -7, -27, 1, -27, -27, - -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27, -27, 5, -27, -27, 32, -27, - 4, -27, 32, -27, -1, -27, 32, -27 - }; - - /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ - const unsigned char - JsonParserX::yydefact_[] = - { - 0, 3, 6, 7, 8, 10, 11, 4, 5, 0, - 0, 9, 0, 2, 12, 0, 14, 0, 23, 24, - 25, 26, 27, 28, 29, 33, 34, 35, 36, 16, - 30, 32, 31, 37, 38, 0, 20, 1, 0, 13, - 18, 15, 21, 17, 0, 22, 0, 19 - }; - - /* YYPGOTO[NTERM-NUM]. */ - const signed char - JsonParserX::yypgoto_[] = - { - -27, -27, 25, 27, -27, -27, -26 - }; - - /* YYDEFGOTO[NTERM-NUM]. */ - const signed char - JsonParserX::yydefgoto_[] = - { - -1, 12, 33, 34, 17, 35, 36 - }; - - /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. */ - const signed char JsonParserX::yytable_ninf_ = -1; - const unsigned char - JsonParserX::yytable_[] = - { - 18, 19, 37, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 43, 38, 44, 29, 45, 15, 39, 46, - 47, 30, 40, 41, 16, 13, 42, 14, 31, 9, - 10, 0, 0, 0, 0, 18, 19, 32, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 1, 0, 0, - 2, 0, 3, 0, 4, 5, 30, 6, 0, 0, - 0, 0, 0, 31, 9, 10, 0, 0, 7, 0, - 0, 0, 32, 0, 0, 8, 9, 10, 0, 0, - 0, 0, 0, 0, 11 - }; - - /* YYCHECK. */ - const signed char - JsonParserX::yycheck_[] = - { - 3, 4, 0, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 38, 20, 10, 18, 42, 10, 17, 20, - 46, 24, 21, 18, 17, 0, 21, 0, 31, 32, - 33, -1, -1, -1, -1, 3, 4, 40, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 3, -1, -1, - 6, -1, 8, -1, 10, 11, 24, 13, -1, -1, - -1, -1, -1, 31, 32, 33, -1, -1, 24, -1, - -1, -1, 40, -1, -1, 31, 32, 33, -1, -1, - -1, -1, -1, -1, 40 - }; - - /* STOS_[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ - const unsigned char - JsonParserX::yystos_[] = - { - 0, 3, 6, 8, 10, 11, 13, 24, 31, 32, - 33, 40, 45, 46, 47, 10, 17, 48, 3, 4, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 18, - 24, 31, 40, 46, 47, 49, 50, 0, 20, 17, - 21, 18, 21, 50, 10, 50, 20, 50 - }; - -#if YYDEBUG - /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding - to YYLEX-NUM. */ - const unsigned short int - JsonParserX::yytoken_number_[] = - { - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, - 295, 296, 297, 298 - }; -#endif - - /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ - const unsigned char - JsonParserX::yyr1_[] = - { - 0, 44, 45, 45, 45, 45, 45, 45, 45, 45, - 45, 45, 45, 46, 46, 47, 47, 48, 48, 48, - 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50 - }; - - /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ - const unsigned char - JsonParserX::yyr2_[] = - { - 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 2, 3, 2, 3, 2, 5, - 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1 - }; - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE - /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at \a yyntokens_, nonterminals. */ - const char* - const JsonParserX::yytname_[] = - { - "\"end of file\"", "error", "$undefined", "\"decimal constant\"", - "\"decimal constant string\"", "\"identifier\"", - "\"signed integer constant\"", "\"signed integer constant string\"", - "\"signed long integer constant\"", - "\"signed long integer constant string\"", "\"string constant\"", - "\"unsigned integer constant\"", "\"unsigned integer constant string\"", - "\"unsigned long integer constant\"", - "\"unsigned long integer constant string\"", "\"&&\"", "\":=\"", "\"}\"", - "\"]\"", "\")\"", "\":\"", "\",\"", "\".\"", "\"==\"", "\"false\"", - "\">=\"", "\">\"", "\"<=\"", "\"<\"", "\"-\"", "\"<>\"", "\"null\"", - "\"{\"", "\"[\"", "\"(\"", "\"||\"", "\"+\"", "\"/\"", "\";\"", "\"*\"", - "\"true\"", "\"string_constant_null\"", "\"unquoted string\"", - "NEGATION", "$accept", "jsonDefinition", "variantArray", "variantVector", - "keyValueList", "valueList", "variantObject", 0 - }; -#endif - -#if YYDEBUG - /* YYRHS -- A `-1'-separated list of the rules' RHS. */ - const JsonParserX::rhs_number_type - JsonParserX::yyrhs_[] = - { - 45, 0, -1, 46, -1, 3, -1, 24, -1, 31, - -1, 6, -1, 8, -1, 10, -1, 40, -1, 11, - -1, 13, -1, 47, -1, 32, 48, 17, -1, 32, - 17, -1, 33, 49, 18, -1, 33, 18, -1, 10, - 20, 50, -1, 48, 21, -1, 48, 21, 10, 20, - 50, -1, 50, -1, 49, 21, -1, 49, 21, 50, - -1, 3, -1, 4, -1, 6, -1, 7, -1, 8, - -1, 9, -1, 10, -1, 24, -1, 40, -1, 31, - -1, 11, -1, 12, -1, 13, -1, 14, -1, 46, - -1, 47, -1 - }; - - /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ - const unsigned char - JsonParserX::yyprhs_[] = - { - 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, - 19, 21, 23, 25, 29, 32, 36, 39, 43, 46, - 52, 54, 57, 61, 63, 65, 67, 69, 71, 73, - 75, 77, 79, 81, 83, 85, 87, 89, 91 - }; - - /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ - const unsigned short int - JsonParserX::yyrline_[] = - { - 0, 161, 161, 165, 169, 173, 177, 181, 185, 190, - 194, 198, 202, 209, 213, 220, 224, 231, 237, 241, - 249, 254, 258, 265, 269, 273, 277, 281, 285, 289, - 294, 298, 302, 306, 310, 314, 318, 322, 326 - }; - - // Print the state stack on the debug stream. - void - JsonParserX::yystack_print_ () - { - *yycdebug_ << "Stack now"; - for (state_stack_type::const_iterator i = yystate_stack_.begin (); - i != yystate_stack_.end (); ++i) - *yycdebug_ << ' ' << *i; - *yycdebug_ << std::endl; - } - - // Report on the debug stream that the rule \a yyrule is going to be reduced. - void - JsonParserX::yy_reduce_print_ (int yyrule) - { - unsigned int yylno = yyrline_[yyrule]; - int yynrhs = yyr2_[yyrule]; - /* Print the symbols being reduced, and their result. */ - *yycdebug_ << "Reducing stack by rule " << yyrule - 1 - << " (line " << yylno << "):" << std::endl; - /* The symbols being reduced. */ - for (int yyi = 0; yyi < yynrhs; yyi++) - YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", - yyrhs_[yyprhs_[yyrule] + yyi], - &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), - &(yylocation_stack_[(yynrhs) - (yyi + 1)])); - } -#endif // YYDEBUG - - /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ - JsonParserX::token_number_type - JsonParserX::yytranslate_ (int t) - { - static - const token_number_type - translate_table[] = - { - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43 - }; - if ((unsigned int) t <= yyuser_token_number_max_) - return translate_table[t]; - else - return yyundef_token_; - } - - const int JsonParserX::yyeof_ = 0; - const int JsonParserX::yylast_ = 84; - const int JsonParserX::yynnts_ = 7; - const int JsonParserX::yyempty_ = -2; - const int JsonParserX::yyfinal_ = 37; - const int JsonParserX::yyterror_ = 1; - const int JsonParserX::yyerrcode_ = 256; - const int JsonParserX::yyntokens_ = 44; - - const unsigned int JsonParserX::yyuser_token_number_max_ = 298; - const JsonParserX::token_number_type JsonParserX::yyundef_token_ = 2; - - -} } // triagens::json_parser - - - - - -// ///////////////////////////////////////////////////////////////////////////// -// postamble -// ///////////////////////////////////////////////////////////////////////////// - -void triagens::json_parser::JsonParserX::error (const triagens::json_parser::JsonParserX::location_type& l, const string& m) { - triagens::json_parser::position last = l.end - 1; - driver.setError(last.line, last.column, m); -} - diff --git a/JsonParserX/JsonParserX.h b/JsonParserX/JsonParserX.h deleted file mode 100644 index 52642e99e7..0000000000 --- a/JsonParserX/JsonParserX.h +++ /dev/null @@ -1,363 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Skeleton interface for Bison LALR(1) parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software - Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C++ LALR(1) parser skeleton written by Akim Demaille. */ - -#ifndef PARSER_HEADER_H -# define PARSER_HEADER_H - -/* "%code requires" blocks. */ - - -#define NAME_SPACE triagens::json_parser -#define YY_DECL \ - NAME_SPACE::JsonParserX::token_type \ - yylex (NAME_SPACE::JsonParserX::semantic_type* yylval_param, \ - NAME_SPACE::JsonParserX::location_type* yylloc_param, \ - void* yyscanner) - - - - - -#include -#include -#include "stack.hh" - - -namespace triagens { namespace json_parser { - - class position; - class location; - -} } // triagens::json_parser - - -#include "location.hh" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 1 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ -do { \ - if (N) \ - { \ - (Current).begin = (Rhs)[1].begin; \ - (Current).end = (Rhs)[N].end; \ - } \ - else \ - { \ - (Current).begin = (Current).end = (Rhs)[0].end; \ - } \ -} while (false) -#endif - - -namespace triagens { namespace json_parser { - - - /// A Bison parser. - class JsonParserX - { - public: - /// Symbol semantic values. -#ifndef YYSTYPE - union semantic_type - { - - - std::string* str; - int32_t int32_type; - int64_t int64_type; - uint32_t uint32_type; - uint64_t uint64_type; - double double_type; - triagens::basics::VariantArray* variantArray; - triagens::basics::VariantArray* keyValueList; - triagens::basics::VariantVector* variantVector; - triagens::basics::VariantVector* valueList; - triagens::basics::VariantObject* variantObject; - - - - - }; -#else - typedef YYSTYPE semantic_type; -#endif - /// Symbol locations. - typedef location location_type; - /// Tokens. - struct token - { - /* Tokens. */ - enum yytokentype { - END = 0, - DECIMAL_CONSTANT = 258, - DECIMAL_CONSTANT_STRING = 259, - IDENTIFIER = 260, - SIGNED_INTEGER_CONSTANT = 261, - SIGNED_INTEGER_CONSTANT_STRING = 262, - SIGNED_LONG_INTEGER_CONSTANT = 263, - SIGNED_LONG_INTEGER_CONSTANT_STRING = 264, - STRING_CONSTANT = 265, - UNSIGNED_INTEGER_CONSTANT = 266, - UNSIGNED_INTEGER_CONSTANT_STRING = 267, - UNSIGNED_LONG_INTEGER_CONSTANT = 268, - UNSIGNED_LONG_INTEGER_CONSTANT_STRING = 269, - AND = 270, - ASSIGN = 271, - CLOSE_BRACE = 272, - CLOSE_BRACKET = 273, - CLOSE_PAREN = 274, - COLON = 275, - COMMA = 276, - DOT = 277, - EQ = 278, - FALSE_CONSTANT = 279, - GE = 280, - GT = 281, - LE = 282, - LT = 283, - MINUS = 284, - NE = 285, - NULL_CONSTANT = 286, - OPEN_BRACE = 287, - OPEN_BRACKET = 288, - OPEN_PAREN = 289, - OR = 290, - PLUS = 291, - QUOTIENT = 292, - SEMICOLON = 293, - TIMES = 294, - TRUE_CONSTANT = 295, - STRING_CONSTANT_NULL = 296, - UNQUOTED_STRING = 297, - NEGATION = 298 - }; - - }; - /// Token type. - typedef token::yytokentype token_type; - - /// Build a parser object. - JsonParserX (triagens::rest::JsonParserXDriver& driver_yyarg); - virtual ~JsonParserX (); - - /// Parse. - /// \returns 0 iff parsing succeeded. - virtual int parse (); - -#if YYDEBUG - /// The current debugging stream. - std::ostream& debug_stream () const; - /// Set the current debugging stream. - void set_debug_stream (std::ostream &); - - /// Type for debugging levels. - typedef int debug_level_type; - /// The current debugging level. - debug_level_type debug_level () const; - /// Set the current debugging level. - void set_debug_level (debug_level_type l); -#endif - - private: - /// Report a syntax error. - /// \param loc where the syntax error is found. - /// \param msg a description of the syntax error. - virtual void error (const location_type& loc, const std::string& msg); - - /// Generate an error message. - /// \param state the state where the error occurred. - /// \param tok the lookahead token. - virtual std::string yysyntax_error_ (int yystate, int tok); - -#if YYDEBUG - /// \brief Report a symbol value on the debug stream. - /// \param yytype The token type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - virtual void yy_symbol_value_print_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); - /// \brief Report a symbol on the debug stream. - /// \param yytype The token type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - virtual void yy_symbol_print_ (int yytype, - const semantic_type* yyvaluep, - const location_type* yylocationp); -#endif - - - /// State numbers. - typedef int state_type; - /// State stack type. - typedef stack state_stack_type; - /// Semantic value stack type. - typedef stack semantic_stack_type; - /// location stack type. - typedef stack location_stack_type; - - /// The state stack. - state_stack_type yystate_stack_; - /// The semantic value stack. - semantic_stack_type yysemantic_stack_; - /// The location stack. - location_stack_type yylocation_stack_; - - /// Internal symbol numbers. - typedef unsigned char token_number_type; - /* Tables. */ - /// For a state, the index in \a yytable_ of its portion. - static const signed char yypact_[]; - static const signed char yypact_ninf_; - - /// For a state, default rule to reduce. - /// Unless\a yytable_ specifies something else to do. - /// Zero means the default is an error. - static const unsigned char yydefact_[]; - - static const signed char yypgoto_[]; - static const signed char yydefgoto_[]; - - /// What to do in a state. - /// \a yytable_[yypact_[s]]: what to do in state \a s. - /// - if positive, shift that token. - /// - if negative, reduce the rule which number is the opposite. - /// - if zero, do what YYDEFACT says. - static const unsigned char yytable_[]; - static const signed char yytable_ninf_; - - static const signed char yycheck_[]; - - /// For a state, its accessing symbol. - static const unsigned char yystos_[]; - - /// For a rule, its LHS. - static const unsigned char yyr1_[]; - /// For a rule, its RHS length. - static const unsigned char yyr2_[]; - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE - /// For a symbol, its name in clear. - static const char* const yytname_[]; -#endif - -#if YYERROR_VERBOSE - /// Convert the symbol name \a n to a form suitable for a diagnostic. - virtual std::string yytnamerr_ (const char *n); -#endif - -#if YYDEBUG - /// A type to store symbol numbers and -1. - typedef signed char rhs_number_type; - /// A `-1'-separated list of the rules' RHS. - static const rhs_number_type yyrhs_[]; - /// For each rule, the index of the first RHS symbol in \a yyrhs_. - static const unsigned char yyprhs_[]; - /// For each rule, its source line number. - static const unsigned short int yyrline_[]; - /// For each scanner token number, its symbol number. - static const unsigned short int yytoken_number_[]; - /// Report on the debug stream that the rule \a r is going to be reduced. - virtual void yy_reduce_print_ (int r); - /// Print the state stack on the debug stream. - virtual void yystack_print_ (); - - /* Debugging. */ - int yydebug_; - std::ostream* yycdebug_; -#endif - - /// Convert a scanner token number \a t to a symbol number. - token_number_type yytranslate_ (int t); - - /// \brief Reclaim the memory associated to a symbol. - /// \param yymsg Why this token is reclaimed. - /// \param yytype The symbol type. - /// \param yyvaluep Its semantic value. - /// \param yylocationp Its location. - inline void yydestruct_ (const char* yymsg, - int yytype, - semantic_type* yyvaluep, - location_type* yylocationp); - - /// Pop \a n symbols the three stacks. - inline void yypop_ (unsigned int n = 1); - - /* Constants. */ - static const int yyeof_; - /* LAST_ -- Last index in TABLE_. */ - static const int yylast_; - static const int yynnts_; - static const int yyempty_; - static const int yyfinal_; - static const int yyterror_; - static const int yyerrcode_; - static const int yyntokens_; - static const unsigned int yyuser_token_number_max_; - static const token_number_type yyundef_token_; - - /* User arguments. */ - triagens::rest::JsonParserXDriver& driver; - }; - -} } // triagens::json_parser - - - - -#endif /* ! defined PARSER_HEADER_H */ diff --git a/JsonParserX/JsonParserX.yy b/JsonParserX/JsonParserX.yy index 8e11a1a85d..8939095a0d 100644 --- a/JsonParserX/JsonParserX.yy +++ b/JsonParserX/JsonParserX.yy @@ -37,9 +37,9 @@ %define namespace "triagens::json_parser" -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. // preamble -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. %code requires { #define NAME_SPACE triagens::json_parser @@ -54,18 +54,19 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "JsonParserX/JsonParserXDriver.h" using namespace std; using namespace triagens::basics; @@ -163,26 +164,26 @@ using namespace triagens::basics; YY_DECL; %} -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. // grammar -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. %% %start jsonDefinition; -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. // precedence -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. %left NEGATION; %left GE LE EQ NE GT LT; %left PLUS MINUS; %left TIMES QUOTIENT; -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. // DEFINITION FILE -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. jsonDefinition: variantArray { @@ -357,9 +358,9 @@ variantObject: %% -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. // postamble -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. void triagens::json_parser::JsonParserX::error (const triagens::json_parser::JsonParserX::location_type& l, const string& m) { triagens::json_parser::position last = l.end - 1; diff --git a/JsonParserX/JsonParserXDriver.cpp b/JsonParserX/JsonParserXDriver.cpp index 77c541a572..ff054756b4 100644 --- a/JsonParserX/JsonParserXDriver.cpp +++ b/JsonParserX/JsonParserXDriver.cpp @@ -27,17 +27,17 @@ #include "JsonParserXDriver.h" -#include -#include -#include "Basics/VariantBoolean.h" -#include "Basics/VariantDouble.h" -#include "Basics/VariantNull.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace triagens::basics; diff --git a/JsonParserX/JsonScannerX.cpp b/JsonParserX/JsonScannerX.cpp deleted file mode 100644 index 27b73131e3..0000000000 --- a/JsonParserX/JsonScannerX.cpp +++ /dev/null @@ -1,2704 +0,0 @@ - -#line 3 "JsonParserX/JsonScannerX.cpp" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -/* %not-for-header */ - -/* %if-c-only */ -/* %if-not-reentrant */ -/* %endif */ -/* %endif */ -/* %ok-for-header */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* %if-c++-only */ -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - -/* %if-c-only */ - -/* %endif */ - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -/* %if-c-only */ -#include -#include -#include -#include -/* %endif */ - -/* %if-tables-serialization */ -/* %endif */ -/* end standard C headers. */ - -/* %if-c-or-c++ */ -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! FLEXINT_H */ - -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* %not-for-header */ - -/* Returned upon end-of-file. */ -#define YY_NULL 0 -/* %ok-for-header */ - -/* %not-for-header */ - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) -/* %ok-for-header */ - -/* %if-reentrant */ - -/* An opaque pointer. */ -#ifndef YY_TYPEDEF_YY_SCANNER_T -#define YY_TYPEDEF_YY_SCANNER_T -typedef void* yyscan_t; -#endif - -/* For convenience, these vars (plus the bison vars far below) - are macros in the reentrant scanner. */ -#define yyin yyg->yyin_r -#define yyout yyg->yyout_r -#define yyextra yyg->yyextra_r -#define yyleng yyg->yyleng_r -#define yytext yyg->yytext_r -#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) -#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) -#define yy_flex_debug yyg->yy_flex_debug_r - -/* %endif */ - -/* %if-not-reentrant */ -/* %endif */ - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yyg->yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yyg->yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart(yyin ,yyscanner ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -/* %if-not-reentrant */ -/* %endif */ - -/* %if-c-only */ -/* %if-not-reentrant */ -/* %endif */ -/* %endif */ - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = yyg->yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { -/* %if-c-only */ - FILE *yy_input_file; -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ - -/* %if-not-reentrant */ -/* %endif */ -/* %ok-for-header */ - -/* %endif */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ - ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] - -/* %if-c-only Standard (non-C++) definition */ - -/* %if-not-reentrant */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ - -void yyrestart (FILE *input_file ,yyscan_t yyscanner ); -void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); -void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); -void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); -void yypop_buffer_state (yyscan_t yyscanner ); - -static void yyensure_buffer_stack (yyscan_t yyscanner ); -static void yy_load_buffer_state (yyscan_t yyscanner ); -static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); - -#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) - -YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); -YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); - -/* %endif */ - -void *yyalloc (yy_size_t ,yyscan_t yyscanner ); -void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner ); -void yyfree (void * ,yyscan_t yyscanner ); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - yyensure_buffer_stack (yyscanner); \ - YY_CURRENT_BUFFER_LVALUE = \ - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ -/* Begin user sect3 */ - -#define yywrap(n) 1 -#define YY_SKIP_YYWRAP - -#define FLEX_DEBUG - -typedef unsigned char YY_CHAR; - -typedef int yy_state_type; - -#define yytext_ptr yytext_r - -/* %if-c-only Standard (non-C++) definition */ - -static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); -static int yy_get_next_buffer (yyscan_t yyscanner ); -static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); - -/* %endif */ - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yyg->yytext_ptr = yy_bp; \ -/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ - yyleng = (size_t) (yy_cp - yy_bp); \ - yyg->yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ -/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ - yyg->yy_c_buf_p = yy_cp; - -/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ -#define YY_NUM_RULES 57 -#define YY_END_OF_BUFFER 58 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[108] = - { 0, - 0, 0, 15, 15, 0, 0, 58, 56, 1, 2, - 56, 3, 56, 51, 40, 54, 52, 36, 47, 41, - 55, 24, 26, 37, 53, 46, 56, 44, 56, 56, - 56, 56, 35, 33, 34, 56, 32, 16, 57, 15, - 14, 16, 1, 2, 49, 38, 24, 26, 0, 20, - 0, 26, 22, 39, 45, 48, 42, 43, 0, 0, - 0, 25, 27, 50, 15, 4, 6, 0, 5, 7, - 8, 9, 10, 11, 30, 31, 0, 0, 0, 21, - 27, 23, 0, 0, 0, 0, 0, 18, 19, 0, - 0, 0, 28, 0, 29, 17, 0, 0, 12, 12, - - 0, 0, 0, 0, 0, 13, 0 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 4, 5, 6, 7, 7, 7, 8, 7, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, - 18, 18, 18, 18, 18, 19, 19, 20, 21, 22, - 23, 24, 7, 7, 25, 26, 27, 28, 29, 30, - 7, 7, 7, 7, 7, 31, 7, 32, 7, 7, - 7, 33, 34, 35, 36, 7, 7, 7, 7, 7, - 37, 38, 39, 1, 7, 7, 40, 41, 27, 28, - - 42, 43, 7, 7, 7, 7, 7, 44, 7, 45, - 7, 7, 7, 46, 47, 48, 49, 7, 7, 7, - 7, 7, 50, 51, 52, 7, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[53] = - { 0, - 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 1, 3, 3, 3, 2, - 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, - 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, - 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, - 2, 2 - } ; - -static yyconst flex_int16_t yy_base[119] = - { 0, - 0, 0, 52, 58, 0, 0, 190, 240, 61, 185, - 160, 240, 174, 240, 240, 240, 52, 240, 58, 240, - 240, 41, 63, 157, 240, 43, 156, 153, 48, 43, - 51, 81, 240, 240, 240, 123, 240, 240, 240, 0, - 240, 102, 85, 169, 240, 240, 71, 86, 92, 240, - 95, 105, 240, 240, 240, 240, 240, 240, 62, 85, - 83, 90, 108, 240, 0, 240, 240, 143, 240, 240, - 240, 240, 240, 240, 136, 139, 94, 100, 104, 240, - 142, 240, 0, 144, 175, 183, 133, 240, 240, 0, - 0, 186, 189, 192, 195, 240, 0, 0, 240, 129, - - 128, 138, 188, 0, 0, 240, 240, 231, 234, 236, - 139, 134, 132, 92, 88, 80, 59, 54 - } ; - -static yyconst flex_int16_t yy_def[119] = - { 0, - 107, 1, 108, 108, 109, 109, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 110, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 110, 107, 107, 111, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 112, 112, 107, 107, 107, 107, 107, 113, - 114, 107, 107, 107, 107, 107, 115, 116, 107, 107, - - 107, 107, 107, 117, 118, 107, 0, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107 - } ; - -static yyconst flex_int16_t yy_nxt[293] = - { 0, - 8, 9, 10, 9, 11, 12, 8, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 23, 24, - 25, 26, 27, 28, 8, 8, 8, 8, 8, 29, - 8, 30, 8, 8, 31, 32, 33, 8, 34, 8, - 8, 8, 29, 8, 30, 8, 8, 31, 32, 35, - 36, 37, 38, 38, 39, 49, 106, 41, 38, 38, - 39, 105, 43, 41, 43, 55, 56, 38, 47, 48, - 48, 50, 59, 38, 47, 48, 48, 51, 60, 52, - 52, 52, 100, 61, 50, 49, 43, 59, 43, 42, - 99, 60, 77, 53, 98, 42, 61, 62, 63, 63, - - 51, 50, 52, 52, 52, 77, 53, 66, 75, 75, - 75, 76, 76, 76, 50, 78, 53, 67, 79, 51, - 80, 52, 52, 52, 81, 81, 81, 87, 78, 53, - 88, 79, 89, 80, 97, 53, 90, 68, 82, 69, - 87, 83, 70, 88, 71, 89, 72, 73, 53, 74, - 68, 82, 75, 75, 75, 76, 76, 76, 81, 81, - 81, 96, 91, 102, 85, 103, 101, 86, 91, 91, - 84, 44, 82, 64, 96, 58, 102, 85, 57, 54, - 86, 46, 45, 91, 91, 82, 92, 44, 92, 107, - 107, 93, 93, 93, 94, 107, 94, 107, 107, 95, - - 95, 95, 93, 93, 93, 93, 93, 93, 95, 95, - 95, 95, 95, 95, 104, 104, 104, 104, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 104, - 104, 40, 40, 40, 39, 39, 39, 65, 65, 7, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107 - - } ; - -static yyconst flex_int16_t yy_chk[293] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 3, 3, 3, 22, 118, 3, 4, 4, - 4, 117, 9, 4, 9, 26, 26, 3, 17, 17, - 17, 22, 29, 4, 19, 19, 19, 23, 30, 23, - 23, 23, 116, 31, 22, 47, 43, 29, 43, 3, - 115, 30, 59, 23, 114, 4, 31, 32, 32, 32, - - 48, 47, 48, 48, 48, 59, 23, 42, 49, 49, - 49, 51, 51, 51, 47, 60, 48, 42, 61, 52, - 62, 52, 52, 52, 63, 63, 63, 77, 60, 48, - 78, 61, 79, 62, 113, 52, 112, 42, 63, 42, - 77, 111, 42, 78, 42, 79, 42, 42, 52, 42, - 42, 63, 75, 75, 75, 76, 76, 76, 81, 81, - 81, 87, 84, 101, 75, 102, 100, 76, 84, 84, - 68, 44, 81, 36, 87, 28, 101, 75, 27, 24, - 76, 13, 11, 84, 84, 81, 85, 10, 85, 7, - 0, 85, 85, 85, 86, 0, 86, 0, 0, 86, - - 86, 86, 92, 92, 92, 93, 93, 93, 94, 94, - 94, 95, 95, 95, 103, 103, 103, 103, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, - 103, 108, 108, 108, 109, 109, 109, 110, 110, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, - 107, 107 - - } ; - -static yyconst flex_int16_t yy_rule_linenum[57] = - { 0, - 63, 67, 81, 86, 87, 88, 89, 90, 91, 92, - 93, 95, 101, 106, 112, 116, 123, 124, 125, 139, - 145, 151, 157, 167, 173, 179, 185, 195, 201, 211, - 217, 226, 227, 228, 229, 230, 231, 234, 235, 236, - 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, - 247, 248, 249, 250, 251, 260 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#include - -#include -#include -#include - -#include - -#include "JsonParserXDriver.h" -#include "JsonParserX.h" - -using namespace triagens::basics; -using namespace triagens::rest; - -#if defined(_MSC_VER) -#pragma warning( disable : 4018 ) -#endif - -/* Work around an incompatibility in flex (at least versions - 2.5.31 through 2.5.33): it generates code that does - not conform to C89. See Debian bug 333231 - . */ - -/* By default yylex returns int, we use token_type. - Unfortunately yyterminate by default returns 0, which is - not of token_type. */ - -#define yyterminate() return token::END -#define YYSTYPE NAME_SPACE::JsonParserX::semantic_type -#define YYLTYPE NAME_SPACE::location - -/* NOT USABLE HERE too MANY THREADS std::string buffer; */ - -#define YY_EXTRA_TYPE triagens::rest::JsonParserXDriver* -#define YY_USER_ACTION yylloc->columns(yyleng); - -#define INITIAL 0 -#define STRINGS 1 -#define UNQUOTED_STRINGS 2 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -/* %if-c-only */ -#include -/* %endif */ -/* %if-c++-only */ -/* %endif */ -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -/* %if-c-only Reentrant structure and macros (non-C++). */ -/* %if-reentrant */ - -/* Holds the entire state of the reentrant scanner. */ -struct yyguts_t - { - - /* User-defined. Not touched by flex. */ - YY_EXTRA_TYPE yyextra_r; - - /* The rest are the same as the globals declared in the non-reentrant scanner. */ - FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /**< index of top of stack. */ - size_t yy_buffer_stack_max; /**< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ - char yy_hold_char; - int yy_n_chars; - int yyleng_r; - char *yy_c_buf_p; - int yy_init; - int yy_start; - int yy_did_buffer_switch_on_eof; - int yy_start_stack_ptr; - int yy_start_stack_depth; - int *yy_start_stack; - yy_state_type yy_last_accepting_state; - char* yy_last_accepting_cpos; - - int yylineno_r; - int yy_flex_debug_r; - - char *yytext_r; - int yy_more_flag; - int yy_more_len; - - YYSTYPE * yylval_r; - - YYLTYPE * yylloc_r; - - }; /* end struct yyguts_t */ - -/* %if-c-only */ - -static int yy_init_globals (yyscan_t yyscanner ); - -/* %endif */ - -/* %if-reentrant */ - - /* This must go here because YYSTYPE and YYLTYPE are included - * from bison output in section 1.*/ - # define yylval yyg->yylval_r - - # define yylloc yyg->yylloc_r - -int yylex_init (yyscan_t* scanner); - -int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); - -/* %endif */ - -/* %endif End reentrant structures and macros. */ - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int yylex_destroy (yyscan_t yyscanner ); - -int yyget_debug (yyscan_t yyscanner ); - -void yyset_debug (int debug_flag ,yyscan_t yyscanner ); - -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner ); - -void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); - -FILE *yyget_in (yyscan_t yyscanner ); - -void yyset_in (FILE * in_str ,yyscan_t yyscanner ); - -FILE *yyget_out (yyscan_t yyscanner ); - -void yyset_out (FILE * out_str ,yyscan_t yyscanner ); - -int yyget_leng (yyscan_t yyscanner ); - -char *yyget_text (yyscan_t yyscanner ); - -int yyget_lineno (yyscan_t yyscanner ); - -void yyset_lineno (int line_number ,yyscan_t yyscanner ); - -/* %if-bison-bridge */ - -YYSTYPE * yyget_lval (yyscan_t yyscanner ); - -void yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); - - YYLTYPE *yyget_lloc (yyscan_t yyscanner ); - - void yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); - -/* %endif */ - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap (yyscan_t yyscanner ); -#else -extern int yywrap (yyscan_t yyscanner ); -#endif -#endif - -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); -#endif - -#ifndef YY_NO_INPUT -/* %if-c-only Standard (non-C++) definition */ -/* %not-for-header */ - -#ifdef __cplusplus -static int yyinput (yyscan_t yyscanner ); -#else -static int input (yyscan_t yyscanner ); -#endif -/* %ok-for-header */ - -/* %endif */ -#endif - -/* %if-c-only */ - -/* %endif */ - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* %if-c-only Standard (non-C++) definition */ -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO fwrite( yytext, yyleng, 1, yyout ) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ -/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - int n; \ - for ( n = 0; n < max_size && \ - (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - }\ -\ -/* %if-c++-only C++ definition \ */\ -/* %endif */ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -/* %if-c-only */ -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -#endif - -/* %if-tables-serialization structures and prototypes */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %not-for-header */ - -/* %tables-yydmap generated elements */ -/* %endif */ -/* end tables serialization structures and prototypes */ - -/* %ok-for-header */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 -/* %if-c-only Standard (non-C++) definition */ - -extern int yylex \ - (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); - -#define YY_DECL int yylex \ - (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only C++ definition */ -/* %endif */ -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -/* %% [6.0] YY_RULE_SETUP definition goes here */ -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/* %not-for-header */ - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -/* %% [7.0] user's declarations go here */ - - yylval = yylval_param; - - yylloc = yylloc_param; - - if ( !yyg->yy_init ) - { - yyg->yy_init = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yyg->yy_start ) - yyg->yy_start = 1; /* first start state */ - - if ( ! yyin ) -/* %if-c-only */ - yyin = stdin; -/* %endif */ -/* %if-c++-only */ -/* %endif */ - - if ( ! yyout ) -/* %if-c-only */ - yyout = stdout; -/* %endif */ -/* %if-c++-only */ -/* %endif */ - - if ( ! YY_CURRENT_BUFFER ) { - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_load_buffer_state(yyscanner ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { -/* %% [8.0] yymore()-related code goes here */ - yy_cp = yyg->yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yyg->yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - -/* %% [9.0] code to set up and find next match goes here */ - yy_current_state = yyg->yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 108 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_current_state != 107 ); - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - -yy_find_action: -/* %% [10.0] code to find the action number goes here */ - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -/* %% [11.0] code for yylineno update goes here */ - -do_action: /* This label is used only to access EOF actions. */ - -/* %% [12.0] debug code goes here */ - if ( yy_flex_debug ) - { - if ( yy_act == 0 ) - fprintf( stderr, "--scanner backing up\n" ); - else if ( yy_act < 57 ) - fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", - (long)yy_rule_linenum[yy_act], yytext ); - else if ( yy_act == 57 ) - fprintf( stderr, "--accepting default rule (\"%s\")\n", - yytext ); - else if ( yy_act == 58 ) - fprintf( stderr, "--(end of buffer or a NUL)\n" ); - else - fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); - } - - switch ( yy_act ) - { /* beginning of action switch */ -/* %% [13.0] actions go here */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yyg->yy_hold_char; - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -{ - yylloc->step(); -} - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -{ - yylloc->lines(yyleng); - yylloc->step(); -} - YY_BREAK - - typedef NAME_SPACE::JsonParserX::token token; - -/****************************** normal strings *******************************/ -case 3: -YY_RULE_SETUP -{ - BEGIN STRINGS; - yyextra->buffer = ""; -} - YY_BREAK -case 4: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\"'); } - YY_BREAK -case 5: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\\'); } - YY_BREAK -case 6: -YY_RULE_SETUP -{ yyextra->buffer.push_back('/'); } - YY_BREAK -case 7: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\b'); } - YY_BREAK -case 8: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\f'); } - YY_BREAK -case 9: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\n'); } - YY_BREAK -case 10: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\r'); } - YY_BREAK -case 11: -YY_RULE_SETUP -{ yyextra->buffer.push_back('\t'); } - YY_BREAK -case 12: -YY_RULE_SETUP -{ - StringUtils::unicodeToUTF8(&yytext[2],4, yyextra->buffer); - //should be terminate if incorrect unicode? - //yyterminate(); -- call this to prematurely terminate the scanning -} - YY_BREAK -case 13: -YY_RULE_SETUP -{ - StringUtils::convertUTF16ToUTF8(&yytext[2], &yytext[8], yyextra->buffer); -} - YY_BREAK -case 14: -YY_RULE_SETUP -{ - BEGIN 0; - yylval->str = new std::string(yyextra->buffer); - return token::STRING_CONSTANT; -} - YY_BREAK -case 15: -YY_RULE_SETUP -{ - yyextra->buffer.append(yytext,yyleng); -} - YY_BREAK -case 16: -YY_RULE_SETUP -{ - yyextra->buffer.push_back(yytext[0]); -} - YY_BREAK -/****************************** identifiers and Keywords *********************/ -case 17: -YY_RULE_SETUP -{ return token::FALSE_CONSTANT; } - YY_BREAK -case 18: -YY_RULE_SETUP -{ return token::NULL_CONSTANT; } - YY_BREAK -case 19: -YY_RULE_SETUP -{ return token::TRUE_CONSTANT; } - YY_BREAK -/*****************************************************************************/ -/****************************** INTEGERS *************************************/ -/*****************************************************************************/ -/*****************************************************************************/ -/* Integer with 'L' or 'l' are 64 bit */ -/*****************************************************************************/ -/* -- long zero -- */ -case 20: -YY_RULE_SETUP -{ - yylval->int64_type = 0; - return token::SIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/* -- unsigned long zero -- */ -case 21: -YY_RULE_SETUP -{ - yylval->uint64_type = 0; - return token::UNSIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/* -- long integer -- */ -case 22: -YY_RULE_SETUP -{ - yylval->int64_type = StringUtils::int64(yytext, yyleng - 1); - return token::SIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/* -- unsigned long integer -- */ -case 23: -YY_RULE_SETUP -{ - yylval->uint64_type = StringUtils::uint64(yytext + 1, yyleng - 2); - return token::UNSIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/*****************************************************************************/ -/* Integer without 'L' or 'l' are also 64 bit */ -/*****************************************************************************/ -/* -- zero -- */ -case 24: -YY_RULE_SETUP -{ - yylval->int64_type = 0; - return token::SIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/* -- unsigned zero -- */ -case 25: -YY_RULE_SETUP -{ - yylval->uint64_type = 0; - return token::UNSIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/* -- integer -- */ -case 26: -YY_RULE_SETUP -{ - yylval->int64_type = StringUtils::int64(yytext, yyleng); - return token::SIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/* -- unsigned integer -- */ -case 27: -YY_RULE_SETUP -{ - yylval->uint64_type = StringUtils::uint64(yytext + 1, yyleng - 1); - return token::UNSIGNED_LONG_INTEGER_CONSTANT; -} - YY_BREAK -/*******************************************************************************/ -/* floats with exponents */ -/*******************************************************************************/ -/* -- decimal with exponent beginning with zero -- */ -case 28: -YY_RULE_SETUP -{ - yylval->double_type = StringUtils::doubleDecimal(yytext, yyleng); - return token::DECIMAL_CONSTANT; -} - YY_BREAK -/* -- decimal with exponent not starting with ZERO -- */ -case 29: -YY_RULE_SETUP -{ - yylval->double_type = StringUtils::doubleDecimal(yytext, yyleng); - return token::DECIMAL_CONSTANT; -} - YY_BREAK -/*******************************************************************************/ -/* floats without exponents */ -/*******************************************************************************/ -/* -- decimal without exponent beginning with zero -- */ -case 30: -YY_RULE_SETUP -{ - yylval->double_type = StringUtils::doubleDecimal(yytext, yyleng); - return token::DECIMAL_CONSTANT; -} - YY_BREAK -/* -- decimal without exponent not starting with ZERO -- */ -case 31: -YY_RULE_SETUP -{ - yylval->double_type = StringUtils::doubleDecimal(yytext, yyleng); - return token::DECIMAL_CONSTANT; -} - YY_BREAK -/*******************************************************************************/ -/* special characters */ -/*******************************************************************************/ -case 32: -YY_RULE_SETUP -{ return token::CLOSE_BRACE; } - YY_BREAK -case 33: -YY_RULE_SETUP -{ return token::CLOSE_BRACKET; } - YY_BREAK -case 34: -YY_RULE_SETUP -{ return token::OPEN_BRACE; } - YY_BREAK -case 35: -YY_RULE_SETUP -{ return token::OPEN_BRACKET; } - YY_BREAK -case 36: -YY_RULE_SETUP -{ return token::COMMA; } - YY_BREAK -case 37: -YY_RULE_SETUP -{ return token::COLON; } - YY_BREAK -/* these special characters are here only to report an error which can easily be detected */ -case 38: -YY_RULE_SETUP -{ return token::AND; } - YY_BREAK -case 39: -YY_RULE_SETUP -{ return token::ASSIGN; } - YY_BREAK -case 40: -YY_RULE_SETUP -{ return token::CLOSE_PAREN; } - YY_BREAK -case 41: -YY_RULE_SETUP -{ return token::DOT; } - YY_BREAK -case 42: -YY_RULE_SETUP -{ return token::EQ; } - YY_BREAK -case 43: -YY_RULE_SETUP -{ return token::GE; } - YY_BREAK -case 44: -YY_RULE_SETUP -{ return token::GT; } - YY_BREAK -case 45: -YY_RULE_SETUP -{ return token::LE; } - YY_BREAK -case 46: -YY_RULE_SETUP -{ return token::LT; } - YY_BREAK -case 47: -YY_RULE_SETUP -{ return token::MINUS; } - YY_BREAK -case 48: -YY_RULE_SETUP -{ return token::NE; } - YY_BREAK -case 49: -YY_RULE_SETUP -{ return token::NE; } - YY_BREAK -case 50: -YY_RULE_SETUP -{ return token::OR; } - YY_BREAK -case 51: -YY_RULE_SETUP -{ return token::OPEN_PAREN; } - YY_BREAK -case 52: -YY_RULE_SETUP -{ return token::PLUS; } - YY_BREAK -case 53: -YY_RULE_SETUP -{ return token::SEMICOLON; } - YY_BREAK -case 54: -YY_RULE_SETUP -{ return token::TIMES; } - YY_BREAK -case 55: -YY_RULE_SETUP -{ return token::QUOTIENT; } - YY_BREAK -/*******************************************************************************/ -/* unquoted */ -/*******************************************************************************/ -/* whatever is left, should be an unquoted string appearing somewhere this */ -/* will be reported as an error */ -case 56: -YY_RULE_SETUP -{ - return token::UNQUOTED_STRING; -} - YY_BREAK -case 57: -YY_RULE_SETUP -ECHO; - YY_BREAK -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(STRINGS): -case YY_STATE_EOF(UNQUOTED_STRINGS): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yyg->yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); - - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yyg->yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { -/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */ - yy_cp = yyg->yy_last_accepting_cpos; - yy_current_state = yyg->yy_last_accepting_state; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_END_OF_FILE: - { - yyg->yy_did_buffer_switch_on_eof = 0; - - if ( yywrap(yyscanner ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = - yyg->yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yyg->yy_c_buf_p = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; - - yy_current_state = yy_get_previous_state( yyscanner ); - - yy_cp = yyg->yy_c_buf_p; - yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of yylex */ -/* %ok-for-header */ - -/* %if-c++-only */ -/* %not-for-header */ - -/* %ok-for-header */ - -/* %endif */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -/* %if-c-only */ -static int yy_get_next_buffer (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) (yyg->yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - yyg->yy_n_chars, (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - if ( yyg->yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart(yyin ,yyscanner); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - yyg->yy_n_chars += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -/* %if-c-only */ -/* %not-for-header */ - - static yy_state_type yy_get_previous_state (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - register yy_state_type yy_current_state; - register char *yy_cp; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - -/* %% [15.0] code to get the start state into yy_current_state goes here */ - yy_current_state = yyg->yy_start; - - for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) - { -/* %% [16.0] code to find the next state goes here */ - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 108 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ -/* %if-c-only */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - register int yy_is_jam; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ -/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ - register char *yy_cp = yyg->yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yyg->yy_last_accepting_state = yy_current_state; - yyg->yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 108 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 107); - - return yy_is_jam ? 0 : yy_current_state; -} - -/* %if-c-only */ - -/* %endif */ - -/* %if-c-only */ -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (yyscan_t yyscanner) -#else - static int input (yyscan_t yyscanner) -#endif - -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - int c; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - *yyg->yy_c_buf_p = yyg->yy_hold_char; - - if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) - /* This was really a NUL. */ - *yyg->yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; - ++yyg->yy_c_buf_p; - - switch ( yy_get_next_buffer( yyscanner ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart(yyin ,yyscanner); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap(yyscanner ) ) - return EOF; - - if ( ! yyg->yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(yyscanner); -#else - return input(yyscanner); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yyg->yy_c_buf_p = yyg->yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ - *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ - yyg->yy_hold_char = *++yyg->yy_c_buf_p; - -/* %% [19.0] update BOL and yylineno */ - - return c; -} -/* %if-c-only */ -#endif /* ifndef YY_NO_INPUT */ -/* %endif */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * @param yyscanner The scanner object. - * @note This function does not reset the start condition to @c INITIAL . - */ -/* %if-c-only */ - void yyrestart (FILE * input_file , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! YY_CURRENT_BUFFER ){ - yyensure_buffer_stack (yyscanner); - YY_CURRENT_BUFFER_LVALUE = - yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); - } - - yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); - yy_load_buffer_state(yyscanner ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * @param yyscanner The scanner object. - */ -/* %if-c-only */ - void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* TODO. We should be able to replace this entire function body - * with - * yypop_buffer_state(); - * yypush_buffer_state(new_buffer); - */ - yyensure_buffer_stack (yyscanner); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - yy_load_buffer_state(yyscanner ); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yyg->yy_did_buffer_switch_on_eof = 1; -} - -/* %if-c-only */ -static void yy_load_buffer_state (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - yyg->yy_hold_char = *yyg->yy_c_buf_p; -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * @param yyscanner The scanner object. - * @return the allocated buffer state. - */ -/* %if-c-only */ - YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ,yyscanner ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer(b,file ,yyscanner); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with yy_create_buffer() - * @param yyscanner The scanner object. - */ -/* %if-c-only */ - void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yyfree((void *) b->yy_ch_buf ,yyscanner ); - - yyfree((void *) b ,yyscanner ); -} - -/* %if-c-only */ - -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - -/* %endif */ - -/* %if-c++-only */ -/* %endif */ - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a yyrestart() or at EOF. - */ -/* %if-c-only */ - static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ - -{ - int oerrno = errno; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - yy_flush_buffer(b ,yyscanner); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then yy_init_buffer was _probably_ - * called from yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - -/* %if-c-only */ - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - -/* %endif */ -/* %if-c++-only */ -/* %endif */ - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * @param yyscanner The scanner object. - */ -/* %if-c-only */ - void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - yy_load_buffer_state(yyscanner ); -} - -/* %if-c-or-c++ */ -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * @param yyscanner The scanner object. - */ -/* %if-c-only */ -void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (new_buffer == NULL) - return; - - yyensure_buffer_stack(yyscanner); - - /* This block is copied from yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *yyg->yy_c_buf_p = yyg->yy_hold_char; - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - yyg->yy_buffer_stack_top++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from yy_switch_to_buffer. */ - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; -} -/* %endif */ - -/* %if-c-or-c++ */ -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * @param yyscanner The scanner object. - */ -/* %if-c-only */ -void yypop_buffer_state (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - if (!YY_CURRENT_BUFFER) - return; - - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); - YY_CURRENT_BUFFER_LVALUE = NULL; - if (yyg->yy_buffer_stack_top > 0) - --yyg->yy_buffer_stack_top; - - if (YY_CURRENT_BUFFER) { - yy_load_buffer_state(yyscanner ); - yyg->yy_did_buffer_switch_on_eof = 1; - } -} -/* %endif */ - -/* %if-c-or-c++ */ -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -/* %if-c-only */ -static void yyensure_buffer_stack (yyscan_t yyscanner) -/* %endif */ -/* %if-c++-only */ -/* %endif */ -{ - int num_to_alloc; - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (!yyg->yy_buffer_stack) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - yyg->yy_buffer_stack_max = num_to_alloc; - yyg->yy_buffer_stack_top = 0; - return; - } - - if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = yyg->yy_buffer_stack_max + grow_size; - yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc - (yyg->yy_buffer_stack, - num_to_alloc * sizeof(struct yy_buffer_state*) - , yyscanner); - if ( ! yyg->yy_buffer_stack ) - YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); - yyg->yy_buffer_stack_max = num_to_alloc; - } -} -/* %endif */ - -/* %if-c-only */ -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - yy_switch_to_buffer(b ,yyscanner ); - - return b; -} -/* %endif */ - -/* %if-c-only */ -/** Setup the input buffer state to scan a string. The next call to yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * yy_scan_bytes() instead. - */ -YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) -{ - - return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); -} -/* %endif */ - -/* %if-c-only */ -/** Setup the input buffer state to scan the given bytes. The next call to yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) yyalloc(n ,yyscanner ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = yy_scan_buffer(buf,n ,yyscanner); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} -/* %endif */ - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -/* %if-c-only */ -static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} -/* %endif */ -/* %if-c++-only */ -/* %endif */ - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - yytext[yyleng] = yyg->yy_hold_char; \ - yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ - yyg->yy_hold_char = *yyg->yy_c_buf_p; \ - *yyg->yy_c_buf_p = '\0'; \ - yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/* %if-c-only */ -/* %if-reentrant */ - -/** Get the user-defined data for this scanner. - * @param yyscanner The scanner object. - */ -YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyextra; -} - -/* %endif */ - -/** Get the current line number. - * @param yyscanner The scanner object. - */ -int yyget_lineno (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yylineno; -} - -/** Get the current column number. - * @param yyscanner The scanner object. - */ -int yyget_column (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - if (! YY_CURRENT_BUFFER) - return 0; - - return yycolumn; -} - -/** Get the input stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_in (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyin; -} - -/** Get the output stream. - * @param yyscanner The scanner object. - */ -FILE *yyget_out (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyout; -} - -/** Get the length of the current token. - * @param yyscanner The scanner object. - */ -int yyget_leng (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yyleng; -} - -/** Get the current token. - * @param yyscanner The scanner object. - */ - -char *yyget_text (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yytext; -} - -/* %if-reentrant */ - -/** Set the user-defined data. This data is never touched by the scanner. - * @param user_defined The data to be associated with this scanner. - * @param yyscanner The scanner object. - */ -void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyextra = user_defined ; -} - -/* %endif */ - -/** Set the current line number. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_lineno (int line_number , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* lineno is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "yyset_lineno called with no buffer" , yyscanner); - - yylineno = line_number; -} - -/** Set the current column. - * @param line_number - * @param yyscanner The scanner object. - */ -void yyset_column (int column_no , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* column is only valid if an input buffer exists. */ - if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "yyset_column called with no buffer" , yyscanner); - - yycolumn = column_no; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * @param yyscanner The scanner object. - * @see yy_switch_to_buffer - */ -void yyset_in (FILE * in_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyin = in_str ; -} - -void yyset_out (FILE * out_str , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yyout = out_str ; -} - -int yyget_debug (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yy_flex_debug; -} - -void yyset_debug (int bdebug , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yy_flex_debug = bdebug ; -} - -/* %endif */ - -/* %if-reentrant */ -/* Accessor methods for yylval and yylloc */ - -/* %if-bison-bridge */ - -YYSTYPE * yyget_lval (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylval; -} - -void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylval = yylval_param; -} - -YYLTYPE *yyget_lloc (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - return yylloc; -} - -void yyset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - yylloc = yylloc_param; -} - -/* %endif */ - -/* User-visible API */ - -/* yylex_init is special because it creates the scanner itself, so it is - * the ONLY reentrant function that doesn't take the scanner as the last argument. - * That's why we explicitly handle the declaration, instead of using our macros. - */ - -int yylex_init(yyscan_t* ptr_yy_globals) - -{ - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* yylex_init_extra has the same functionality as yylex_init, but follows the - * convention of taking the scanner as the last argument. Note however, that - * this is a *pointer* to a scanner, as it will be allocated by this call (and - * is the reason, too, why this function also must handle its own declaration). - * The user defined value in the first argument will be available to yyalloc in - * the yyextra field. - */ - -int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) - -{ - struct yyguts_t dummy_yyguts; - - yyset_extra (yy_user_defined, &dummy_yyguts); - - if (ptr_yy_globals == NULL){ - errno = EINVAL; - return 1; - } - - *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - - if (*ptr_yy_globals == NULL){ - errno = ENOMEM; - return 1; - } - - /* By setting to 0xAA, we expose bugs in - yy_init_globals. Leave at 0x00 for releases. */ - memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - - yyset_extra (yy_user_defined, *ptr_yy_globals); - - return yy_init_globals ( *ptr_yy_globals ); -} - -/* %endif if-c-only */ - -/* %if-c-only */ -static int yy_init_globals (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from yylex_destroy(), so don't allocate here. - */ - - yyg->yy_buffer_stack = 0; - yyg->yy_buffer_stack_top = 0; - yyg->yy_buffer_stack_max = 0; - yyg->yy_c_buf_p = (char *) 0; - yyg->yy_init = 0; - yyg->yy_start = 0; - - yyg->yy_start_stack_ptr = 0; - yyg->yy_start_stack_depth = 0; - yyg->yy_start_stack = NULL; - -/* Defined in main.c */ -#ifdef YY_STDINIT - yyin = stdin; - yyout = stdout; -#else - yyin = (FILE *) 0; - yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * yylex_init() - */ - return 0; -} -/* %endif */ - -/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ -/* yylex_destroy is for both reentrant and non-reentrant scanners. */ -int yylex_destroy (yyscan_t yyscanner) -{ - struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); - YY_CURRENT_BUFFER_LVALUE = NULL; - yypop_buffer_state(yyscanner); - } - - /* Destroy the stack itself. */ - yyfree(yyg->yy_buffer_stack ,yyscanner); - yyg->yy_buffer_stack = NULL; - - /* Destroy the start condition stack. */ - yyfree(yyg->yy_start_stack ,yyscanner ); - yyg->yy_start_stack = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * yylex() is called, initialization will occur. */ - yy_init_globals( yyscanner); - -/* %if-reentrant */ - /* Destroy the main struct (reentrant only). */ - yyfree ( yyscanner , yyscanner ); - yyscanner = NULL; -/* %endif */ - return 0; -} -/* %endif */ - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *yyalloc (yy_size_t size , yyscan_t yyscanner) -{ - return (void *) malloc( size ); -} - -void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void yyfree (void * ptr , yyscan_t yyscanner) -{ - free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ -} - -/* %if-tables-serialization definitions */ -/* %define-yytables The name for this specific scanner's tables. */ -#define YYTABLES_NAME "yytables" -/* %endif */ - -/* %ok-for-header */ - -void JsonParserXDriver::doParse () { - NAME_SPACE::JsonParserX parser(*this); - parser.set_debug_level(traceParsing); - parser.parse(); -} - -void JsonParserXDriver::scan_begin () { - yylex_init_extra(this,&scanner); - yyset_debug(traceScanning,scanner); - yy_scan_string(scanString,scanner); -} - -void JsonParserXDriver::scan_end () { - yylex_destroy(scanner); -} - diff --git a/JsonParserX/location.hh b/JsonParserX/location.hh deleted file mode 100644 index 2fef200e1a..0000000000 --- a/JsonParserX/location.hh +++ /dev/null @@ -1,161 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Locations for Bison parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file location.hh - ** Define the triagens::json_parser::location class. - */ - -#ifndef BISON_LOCATION_HH -# define BISON_LOCATION_HH - -# include -# include -# include "position.hh" - - -namespace triagens { namespace json_parser { - - - /// Abstract a location. - class location - { - public: - - /// Construct a location. - location () - : begin (), end () - { - } - - - /// Initialization. - inline void initialize (std::string* fn) - { - begin.initialize (fn); - end = begin; - } - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// Reset initial location to final location. - inline void step () - { - begin = end; - } - - /// Extend the current location to the COUNT next columns. - inline void columns (unsigned int count = 1) - { - end += count; - } - - /// Extend the current location to the COUNT next lines. - inline void lines (unsigned int count = 1) - { - end.lines (count); - } - /** \} */ - - - public: - /// Beginning of the located region. - position begin; - /// End of the located region. - position end; - }; - - /// Join two location objects to create a location. - inline const location operator+ (const location& begin, const location& end) - { - location res = begin; - res.end = end.end; - return res; - } - - /// Add two location objects. - inline const location operator+ (const location& begin, unsigned int width) - { - location res = begin; - res.columns (width); - return res; - } - - /// Add and assign a location. - inline location& operator+= (location& res, unsigned int width) - { - res.columns (width); - return res; - } - - /// Compare two location objects. - inline bool - operator== (const location& loc1, const location& loc2) - { - return loc1.begin == loc2.begin && loc1.end == loc2.end; - } - - /// Compare two location objects. - inline bool - operator!= (const location& loc1, const location& loc2) - { - return !(loc1 == loc2); - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param loc a reference to the location to redirect - ** - ** Avoid duplicate information. - */ - inline std::ostream& operator<< (std::ostream& ostr, const location& loc) - { - position last = loc.end - 1; - ostr << loc.begin; - if (last.filename - && (!loc.begin.filename - || *loc.begin.filename != *last.filename)) - ostr << '-' << last; - else if (loc.begin.line != last.line) - ostr << '-' << last.line << '.' << last.column; - else if (loc.begin.column != last.column) - ostr << '-' << last.column; - return ostr; - } - - -} } // triagens::json_parser - - -#endif // not BISON_LOCATION_HH diff --git a/JsonParserX/position.hh b/JsonParserX/position.hh deleted file mode 100644 index e458c1eba9..0000000000 --- a/JsonParserX/position.hh +++ /dev/null @@ -1,157 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Positions for Bison parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/** - ** \file position.hh - ** Define the triagens::json_parser::position class. - */ - -#ifndef BISON_POSITION_HH -# define BISON_POSITION_HH - -# include -# include -# include - - -namespace triagens { namespace json_parser { - - /// Abstract a position. - class position - { - public: - - /// Construct a position. - position () - : filename (0), line (1), column (1) - { - } - - - /// Initialization. - inline void initialize (std::string* fn) - { - filename = fn; - line = 1; - column = 1; - } - - /** \name Line and Column related manipulators - ** \{ */ - public: - /// (line related) Advance to the COUNT next lines. - inline void lines (int count = 1) - { - column = 1; - line += count; - } - - /// (column related) Advance to the COUNT next columns. - inline void columns (int count = 1) - { - column = std::max (1u, column + count); - } - /** \} */ - - public: - /// File name to which this position refers. - std::string* filename; - /// Current line number. - unsigned int line; - /// Current column number. - unsigned int column; - }; - - /// Add and assign a position. - inline const position& - operator+= (position& res, const int width) - { - res.columns (width); - return res; - } - - /// Add two position objects. - inline const position - operator+ (const position& begin, const int width) - { - position res = begin; - return res += width; - } - - /// Add and assign a position. - inline const position& - operator-= (position& res, const int width) - { - return res += -width; - } - - /// Add two position objects. - inline const position - operator- (const position& begin, const int width) - { - return begin + -width; - } - - /// Compare two position objects. - inline bool - operator== (const position& pos1, const position& pos2) - { - return - (pos1.filename == pos2.filename - || pos1.filename && pos2.filename && *pos1.filename == *pos2.filename) - && pos1.line == pos2.line && pos1.column == pos2.column; - } - - /// Compare two position objects. - inline bool - operator!= (const position& pos1, const position& pos2) - { - return !(pos1 == pos2); - } - - /** \brief Intercept output stream redirection. - ** \param ostr the destination output stream - ** \param pos a reference to the position to redirect - */ - inline std::ostream& - operator<< (std::ostream& ostr, const position& pos) - { - if (pos.filename) - ostr << *pos.filename << ':'; - return ostr << pos.line << '.' << pos.column; - } - - -} } // triagens::json_parser - -#endif // not BISON_POSITION_HH diff --git a/JsonParserX/stack.hh b/JsonParserX/stack.hh deleted file mode 100644 index ec51c7622e..0000000000 --- a/JsonParserX/stack.hh +++ /dev/null @@ -1,133 +0,0 @@ - -/* A Bison parser, made by GNU Bison 2.4.1. */ - -/* Stack handling for Bison parsers in C++ - - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software - Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -#ifndef BISON_STACK_HH -# define BISON_STACK_HH - -#include - - -namespace triagens { namespace json_parser { - - template > - class stack - { - public: - - // Hide our reversed order. - typedef typename S::reverse_iterator iterator; - typedef typename S::const_reverse_iterator const_iterator; - - stack () : seq_ () - { - } - - stack (unsigned int n) : seq_ (n) - { - } - - inline - T& - operator [] (unsigned int i) - { - return seq_[i]; - } - - inline - const T& - operator [] (unsigned int i) const - { - return seq_[i]; - } - - inline - void - push (const T& t) - { - seq_.push_front (t); - } - - inline - void - pop (unsigned int n = 1) - { - for (; n; --n) - seq_.pop_front (); - } - - inline - unsigned int - height () const - { - return seq_.size (); - } - - inline const_iterator begin () const { return seq_.rbegin (); } - inline const_iterator end () const { return seq_.rend (); } - - private: - - S seq_; - }; - - /// Present a slice of the top of a stack. - template > - class slice - { - public: - - slice (const S& stack, - unsigned int range) : stack_ (stack), - range_ (range) - { - } - - inline - const T& - operator [] (unsigned int i) const - { - return stack_[range_ - i]; - } - - private: - - const S& stack_; - unsigned int range_; - }; - -} } // triagens::json_parser - - -#endif // not BISON_STACK_HH[]dnl -