From b78e72f0d23a16124b0abe034fa5bd32ce56af20 Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Thu, 22 Dec 2011 15:45:39 +0100 Subject: [PATCH] added disclaimer --- JsonParserX/JsonParserX.cpp | 26 +++++----- JsonParserX/JsonParserX.h | 12 ++--- JsonParserX/JsonParserX.yy | 31 +++++++++++- JsonParserX/JsonParserXDriver.h | 2 +- JsonParserX/JsonScannerX.cpp | 88 ++++++++++++++++----------------- JsonParserX/JsonScannerX.ll | 27 ++++++++++ 6 files changed, 120 insertions(+), 66 deletions(-) diff --git a/JsonParserX/JsonParserX.cpp b/JsonParserX/JsonParserX.cpp index 5eb8482baf..e726e41578 100644 --- a/JsonParserX/JsonParserX.cpp +++ b/JsonParserX/JsonParserX.cpp @@ -2,20 +2,20 @@ /* 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 . */ @@ -28,7 +28,7 @@ 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. */ @@ -37,7 +37,7 @@ -#include +#include #include #include #include @@ -237,7 +237,7 @@ namespace triagens { namespace json_parser { switch (yytype) { - + default: break; } @@ -312,7 +312,7 @@ namespace triagens { namespace json_parser { /* User initialization code. */ - + { // reset the location yylloc.step(); @@ -543,23 +543,23 @@ namespace triagens { namespace json_parser { { (yyval.keyValueList) = new VariantArray(); - (yyval.keyValueList)->add(*(yysemantic_stack_[(3) - (1)].str),(yysemantic_stack_[(3) - (3)].variantObject)); - delete (yysemantic_stack_[(3) - (1)].str); + (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 + // 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); + (yyval.keyValueList)->add(*(yysemantic_stack_[(5) - (3)].str),(yysemantic_stack_[(5) - (5)].variantObject)); + delete (yysemantic_stack_[(5) - (3)].str); } break; diff --git a/JsonParserX/JsonParserX.h b/JsonParserX/JsonParserX.h index 2ea55d06c7..52642e99e7 100644 --- a/JsonParserX/JsonParserX.h +++ b/JsonParserX/JsonParserX.h @@ -2,20 +2,20 @@ /* 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 . */ @@ -28,7 +28,7 @@ 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. */ @@ -128,7 +128,7 @@ namespace triagens { namespace json_parser { triagens::basics::VariantVector* variantVector; triagens::basics::VariantVector* valueList; triagens::basics::VariantObject* variantObject; - + diff --git a/JsonParserX/JsonParserX.yy b/JsonParserX/JsonParserX.yy index c78d5243e4..8e11a1a85d 100644 --- a/JsonParserX/JsonParserX.yy +++ b/JsonParserX/JsonParserX.yy @@ -4,9 +4,36 @@ %error-verbose %pure-parser -// ///////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief bison parser +/// +/// @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. Oreste Costa-Panaia +/// @author Copyright 2010-2011, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +// ............................................................................. // change the namespace here -- see define NAME_SPACE below -// ///////////////////////////////////////////////////////////////////////////// +// ............................................................................. %define namespace "triagens::json_parser" diff --git a/JsonParserX/JsonParserXDriver.h b/JsonParserX/JsonParserXDriver.h index e6175ee8d3..bef3287c94 100644 --- a/JsonParserX/JsonParserXDriver.h +++ b/JsonParserX/JsonParserXDriver.h @@ -28,7 +28,7 @@ #ifndef TRIAGENS_FYN_JSON_PARSER_X_JSON_PARSER_XDRIVER_H #define TRIAGENS_FYN_JSON_PARSER_X_JSON_PARSER_XDRIVER_H 1 -#include +#include //////////////////////////////////////////////////////////////////////////////// // @brief flex prototyp diff --git a/JsonParserX/JsonScannerX.cpp b/JsonParserX/JsonScannerX.cpp index bcca523ed9..27b73131e3 100644 --- a/JsonParserX/JsonScannerX.cpp +++ b/JsonParserX/JsonScannerX.cpp @@ -1,5 +1,5 @@ -#line 3 "./JsonParserX/JsonScannerX.cpp" +#line 3 "JsonParserX/JsonScannerX.cpp" #define YY_INT_ALIGNED short int @@ -25,7 +25,7 @@ /* %endif */ /* %if-c-only */ - + /* %endif */ /* %if-c-only */ @@ -57,7 +57,7 @@ #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. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -74,7 +74,7 @@ typedef uint32_t flex_uint32_t; 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 char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -224,7 +224,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #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 \ @@ -291,7 +291,7 @@ struct yy_buffer_state 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. */ @@ -651,13 +651,13 @@ using namespace triagens::rest; /* 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); @@ -733,9 +733,9 @@ static int yy_init_globals (yyscan_t yyscanner ); /* 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); @@ -780,9 +780,9 @@ 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 @@ -1088,9 +1088,9 @@ case 2: /* rule 2 can match eol */ YY_RULE_SETUP { - yylloc->lines(yyleng); + yylloc->lines(yyleng); yylloc->step(); -} +} YY_BREAK typedef NAME_SPACE::JsonParserX::token token; @@ -1099,7 +1099,7 @@ YY_RULE_SETUP case 3: YY_RULE_SETUP { - BEGIN STRINGS; + BEGIN STRINGS; yyextra->buffer = ""; } YY_BREAK @@ -1160,12 +1160,12 @@ YY_RULE_SETUP case 15: YY_RULE_SETUP { - yyextra->buffer.append(yytext,yyleng); + yyextra->buffer.append(yytext,yyleng); } YY_BREAK case 16: YY_RULE_SETUP -{ +{ yyextra->buffer.push_back(yytext[0]); } YY_BREAK @@ -1397,12 +1397,12 @@ YY_RULE_SETUP /* unquoted */ /*******************************************************************************/ /* whatever is left, should be an unquoted string appearing somewhere this */ -/* will be reported as an error */ +/* will be reported as an error */ case 56: YY_RULE_SETUP { return token::UNQUOTED_STRING; -} +} YY_BREAK case 57: YY_RULE_SETUP @@ -1944,7 +1944,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner) /* %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()" ); @@ -1994,7 +1994,7 @@ static void yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* %endif */ /* %if-c++-only */ @@ -2031,7 +2031,7 @@ extern int isatty (int ); /* %if-c-only */ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + /* %endif */ /* %if-c++-only */ /* %endif */ @@ -2161,9 +2161,9 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) , 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; @@ -2194,12 +2194,12 @@ static void yyensure_buffer_stack (yyscan_t yyscanner) * @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. + * @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 ) @@ -2237,7 +2237,7 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - + return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /* %endif */ @@ -2256,7 +2256,7 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yysc 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 ); @@ -2334,10 +2334,10 @@ YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner) int yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -2347,10 +2347,10 @@ int yyget_lineno (yyscan_t yyscanner) int yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -2415,8 +2415,8 @@ void yyset_lineno (int line_number , yyscan_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); - + yy_fatal_error( "yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } @@ -2430,8 +2430,8 @@ void yyset_column (int column_no , yyscan_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); - + yy_fatal_error( "yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } @@ -2489,13 +2489,13 @@ 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 */ @@ -2545,20 +2545,20 @@ int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) 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 ); } @@ -2689,7 +2689,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) void JsonParserXDriver::doParse () { NAME_SPACE::JsonParserX parser(*this); parser.set_debug_level(traceParsing); - parser.parse(); + parser.parse(); } void JsonParserXDriver::scan_begin () { diff --git a/JsonParserX/JsonScannerX.ll b/JsonParserX/JsonScannerX.ll index 1268b20efc..460a2cbf2e 100644 --- a/JsonParserX/JsonScannerX.ll +++ b/JsonParserX/JsonScannerX.ll @@ -1,4 +1,31 @@ %{ /* -*- C++ -*- */ +//////////////////////////////////////////////////////////////////////////////// +/// @brief flex scanner +/// +/// @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. Oreste Costa-Panaia +/// @author Copyright 2010-2011, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + #include #include