From 8e9bfd5c4a1e43e235d8d1d57ce28c38f7a71a42 Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Fri, 9 Jan 2009 14:12:17 -0330 Subject: C++Builder compile fixes --- cpp/src/IceGrid/NodeI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cpp/src') diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 77ed21db79e..140e2e73d81 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -193,7 +193,7 @@ class NodeUp : public NodeI::Update, public AMI_NodeObserver_nodeUp public: NodeUp(const NodeIPtr& node, const NodeObserverPrx& observer, NodeDynamicInfo info) : - Update(node, observer), _info(info) + NodeI::Update(node, observer), _info(info) { } -- cgit v1.2.3 From 9489933d2e20de2c60682831a9a1fe384f61974a Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Fri, 9 Jan 2009 10:50:03 -0800 Subject: bug 3523 - commit flex/bison files --- cpp/demo/Freeze/library/.gitignore | 3 - cpp/demo/Freeze/library/Grammar.cpp | 1418 +++++++++++ cpp/demo/Freeze/library/Grammar.h | 74 + cpp/demo/Freeze/library/Makefile | 2 - cpp/demo/Freeze/library/Makefile.mak | 2 - cpp/demo/Freeze/library/Scanner.cpp | 1845 ++++++++++++++ cpp/demo/Freeze/phonebook/.gitignore | 3 - cpp/demo/Freeze/phonebook/Grammar.cpp | 1422 +++++++++++ cpp/demo/Freeze/phonebook/Grammar.h | 74 + cpp/demo/Freeze/phonebook/Makefile | 2 - cpp/demo/Freeze/phonebook/Makefile.mak | 2 - cpp/demo/Freeze/phonebook/Scanner.cpp | 1845 ++++++++++++++ cpp/demo/book/freeze_filesystem/.gitignore | 3 - cpp/demo/book/freeze_filesystem/Makefile | 2 - cpp/demo/book/lifecycle/.gitignore | 3 - cpp/demo/book/lifecycle/Grammar.cpp | 1408 +++++++++++ cpp/demo/book/lifecycle/Grammar.h | 72 + cpp/demo/book/lifecycle/Makefile | 4 - cpp/demo/book/lifecycle/Makefile.mak | 2 - cpp/demo/book/lifecycle/Scanner.cpp | 1826 ++++++++++++++ cpp/src/FreezeScript/.gitignore | 6 - cpp/src/FreezeScript/Grammar.cpp | 1674 +++++++++++++ cpp/src/FreezeScript/Grammar.h | 102 + cpp/src/FreezeScript/Makefile | 5 - cpp/src/FreezeScript/Makefile.mak | 2 - cpp/src/FreezeScript/Scanner.cpp | 2000 +++++++++++++++ cpp/src/IceGrid/.gitignore | 3 - cpp/src/IceGrid/Grammar.cpp | 3224 ++++++++++++++++++++++++ cpp/src/IceGrid/Grammar.h | 126 + cpp/src/IceGrid/Makefile | 4 - cpp/src/IceGrid/Makefile.mak | 2 - cpp/src/IceGrid/Scanner.cpp | 1790 ++++++++++++++ cpp/src/IceStorm/.gitignore | 3 - cpp/src/IceStorm/Grammar.cpp | 1484 +++++++++++ cpp/src/IceStorm/Grammar.h | 70 + cpp/src/IceStorm/Makefile | 2 - cpp/src/IceStorm/Makefile.mak | 4 - cpp/src/IceStorm/Scanner.cpp | 1762 ++++++++++++++ cpp/src/Slice/.gitignore | 6 - cpp/src/Slice/Grammar.cpp | 3655 ++++++++++++++++++++++++++++ cpp/src/Slice/Grammar.h | 130 + cpp/src/Slice/Makefile | 4 - cpp/src/Slice/Makefile.mak | 2 - cpp/src/Slice/Scanner.cpp | 2133 ++++++++++++++++ cpp/test/Freeze/complex/.gitignore | 3 - cpp/test/Freeze/complex/Grammar.cpp | 1261 ++++++++++ cpp/test/Freeze/complex/Grammar.h | 50 + cpp/test/Freeze/complex/Makefile | 2 - cpp/test/Freeze/complex/Makefile.mak | 2 - cpp/test/Freeze/complex/Scanner.cpp | 1543 ++++++++++++ 50 files changed, 30988 insertions(+), 78 deletions(-) create mode 100644 cpp/demo/Freeze/library/Grammar.cpp create mode 100644 cpp/demo/Freeze/library/Grammar.h create mode 100644 cpp/demo/Freeze/library/Scanner.cpp create mode 100644 cpp/demo/Freeze/phonebook/Grammar.cpp create mode 100644 cpp/demo/Freeze/phonebook/Grammar.h create mode 100644 cpp/demo/Freeze/phonebook/Scanner.cpp create mode 100644 cpp/demo/book/lifecycle/Grammar.cpp create mode 100644 cpp/demo/book/lifecycle/Grammar.h create mode 100644 cpp/demo/book/lifecycle/Scanner.cpp delete mode 100644 cpp/src/FreezeScript/.gitignore create mode 100644 cpp/src/FreezeScript/Grammar.cpp create mode 100644 cpp/src/FreezeScript/Grammar.h create mode 100644 cpp/src/FreezeScript/Scanner.cpp create mode 100644 cpp/src/IceGrid/Grammar.cpp create mode 100644 cpp/src/IceGrid/Grammar.h create mode 100644 cpp/src/IceGrid/Scanner.cpp create mode 100644 cpp/src/IceStorm/Grammar.cpp create mode 100644 cpp/src/IceStorm/Grammar.h create mode 100644 cpp/src/IceStorm/Scanner.cpp delete mode 100644 cpp/src/Slice/.gitignore create mode 100644 cpp/src/Slice/Grammar.cpp create mode 100644 cpp/src/Slice/Grammar.h create mode 100644 cpp/src/Slice/Scanner.cpp create mode 100644 cpp/test/Freeze/complex/Grammar.cpp create mode 100644 cpp/test/Freeze/complex/Grammar.h create mode 100644 cpp/test/Freeze/complex/Scanner.cpp (limited to 'cpp/src') diff --git a/cpp/demo/Freeze/library/.gitignore b/cpp/demo/Freeze/library/.gitignore index 54621e8e1aa..e810043d997 100644 --- a/cpp/demo/Freeze/library/.gitignore +++ b/cpp/demo/Freeze/library/.gitignore @@ -9,6 +9,3 @@ Library.h db/* LibraryTypes.h LibraryTypes.cpp -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/demo/Freeze/library/Grammar.cpp b/cpp/demo/Freeze/library/Grammar.cpp new file mode 100644 index 00000000000..87f243e55fe --- /dev/null +++ b/cpp/demo/Freeze/library/Grammar.cpp @@ -0,0 +1,1418 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_ADD_BOOK = 260, + TOK_FIND_ISBN = 261, + TOK_FIND_AUTHORS = 262, + TOK_NEXT_FOUND_BOOK = 263, + TOK_PRINT_CURRENT = 264, + TOK_RENT_BOOK = 265, + TOK_RETURN_BOOK = 266, + TOK_REMOVE_CURRENT = 267, + TOK_SET_EVICTOR_SIZE = 268, + TOK_SHUTDOWN = 269, + TOK_STRING = 270 + }; +#endif +#define TOK_HELP 258 +#define TOK_EXIT 259 +#define TOK_ADD_BOOK 260 +#define TOK_FIND_ISBN 261 +#define TOK_FIND_AUTHORS 262 +#define TOK_NEXT_FOUND_BOOK 263 +#define TOK_PRINT_CURRENT 264 +#define TOK_RENT_BOOK 265 +#define TOK_RETURN_BOOK 266 +#define TOK_REMOVE_CURRENT 267 +#define TOK_SET_EVICTOR_SIZE 268 +#define TOK_SHUTDOWN 269 +#define TOK_STRING 270 + + + + +/* Copy the first part of user declarations. */ +#line 1 "Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; + +void +yyerror(const char* s) +{ + parser->error(s); +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 148 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 32 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 51 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 17 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 5 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 21 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 40 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 270 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 16, + 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 6, 9, 11, 14, 17, 21, + 25, 29, 32, 35, 39, 42, 45, 49, 52, 55, + 57, 60 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 18, 0, -1, 19, -1, -1, 19, 20, -1, 20, + -1, 3, 16, -1, 4, 16, -1, 5, 21, 16, + -1, 6, 21, 16, -1, 7, 21, 16, -1, 8, + 16, -1, 9, 16, -1, 10, 21, 16, -1, 11, + 16, -1, 12, 16, -1, 13, 21, 16, -1, 14, + 16, -1, 1, 16, -1, 16, -1, 15, 21, -1, + 15, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 53, 53, 57, 64, 67, 75, 79, 83, 87, + 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, + 135, 140 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_HELP", "TOK_EXIT", "TOK_ADD_BOOK", + "TOK_FIND_ISBN", "TOK_FIND_AUTHORS", "TOK_NEXT_FOUND_BOOK", + "TOK_PRINT_CURRENT", "TOK_RENT_BOOK", "TOK_RETURN_BOOK", + "TOK_REMOVE_CURRENT", "TOK_SET_EVICTOR_SIZE", "TOK_SHUTDOWN", + "TOK_STRING", "';'", "$accept", "start", "commands", "command", + "strings", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 17, 18, 18, 19, 19, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 21, 21 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 0, 2, 1, 2, 2, 3, 3, + 3, 2, 2, 3, 2, 2, 3, 2, 2, 1, + 2, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 0, 0, 5, 18, 6, + 7, 21, 0, 0, 0, 11, 12, 0, 14, 15, + 0, 17, 1, 4, 20, 8, 9, 10, 13, 16 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 15, 16, 17, 22 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -15 +static const yysigned_char yypact[] = +{ + 0, -14, -1, 3, 21, 21, 21, 16, 23, 21, + 24, 26, 21, 27, -15, 37, 17, -15, -15, -15, + -15, 21, 28, 30, 31, -15, -15, 32, -15, -15, + 33, -15, -15, -15, -15, -15, -15, -15, -15, -15 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -15, -15, -15, 35, 29 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const yysigned_char yytable[] = +{ + -3, 1, 18, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 19, 14, -2, 1, 20, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 25, 14, 23, 24, 21, 32, 27, 26, + 28, 30, 29, 31, 35, 0, 36, 37, 38, 39, + 34, 33 +}; + +static const yysigned_char yycheck[] = +{ + 0, 1, 16, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 16, 16, 0, 1, 16, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 16, 16, 5, 6, 15, 0, 9, 16, + 16, 12, 16, 16, 16, -1, 16, 16, 16, 16, + 21, 16 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 16, 18, 19, 20, 16, 16, + 16, 15, 21, 21, 21, 16, 16, 21, 16, 16, + 21, 16, 0, 20, 21, 16, 16, 16, 16, 16 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 54 "Grammar.y" + { +;} + break; + + case 3: +#line 57 "Grammar.y" + { +;} + break; + + case 4: +#line 65 "Grammar.y" + { +;} + break; + + case 5: +#line 68 "Grammar.y" + { +;} + break; + + case 6: +#line 76 "Grammar.y" + { + parser->usage(); +;} + break; + + case 7: +#line 80 "Grammar.y" + { + return 0; +;} + break; + + case 8: +#line 84 "Grammar.y" + { + parser->addBook(yyvsp[-1]); +;} + break; + + case 9: +#line 88 "Grammar.y" + { + parser->findIsbn(yyvsp[-1]); +;} + break; + + case 10: +#line 92 "Grammar.y" + { + parser->findAuthors(yyvsp[-1]); +;} + break; + + case 11: +#line 96 "Grammar.y" + { + parser->nextFoundBook(); +;} + break; + + case 12: +#line 100 "Grammar.y" + { + parser->printCurrent(); +;} + break; + + case 13: +#line 104 "Grammar.y" + { + parser->rentCurrent(yyvsp[-1]); +;} + break; + + case 14: +#line 108 "Grammar.y" + { + parser->returnCurrent(); +;} + break; + + case 15: +#line 112 "Grammar.y" + { + parser->removeCurrent(); +;} + break; + + case 16: +#line 116 "Grammar.y" + { + parser->setEvictorSize(yyvsp[-1]); +;} + break; + + case 17: +#line 120 "Grammar.y" + { + parser->shutdown(); +;} + break; + + case 18: +#line 124 "Grammar.y" + { + yyerrok; +;} + break; + + case 19: +#line 128 "Grammar.y" + { +;} + break; + + case 20: +#line 136 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 21: +#line 141 "Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 1192 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 146 "Grammar.y" + + diff --git a/cpp/demo/Freeze/library/Grammar.h b/cpp/demo/Freeze/library/Grammar.h new file mode 100644 index 00000000000..ec2ea905438 --- /dev/null +++ b/cpp/demo/Freeze/library/Grammar.h @@ -0,0 +1,74 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_ADD_BOOK = 260, + TOK_FIND_ISBN = 261, + TOK_FIND_AUTHORS = 262, + TOK_NEXT_FOUND_BOOK = 263, + TOK_PRINT_CURRENT = 264, + TOK_RENT_BOOK = 265, + TOK_RETURN_BOOK = 266, + TOK_REMOVE_CURRENT = 267, + TOK_SET_EVICTOR_SIZE = 268, + TOK_SHUTDOWN = 269, + TOK_STRING = 270 + }; +#endif +#define TOK_HELP 258 +#define TOK_EXIT 259 +#define TOK_ADD_BOOK 260 +#define TOK_FIND_ISBN 261 +#define TOK_FIND_AUTHORS 262 +#define TOK_NEXT_FOUND_BOOK 263 +#define TOK_PRINT_CURRENT 264 +#define TOK_RENT_BOOK 265 +#define TOK_RETURN_BOOK 266 +#define TOK_REMOVE_CURRENT 267 +#define TOK_SET_EVICTOR_SIZE 268 +#define TOK_SHUTDOWN 269 +#define TOK_STRING 270 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/demo/Freeze/library/Makefile b/cpp/demo/Freeze/library/Makefile index e5c76e89020..2e7fc5deb22 100644 --- a/cpp/demo/Freeze/library/Makefile +++ b/cpp/demo/Freeze/library/Makefile @@ -68,7 +68,5 @@ LibraryTypes.h LibraryTypes.cpp: Library.ice $(SLICE2FREEZE) $(SLICEPARSERLIB) clean:: -rm -f db/* -rm -f LibraryTypes.h LibraryTypes.cpp - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp include .depend diff --git a/cpp/demo/Freeze/library/Makefile.mak b/cpp/demo/Freeze/library/Makefile.mak index 14aaefa8364..6f6011eb4f4 100644 --- a/cpp/demo/Freeze/library/Makefile.mak +++ b/cpp/demo/Freeze/library/Makefile.mak @@ -91,8 +91,6 @@ clean:: clean:: -del /q LibraryTypes.h LibraryTypes.cpp - -del /q Grammar.cpp Grammar.h - -del /q Scanner.cpp -for %f in (db\*) do if not %f == db\.gitignore del /q %f !include .depend diff --git a/cpp/demo/Freeze/library/Scanner.cpp b/cpp/demo/Freeze/library/Scanner.cpp new file mode 100644 index 00000000000..a42d02830e7 --- /dev/null +++ b/cpp/demo/Freeze/library/Scanner.cpp @@ -0,0 +1,1845 @@ +#include +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 20 +#define YY_END_OF_BUFFER 21 +static yyconst short int yy_accept[77] = + { 0, + 15, 15, 21, 19, 15, 16, 17, 18, 19, 16, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 15, 0, 2, 1, 0, 15, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 4, 3, 6, 8, 0, 10, 0, 0, + 13, 0, 0, 0, 0, 0, 0, 0, 12, 11, + 0, 7, 9, 0, 14, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 1, + 1, 6, 1, 1, 1, 1, 7, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 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, 9, 1, 1, 1, 1, 10, 11, 12, 13, + + 14, 1, 1, 15, 16, 1, 1, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 1, 30, 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, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[31] = + { 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 + } ; + +static yyconst short int yy_base[77] = + { 0, + 0, 0, 93, 94, 29, 94, 94, 94, 26, 94, + 32, 23, 66, 62, 76, 65, 74, 61, 72, 24, + 35, 39, 94, 94, 43, 94, 72, 59, 60, 66, + 64, 69, 50, 62, 29, 51, 46, 94, 60, 51, + 48, 51, 52, 45, 44, 48, 42, 40, 40, 50, + 43, 48, 94, 94, 94, 94, 34, 94, 37, 46, + 94, 35, 38, 42, 36, 33, 28, 26, 94, 94, + 22, 94, 94, 24, 94, 94 + } ; + +static yyconst short int yy_def[77] = + { 0, + 76, 1, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 0 + } ; + +static yyconst short int yy_nxt[125] = + { 0, + 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, + 4, 13, 4, 14, 15, 16, 4, 4, 17, 4, + 4, 18, 19, 20, 4, 4, 4, 4, 4, 4, + 21, 23, 24, 25, 26, 27, 21, 22, 36, 37, + 25, 26, 75, 22, 25, 26, 46, 47, 28, 74, + 73, 72, 71, 48, 70, 69, 68, 67, 66, 65, + 64, 63, 62, 61, 60, 59, 58, 57, 53, 56, + 55, 54, 53, 52, 51, 50, 49, 45, 44, 43, + 42, 41, 40, 39, 38, 35, 34, 33, 32, 31, + 30, 29, 76, 3, 76, 76, 76, 76, 76, 76, + + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76 + } ; + +static yyconst short int yy_chk[125] = + { 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, + 5, 9, 9, 11, 11, 12, 21, 5, 20, 20, + 22, 22, 74, 21, 25, 25, 35, 35, 12, 71, + 68, 67, 66, 35, 65, 64, 63, 62, 60, 59, + 57, 52, 51, 50, 49, 48, 47, 46, 45, 44, + 43, 42, 41, 40, 39, 37, 36, 34, 33, 32, + 31, 30, 29, 28, 27, 19, 18, 17, 16, 15, + 14, 13, 3, 76, 76, 76, 76, 76, 76, 76, + + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; + +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) + +#define YY_ALWAYS_INTERACTIVE 1 +#line 442 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 35 "Scanner.l" + + +#line 596 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 77 ) + 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_base[yy_current_state] != 94 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 37 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 47 "Scanner.l" +{ + // C-style comment + while(true) + { + int c = yyinput(); + if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + unput(next); + } + } + else if(c == EOF) + { + parser->warning("EOF in comment"); + break; + } + } +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 72 "Scanner.l" +{ + return TOK_HELP; +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 76 "Scanner.l" +{ + return TOK_EXIT; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 80 "Scanner.l" +{ + return TOK_ADD_BOOK; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 84 "Scanner.l" +{ + return TOK_FIND_ISBN; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 88 "Scanner.l" +{ + return TOK_FIND_AUTHORS; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 92 "Scanner.l" +{ + return TOK_NEXT_FOUND_BOOK; +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 96 "Scanner.l" +{ + return TOK_PRINT_CURRENT; +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 100 "Scanner.l" +{ + return TOK_RENT_BOOK; +} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 104 "Scanner.l" +{ + return TOK_RETURN_BOOK; +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 108 "Scanner.l" +{ + return TOK_REMOVE_CURRENT; +} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 112 "Scanner.l" +{ + return TOK_SET_EVICTOR_SIZE; +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 116 "Scanner.l" +{ + return TOK_SHUTDOWN; +} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 120 "Scanner.l" +{ + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) + { + if(yytext[i] == '\\') + { + parser->continueLine(); + } + } +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 131 "Scanner.l" +{ + return ';'; +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 135 "Scanner.l" +{ + // "..."-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '"') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + switch(next) + { + case '\\': + case '"': + { + s += next; + break; + } + + case 'n': + { + s += '\n'; + break; + } + + case 'r': + { + s += '\r'; + break; + } + + case 't': + { + s += '\t'; + break; + } + + case 'v': + { + s += '\v'; + break; + } + + case 'f': + { + s += '\f'; + break; + } + + default: + { + s += c; + unput(next); + } + } + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 209 "Scanner.l" +{ + // '...'-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '\'') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 234 "Scanner.l" +{ + // Simple strings + string s; + s += yytext[0]; + while(true) + { + char c = static_cast(yyinput()); + if(c == EOF) + { + break; + } + else if(isspace(c) || c == ';') + { + unput(c); + break; + } + + s += c; + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 258 "Scanner.l" +ECHO; + YY_BREAK +#line 962 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 77 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 77 ) + 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 == 76); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 258 "Scanner.l" + diff --git a/cpp/demo/Freeze/phonebook/.gitignore b/cpp/demo/Freeze/phonebook/.gitignore index b576b1ccfb9..dcd6a06b5ab 100644 --- a/cpp/demo/Freeze/phonebook/.gitignore +++ b/cpp/demo/Freeze/phonebook/.gitignore @@ -8,7 +8,4 @@ PhoneBook.cpp PhoneBook.h NameIndex.h NameIndex.cpp -Grammar.cpp -Grammar.h -Scanner.cpp db/* diff --git a/cpp/demo/Freeze/phonebook/Grammar.cpp b/cpp/demo/Freeze/phonebook/Grammar.cpp new file mode 100644 index 00000000000..6aa19c49770 --- /dev/null +++ b/cpp/demo/Freeze/phonebook/Grammar.cpp @@ -0,0 +1,1422 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_ADD_CONTACTS = 260, + TOK_FIND_CONTACTS = 261, + TOK_NEXT_FOUND_CONTACT = 262, + TOK_PRINT_CURRENT = 263, + TOK_SET_CURRENT_NAME = 264, + TOK_SET_CURRENT_ADDRESS = 265, + TOK_SET_CURRENT_PHONE = 266, + TOK_REMOVE_CURRENT = 267, + TOK_SET_EVICTOR_SIZE = 268, + TOK_SHUTDOWN = 269, + TOK_STRING = 270 + }; +#endif +#define TOK_HELP 258 +#define TOK_EXIT 259 +#define TOK_ADD_CONTACTS 260 +#define TOK_FIND_CONTACTS 261 +#define TOK_NEXT_FOUND_CONTACT 262 +#define TOK_PRINT_CURRENT 263 +#define TOK_SET_CURRENT_NAME 264 +#define TOK_SET_CURRENT_ADDRESS 265 +#define TOK_SET_CURRENT_PHONE 266 +#define TOK_REMOVE_CURRENT 267 +#define TOK_SET_EVICTOR_SIZE 268 +#define TOK_SHUTDOWN 269 +#define TOK_STRING 270 + + + + +/* Copy the first part of user declarations. */ +#line 1 "Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; +using namespace Ice; + +void +yyerror(const char* s) +{ + parser->error(s); +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 149 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 32 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 51 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 17 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 5 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 21 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 41 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 270 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 16, + 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 6, 9, 11, 14, 17, 21, + 25, 28, 31, 35, 39, 43, 46, 50, 53, 56, + 58, 61 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 18, 0, -1, 19, -1, -1, 19, 20, -1, 20, + -1, 3, 16, -1, 4, 16, -1, 5, 21, 16, + -1, 6, 21, 16, -1, 7, 16, -1, 8, 16, + -1, 9, 21, 16, -1, 10, 21, 16, -1, 11, + 21, 16, -1, 12, 16, -1, 13, 21, 16, -1, + 14, 16, -1, 1, 16, -1, 16, -1, 15, 21, + -1, 15, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 54, 54, 58, 65, 68, 76, 80, 84, 88, + 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, + 136, 141 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_HELP", "TOK_EXIT", + "TOK_ADD_CONTACTS", "TOK_FIND_CONTACTS", "TOK_NEXT_FOUND_CONTACT", + "TOK_PRINT_CURRENT", "TOK_SET_CURRENT_NAME", "TOK_SET_CURRENT_ADDRESS", + "TOK_SET_CURRENT_PHONE", "TOK_REMOVE_CURRENT", "TOK_SET_EVICTOR_SIZE", + "TOK_SHUTDOWN", "TOK_STRING", "';'", "$accept", "start", "commands", + "command", "strings", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 17, 18, 18, 19, 19, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 21, 21 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 0, 2, 1, 2, 2, 3, 3, + 2, 2, 3, 3, 3, 2, 3, 2, 2, 1, + 2, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 0, 0, 5, 18, 6, + 7, 21, 0, 0, 10, 11, 0, 0, 0, 15, + 0, 17, 1, 4, 20, 8, 9, 12, 13, 14, + 16 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 15, 16, 17, 22 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -15 +static const yysigned_char yypact[] = +{ + 0, -14, -1, 3, 19, 19, 22, 24, 19, 19, + 19, 25, 19, 26, -15, 43, 17, -15, -15, -15, + -15, 19, 28, 29, -15, -15, 30, 31, 33, -15, + 34, -15, -15, -15, -15, -15, -15, -15, -15, -15, + -15 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -15, -15, -15, 35, 27 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const yysigned_char yytable[] = +{ + -3, 1, 18, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 19, 14, -2, 1, 20, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 23, 14, 21, 26, 27, 28, 24, 30, + 25, 29, 31, 32, 35, 36, 37, 38, 34, 39, + 40, 33 +}; + +static const unsigned char yycheck[] = +{ + 0, 1, 16, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 16, 16, 0, 1, 16, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 5, 16, 15, 8, 9, 10, 16, 12, + 16, 16, 16, 0, 16, 16, 16, 16, 21, 16, + 16, 16 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 16, 18, 19, 20, 16, 16, + 16, 15, 21, 21, 16, 16, 21, 21, 21, 16, + 21, 16, 0, 20, 21, 16, 16, 16, 16, 16, + 16 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 55 "Grammar.y" + { +;} + break; + + case 3: +#line 58 "Grammar.y" + { +;} + break; + + case 4: +#line 66 "Grammar.y" + { +;} + break; + + case 5: +#line 69 "Grammar.y" + { +;} + break; + + case 6: +#line 77 "Grammar.y" + { + parser->usage(); +;} + break; + + case 7: +#line 81 "Grammar.y" + { + return 0; +;} + break; + + case 8: +#line 85 "Grammar.y" + { + parser->addContacts(yyvsp[-1]); +;} + break; + + case 9: +#line 89 "Grammar.y" + { + parser->findContacts(yyvsp[-1]); +;} + break; + + case 10: +#line 93 "Grammar.y" + { + parser->nextFoundContact(); +;} + break; + + case 11: +#line 97 "Grammar.y" + { + parser->printCurrent(); +;} + break; + + case 12: +#line 101 "Grammar.y" + { + parser->setCurrentName(yyvsp[-1]); +;} + break; + + case 13: +#line 105 "Grammar.y" + { + parser->setCurrentAddress(yyvsp[-1]); +;} + break; + + case 14: +#line 109 "Grammar.y" + { + parser->setCurrentPhone(yyvsp[-1]); +;} + break; + + case 15: +#line 113 "Grammar.y" + { + parser->removeCurrent(); +;} + break; + + case 16: +#line 117 "Grammar.y" + { + parser->setEvictorSize(yyvsp[-1]); +;} + break; + + case 17: +#line 121 "Grammar.y" + { + parser->shutdown(); +;} + break; + + case 18: +#line 125 "Grammar.y" + { + yyerrok; +;} + break; + + case 19: +#line 129 "Grammar.y" + { +;} + break; + + case 20: +#line 137 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 21: +#line 142 "Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 1196 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 147 "Grammar.y" + + diff --git a/cpp/demo/Freeze/phonebook/Grammar.h b/cpp/demo/Freeze/phonebook/Grammar.h new file mode 100644 index 00000000000..076fe968167 --- /dev/null +++ b/cpp/demo/Freeze/phonebook/Grammar.h @@ -0,0 +1,74 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_ADD_CONTACTS = 260, + TOK_FIND_CONTACTS = 261, + TOK_NEXT_FOUND_CONTACT = 262, + TOK_PRINT_CURRENT = 263, + TOK_SET_CURRENT_NAME = 264, + TOK_SET_CURRENT_ADDRESS = 265, + TOK_SET_CURRENT_PHONE = 266, + TOK_REMOVE_CURRENT = 267, + TOK_SET_EVICTOR_SIZE = 268, + TOK_SHUTDOWN = 269, + TOK_STRING = 270 + }; +#endif +#define TOK_HELP 258 +#define TOK_EXIT 259 +#define TOK_ADD_CONTACTS 260 +#define TOK_FIND_CONTACTS 261 +#define TOK_NEXT_FOUND_CONTACT 262 +#define TOK_PRINT_CURRENT 263 +#define TOK_SET_CURRENT_NAME 264 +#define TOK_SET_CURRENT_ADDRESS 265 +#define TOK_SET_CURRENT_PHONE 266 +#define TOK_REMOVE_CURRENT 267 +#define TOK_SET_EVICTOR_SIZE 268 +#define TOK_SHUTDOWN 269 +#define TOK_STRING 270 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/demo/Freeze/phonebook/Makefile b/cpp/demo/Freeze/phonebook/Makefile index f4f2dd9e382..89993a02c82 100644 --- a/cpp/demo/Freeze/phonebook/Makefile +++ b/cpp/demo/Freeze/phonebook/Makefile @@ -67,8 +67,6 @@ NameIndex.h NameIndex.cpp: PhoneBook.ice $(SLICE2FREEZE) $(SLICEPARSERLIB) clean:: -rm -f NameIndex.h NameIndex.cpp - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp -rm -f db/* include .depend diff --git a/cpp/demo/Freeze/phonebook/Makefile.mak b/cpp/demo/Freeze/phonebook/Makefile.mak index 018abf81ec3..c9a5ef28d78 100644 --- a/cpp/demo/Freeze/phonebook/Makefile.mak +++ b/cpp/demo/Freeze/phonebook/Makefile.mak @@ -90,8 +90,6 @@ clean:: clean:: -del /q NameIndex.h NameIndex.cpp - -del /q Grammar.cpp Grammar.h - -del /q Scanner.cpp -for %f in (db\*) do if not %f == db\.gitignore del /q %f !include .depend diff --git a/cpp/demo/Freeze/phonebook/Scanner.cpp b/cpp/demo/Freeze/phonebook/Scanner.cpp new file mode 100644 index 00000000000..b66053b29ae --- /dev/null +++ b/cpp/demo/Freeze/phonebook/Scanner.cpp @@ -0,0 +1,1845 @@ +#include +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 20 +#define YY_END_OF_BUFFER 21 +static yyconst short int yy_accept[77] = + { 0, + 15, 15, 21, 19, 15, 16, 17, 18, 19, 16, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 15, 0, 2, 1, 0, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 4, 6, 3, 9, 7, 0, 0, + 0, 13, 0, 0, 11, 0, 0, 0, 0, 12, + 0, 10, 8, 0, 14, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 1, + 1, 6, 1, 1, 1, 1, 7, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 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, 9, 1, 1, 1, 1, 10, 1, 11, 12, + + 13, 14, 1, 15, 16, 1, 1, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 1, 30, 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, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[31] = + { 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 + } ; + +static yyconst short int yy_base[77] = + { 0, + 0, 0, 92, 93, 29, 93, 93, 93, 26, 93, + 32, 79, 64, 60, 72, 74, 26, 71, 59, 71, + 25, 35, 40, 93, 93, 43, 93, 71, 59, 65, + 61, 62, 60, 48, 56, 59, 56, 47, 42, 48, + 47, 44, 56, 46, 53, 40, 45, 38, 42, 36, + 47, 46, 45, 93, 93, 93, 93, 93, 44, 29, + 43, 93, 30, 34, 93, 39, 31, 26, 24, 93, + 20, 93, 93, 28, 93, 93 + } ; + +static yyconst short int yy_def[77] = + { 0, + 76, 1, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 0 + } ; + +static yyconst short int yy_nxt[124] = + { 0, + 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, + 13, 4, 14, 15, 16, 4, 4, 4, 17, 4, + 18, 19, 20, 21, 4, 4, 4, 4, 4, 4, + 22, 24, 25, 26, 27, 33, 22, 23, 34, 38, + 39, 26, 27, 23, 26, 27, 75, 74, 73, 72, + 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, + 61, 60, 54, 59, 58, 57, 56, 55, 54, 53, + 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, + 42, 41, 40, 37, 36, 35, 32, 31, 30, 29, + 28, 76, 3, 76, 76, 76, 76, 76, 76, 76, + + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76 + } ; + +static yyconst short int yy_chk[124] = + { 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, + 5, 9, 9, 11, 11, 17, 22, 5, 17, 21, + 21, 23, 23, 22, 26, 26, 74, 71, 69, 68, + 67, 66, 64, 63, 61, 60, 59, 53, 52, 51, + 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, + 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, + 30, 29, 28, 20, 19, 18, 16, 15, 14, 13, + 12, 3, 76, 76, 76, 76, 76, 76, 76, 76, + + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; + +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) + +#define YY_ALWAYS_INTERACTIVE 1 +#line 442 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 35 "Scanner.l" + + +#line 596 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 77 ) + 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_base[yy_current_state] != 93 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 37 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 47 "Scanner.l" +{ + // C-style comment + while(true) + { + int c = yyinput(); + if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + unput(next); + } + } + else if(c == EOF) + { + parser->warning("EOF in comment"); + break; + } + } +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 72 "Scanner.l" +{ + return TOK_HELP; +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 76 "Scanner.l" +{ + return TOK_EXIT; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 80 "Scanner.l" +{ + return TOK_ADD_CONTACTS; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 84 "Scanner.l" +{ + return TOK_FIND_CONTACTS; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 88 "Scanner.l" +{ + return TOK_NEXT_FOUND_CONTACT; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 92 "Scanner.l" +{ + return TOK_PRINT_CURRENT; +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 96 "Scanner.l" +{ + return TOK_SET_CURRENT_NAME; +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 100 "Scanner.l" +{ + return TOK_SET_CURRENT_ADDRESS; +} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 104 "Scanner.l" +{ + return TOK_SET_CURRENT_PHONE; +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 108 "Scanner.l" +{ + return TOK_REMOVE_CURRENT; +} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 112 "Scanner.l" +{ + return TOK_SET_EVICTOR_SIZE; +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 116 "Scanner.l" +{ + return TOK_SHUTDOWN; +} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 120 "Scanner.l" +{ + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) + { + if(yytext[i] == '\\') + { + parser->continueLine(); + } + } +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 131 "Scanner.l" +{ + return ';'; +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 135 "Scanner.l" +{ + // "..."-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '"') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + switch(next) + { + case '\\': + case '"': + { + s += next; + break; + } + + case 'n': + { + s += '\n'; + break; + } + + case 'r': + { + s += '\r'; + break; + } + + case 't': + { + s += '\t'; + break; + } + + case 'v': + { + s += '\v'; + break; + } + + case 'f': + { + s += '\f'; + break; + } + + default: + { + s += c; + unput(next); + } + } + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 209 "Scanner.l" +{ + // '...'-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '\'') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 234 "Scanner.l" +{ + // Simple strings + string s; + s += yytext[0]; + while(true) + { + char c = static_cast(yyinput()); + if(c == EOF) + { + break; + } + else if(isspace(c) || c == ';') + { + unput(c); + break; + } + + s += c; + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 258 "Scanner.l" +ECHO; + YY_BREAK +#line 962 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 77 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 77 ) + 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 == 76); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 258 "Scanner.l" + diff --git a/cpp/demo/book/freeze_filesystem/.gitignore b/cpp/demo/book/freeze_filesystem/.gitignore index 7d2b8d0a9ea..7c81ab1ce91 100644 --- a/cpp/demo/book/freeze_filesystem/.gitignore +++ b/cpp/demo/book/freeze_filesystem/.gitignore @@ -8,6 +8,3 @@ PersistentFilesystem.cpp Filesystem.h PersistentFilesystem.h db/* -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/demo/book/freeze_filesystem/Makefile b/cpp/demo/book/freeze_filesystem/Makefile index 724419b3747..31cbf347222 100644 --- a/cpp/demo/book/freeze_filesystem/Makefile +++ b/cpp/demo/book/freeze_filesystem/Makefile @@ -44,7 +44,5 @@ $(SERVER): $(OBJS) $(SOBJS) clean:: -rm -f db/* - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp include .depend diff --git a/cpp/demo/book/lifecycle/.gitignore b/cpp/demo/book/lifecycle/.gitignore index 5f489ba756a..a0bd7a59dd3 100644 --- a/cpp/demo/book/lifecycle/.gitignore +++ b/cpp/demo/book/lifecycle/.gitignore @@ -5,6 +5,3 @@ client server Filesystem.cpp Filesystem.h -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/demo/book/lifecycle/Grammar.cpp b/cpp/demo/book/lifecycle/Grammar.cpp new file mode 100644 index 00000000000..8e5d9b010ba --- /dev/null +++ b/cpp/demo/book/lifecycle/Grammar.cpp @@ -0,0 +1,1408 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_STRING = 260, + TOK_LIST = 261, + TOK_LIST_RECURSIVE = 262, + TOK_CREATE_FILE = 263, + TOK_CREATE_DIR = 264, + TOK_PWD = 265, + TOK_CD = 266, + TOK_CAT = 267, + TOK_WRITE = 268, + TOK_RM = 269 + }; +#endif +#define TOK_HELP 258 +#define TOK_EXIT 259 +#define TOK_STRING 260 +#define TOK_LIST 261 +#define TOK_LIST_RECURSIVE 262 +#define TOK_CREATE_FILE 263 +#define TOK_CREATE_DIR 264 +#define TOK_PWD 265 +#define TOK_CD 266 +#define TOK_CAT 267 +#define TOK_WRITE 268 +#define TOK_RM 269 + + + + +/* Copy the first part of user declarations. */ +#line 1 "Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; + +void +yyerror(const char* s) +{ + parser->error(s); +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 146 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 27 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 45 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 16 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 5 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 21 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 30 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 269 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 15, + 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 6, 9, 11, 14, 17, 19, + 21, 24, 27, 29, 31, 34, 37, 40, 43, 46, + 48, 51 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 17, 0, -1, 18, -1, -1, 18, 19, -1, 19, + -1, 3, 15, -1, 4, 15, -1, 6, -1, 7, + -1, 8, 20, -1, 9, 20, -1, 10, -1, 11, + -1, 11, 20, -1, 12, 5, -1, 13, 20, -1, + 14, 20, -1, 1, 15, -1, 15, -1, 5, 20, + -1, 5, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 52, 52, 56, 63, 66, 74, 78, 82, 86, + 90, 94, 98, 102, 106, 110, 114, 118, 122, 127, + 135, 140 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_HELP", "TOK_EXIT", "TOK_STRING", + "TOK_LIST", "TOK_LIST_RECURSIVE", "TOK_CREATE_FILE", "TOK_CREATE_DIR", + "TOK_PWD", "TOK_CD", "TOK_CAT", "TOK_WRITE", "TOK_RM", "';'", "$accept", + "start", "commands", "command", "strings", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 16, 17, 17, 18, 18, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 20, 20 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 0, 2, 1, 2, 2, 1, 1, + 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, + 2, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 0, 0, 8, 9, 0, 0, 12, 13, + 0, 0, 0, 19, 0, 0, 5, 18, 6, 7, + 21, 10, 11, 14, 15, 16, 17, 1, 4, 20 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 14, 15, 16, 21 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -14 +static const yysigned_char yypact[] = +{ + 0, -13, -10, 3, -14, -14, 28, 28, -14, 28, + 30, 28, 28, -14, 21, 16, -14, -14, -14, -14, + 28, -14, -14, -14, -14, -14, -14, -14, -14, -14 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -14, -14, -14, 23, 25 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const yysigned_char yytable[] = +{ + -3, 1, 17, 2, 3, 18, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, -2, 1, 19, 2, + 3, 27, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 22, 20, 23, 24, 25, 26, 28, 0, + 0, 0, 0, 0, 0, 29 +}; + +static const yysigned_char yycheck[] = +{ + 0, 1, 15, 3, 4, 15, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 0, 1, 15, 3, + 4, 0, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 7, 5, 9, 5, 11, 12, 15, -1, + -1, -1, -1, -1, -1, 20 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 1, 3, 4, 6, 7, 8, 9, 10, 11, + 12, 13, 14, 15, 17, 18, 19, 15, 15, 15, + 5, 20, 20, 20, 5, 20, 20, 0, 19, 20 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 53 "Grammar.y" + { +;} + break; + + case 3: +#line 56 "Grammar.y" + { +;} + break; + + case 4: +#line 64 "Grammar.y" + { +;} + break; + + case 5: +#line 67 "Grammar.y" + { +;} + break; + + case 6: +#line 75 "Grammar.y" + { + parser->usage(); +;} + break; + + case 7: +#line 79 "Grammar.y" + { + return 0; +;} + break; + + case 8: +#line 83 "Grammar.y" + { + parser->list(false); +;} + break; + + case 9: +#line 87 "Grammar.y" + { + parser->list(true); +;} + break; + + case 10: +#line 91 "Grammar.y" + { + parser->createFile(yyvsp[0]); +;} + break; + + case 11: +#line 95 "Grammar.y" + { + parser->createDir(yyvsp[0]); +;} + break; + + case 12: +#line 99 "Grammar.y" + { + parser->pwd(); +;} + break; + + case 13: +#line 103 "Grammar.y" + { + parser->cd("/"); +;} + break; + + case 14: +#line 107 "Grammar.y" + { + parser->cd(yyvsp[0].front()); +;} + break; + + case 15: +#line 111 "Grammar.y" + { + parser->cat(yyvsp[0].front()); +;} + break; + + case 16: +#line 115 "Grammar.y" + { + parser->write(yyvsp[0]); +;} + break; + + case 17: +#line 119 "Grammar.y" + { + parser->destroy(yyvsp[0]); +;} + break; + + case 18: +#line 123 "Grammar.y" + { + parser->usage(); + yyerrok; +;} + break; + + case 19: +#line 128 "Grammar.y" + { +;} + break; + + case 20: +#line 136 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 21: +#line 141 "Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 1182 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 146 "Grammar.y" + + diff --git a/cpp/demo/book/lifecycle/Grammar.h b/cpp/demo/book/lifecycle/Grammar.h new file mode 100644 index 00000000000..d90f2d43183 --- /dev/null +++ b/cpp/demo/book/lifecycle/Grammar.h @@ -0,0 +1,72 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_STRING = 260, + TOK_LIST = 261, + TOK_LIST_RECURSIVE = 262, + TOK_CREATE_FILE = 263, + TOK_CREATE_DIR = 264, + TOK_PWD = 265, + TOK_CD = 266, + TOK_CAT = 267, + TOK_WRITE = 268, + TOK_RM = 269 + }; +#endif +#define TOK_HELP 258 +#define TOK_EXIT 259 +#define TOK_STRING 260 +#define TOK_LIST 261 +#define TOK_LIST_RECURSIVE 262 +#define TOK_CREATE_FILE 263 +#define TOK_CREATE_DIR 264 +#define TOK_PWD 265 +#define TOK_CD 266 +#define TOK_CAT 267 +#define TOK_WRITE 268 +#define TOK_RM 269 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/demo/book/lifecycle/Makefile b/cpp/demo/book/lifecycle/Makefile index 8e590235918..cf5ee6a1c7b 100644 --- a/cpp/demo/book/lifecycle/Makefile +++ b/cpp/demo/book/lifecycle/Makefile @@ -43,8 +43,4 @@ $(SERVER): $(OBJS) $(SOBJS) rm -f $@ $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SOBJS) $(DB_RPATH_LINK) $(LIBS) -clean:: - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp - include .depend diff --git a/cpp/demo/book/lifecycle/Makefile.mak b/cpp/demo/book/lifecycle/Makefile.mak index a4b3084c913..7828da700c3 100644 --- a/cpp/demo/book/lifecycle/Makefile.mak +++ b/cpp/demo/book/lifecycle/Makefile.mak @@ -63,7 +63,5 @@ Grammar.cpp Grammar.h: Grammar.y clean:: -del /q Filesystem.cpp Filesystem.h - -del /q Scanner.cpp Scanner.h - -del /q Grammar.cpp Grammar.h !include .depend diff --git a/cpp/demo/book/lifecycle/Scanner.cpp b/cpp/demo/book/lifecycle/Scanner.cpp new file mode 100644 index 00000000000..6cc5ce4d919 --- /dev/null +++ b/cpp/demo/book/lifecycle/Scanner.cpp @@ -0,0 +1,1826 @@ +#include +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 19 +#define YY_END_OF_BUFFER 20 +static yyconst short int yy_accept[56] = + { 0, + 14, 14, 20, 18, 14, 15, 16, 17, 18, 15, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 14, 0, 2, 1, 0, 14, 0, 10, 0, 0, + 6, 5, 0, 0, 0, 13, 0, 11, 0, 0, + 0, 0, 9, 0, 0, 4, 3, 0, 0, 0, + 8, 0, 12, 7, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 1, + 1, 6, 1, 1, 1, 1, 7, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 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, 9, 1, 1, 1, 1, 10, 1, 11, 12, + + 13, 14, 1, 15, 16, 1, 17, 18, 19, 1, + 1, 20, 21, 22, 23, 24, 25, 1, 26, 27, + 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, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[28] = + { 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 + } ; + +static yyconst short int yy_base[56] = + { 0, + 0, 0, 69, 70, 26, 70, 70, 70, 23, 70, + 29, 24, 41, 54, 15, 49, 39, 39, 44, 40, + 31, 39, 70, 70, 41, 70, 37, 70, 44, 41, + 70, 70, 33, 46, 41, 70, 40, 70, 31, 34, + 37, 36, 70, 27, 26, 70, 70, 27, 30, 33, + 70, 26, 70, 70, 70 + } ; + +static yyconst short int yy_def[56] = + { 0, + 55, 1, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 0 + } ; + +static yyconst short int yy_nxt[98] = + { 0, + 4, 5, 6, 7, 8, 4, 9, 10, 11, 4, + 12, 4, 13, 4, 14, 4, 4, 15, 16, 17, + 18, 19, 4, 4, 4, 20, 4, 21, 23, 24, + 25, 26, 21, 27, 22, 28, 31, 32, 54, 22, + 25, 26, 25, 26, 41, 53, 42, 52, 51, 50, + 46, 49, 48, 47, 46, 45, 44, 43, 40, 39, + 38, 37, 36, 35, 34, 33, 30, 29, 55, 3, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55 + + } ; + +static yyconst short int yy_chk[98] = + { 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, 5, 9, 9, + 11, 11, 21, 12, 5, 12, 15, 15, 52, 21, + 22, 22, 25, 25, 33, 50, 33, 49, 48, 45, + 44, 42, 41, 40, 39, 37, 35, 34, 30, 29, + 27, 20, 19, 18, 17, 16, 14, 13, 3, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + 55, 55, 55, 55, 55, 55, 55 + + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; + +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) + +#define YY_ALWAYS_INTERACTIVE 1 +#line 430 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 35 "Scanner.l" + + +#line 584 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 56 ) + 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_base[yy_current_state] != 70 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 37 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 47 "Scanner.l" +{ + // C-style comment + while(true) + { + int c = yyinput(); + if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + unput(next); + } + } + else if(c == EOF) + { + parser->warning("EOF in comment"); + break; + } + } +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 72 "Scanner.l" +{ + return TOK_HELP; +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 76 "Scanner.l" +{ + return TOK_EXIT; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 80 "Scanner.l" +{ + return TOK_LIST; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 84 "Scanner.l" +{ + return TOK_LIST_RECURSIVE; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 88 "Scanner.l" +{ + return TOK_CREATE_FILE; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 92 "Scanner.l" +{ + return TOK_CREATE_DIR; +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 96 "Scanner.l" +{ + return TOK_PWD; +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 100 "Scanner.l" +{ + return TOK_CD; +} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 104 "Scanner.l" +{ + return TOK_CAT; +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 108 "Scanner.l" +{ + return TOK_WRITE; +} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 112 "Scanner.l" +{ + return TOK_RM; +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 116 "Scanner.l" +{ + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) + { + if(yytext[i] == '\\') + { + parser->continueLine(); + } + } +} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 127 "Scanner.l" +{ + return ';'; +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 131 "Scanner.l" +{ + // "..."-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '"') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + switch(next) + { + case '\\': + case '"': + { + s += next; + break; + } + + case 'n': + { + s += '\n'; + break; + } + + case 'r': + { + s += '\r'; + break; + } + + case 't': + { + s += '\t'; + break; + } + + case 'v': + { + s += '\v'; + break; + } + + case 'f': + { + s += '\f'; + break; + } + + default: + { + s += c; + unput(next); + } + } + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 205 "Scanner.l" +{ + // '...'-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '\'') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 230 "Scanner.l" +{ + // Simple strings + string s; + s += yytext[0]; + while(true) + { + char c = static_cast(yyinput()); + if(c == EOF) + { + break; + } + else if(isspace(c) || c == ';') + { + unput(c); + break; + } + + s += c; + } + yylvalp->clear(); + yylvalp->push_back(s); + return TOK_STRING; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 254 "Scanner.l" +ECHO; + YY_BREAK +#line 943 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 56 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 56 ) + 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 == 55); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 254 "Scanner.l" + diff --git a/cpp/src/FreezeScript/.gitignore b/cpp/src/FreezeScript/.gitignore deleted file mode 100644 index da581c67fd4..00000000000 --- a/cpp/src/FreezeScript/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -// Generated by makegitignore.py - -// IMPORTANT: Do not edit this file -- any edits made here will be lost! -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/src/FreezeScript/Grammar.cpp b/cpp/src/FreezeScript/Grammar.cpp new file mode 100644 index 00000000000..44df79bb717 --- /dev/null +++ b/cpp/src/FreezeScript/Grammar.cpp @@ -0,0 +1,1674 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* If NAME_PREFIX is specified substitute the variables and functions + names. */ +#define yyparse freeze_script_parse +#define yylex freeze_script_lex +#define yyerror freeze_script_error +#define yylval freeze_script_lval +#define yychar freeze_script_char +#define yydebug freeze_script_debug +#define yynerrs freeze_script_nerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_AND = 258, + TOK_OR = 259, + TOK_NOT = 260, + TOK_ADD = 261, + TOK_SUB = 262, + TOK_MUL = 263, + TOK_DIV = 264, + TOK_MOD = 265, + TOK_LPAREN = 266, + TOK_RPAREN = 267, + TOK_LBRACKET = 268, + TOK_RBRACKET = 269, + TOK_LESS_THAN = 270, + TOK_GREATER_THAN = 271, + TOK_LESS_EQUAL = 272, + TOK_GREATER_EQUAL = 273, + TOK_EQUAL = 274, + TOK_NEQ = 275, + TOK_TRUE = 276, + TOK_FALSE = 277, + TOK_NIL = 278, + TOK_SCOPE_DELIMITER = 279, + TOK_IDENTIFIER = 280, + TOK_STRING_LITERAL = 281, + TOK_INTEGER_LITERAL = 282, + TOK_FLOATING_POINT_LITERAL = 283, + UNARY_OP = 284 + }; +#endif +#define TOK_AND 258 +#define TOK_OR 259 +#define TOK_NOT 260 +#define TOK_ADD 261 +#define TOK_SUB 262 +#define TOK_MUL 263 +#define TOK_DIV 264 +#define TOK_MOD 265 +#define TOK_LPAREN 266 +#define TOK_RPAREN 267 +#define TOK_LBRACKET 268 +#define TOK_RBRACKET 269 +#define TOK_LESS_THAN 270 +#define TOK_GREATER_THAN 271 +#define TOK_LESS_EQUAL 272 +#define TOK_GREATER_EQUAL 273 +#define TOK_EQUAL 274 +#define TOK_NEQ 275 +#define TOK_TRUE 276 +#define TOK_FALSE 277 +#define TOK_NIL 278 +#define TOK_SCOPE_DELIMITER 279 +#define TOK_IDENTIFIER 280 +#define TOK_STRING_LITERAL 281 +#define TOK_INTEGER_LITERAL 282 +#define TOK_FLOATING_POINT_LITERAL 283 +#define UNARY_OP 284 + + + + +/* Copy the first part of user declarations. */ +#line 1 "../FreezeScript/Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; +using namespace FreezeScript; + +void +freeze_script_error(const char* s) +{ + // yacc and recent versions of Bison use "syntax error" instead + // of "parse error". + + if(strcmp(s, "parse error") == 0) + { + parseErrorReporter->expressionSyntaxError("syntax error"); + } + else + { + parseErrorReporter->expressionSyntaxError(s); + } +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 196 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 24 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 111 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 32 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 9 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 39 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 65 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 284 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 31, 2, 30, 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 7, 11, 15, 19, 23, 27, + 31, 35, 39, 43, 47, 51, 55, 59, 61, 65, + 68, 71, 73, 75, 77, 79, 81, 83, 85, 89, + 91, 93, 98, 102, 104, 109, 113, 115, 116, 120 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 33, 0, -1, 34, -1, 35, -1, 35, 15, 35, + -1, 35, 16, 35, -1, 35, 17, 35, -1, 35, + 18, 35, -1, 35, 19, 35, -1, 35, 20, 35, + -1, 35, 4, 35, -1, 35, 3, 35, -1, 35, + 8, 35, -1, 35, 9, 35, -1, 35, 10, 35, + -1, 35, 6, 35, -1, 35, 7, 35, -1, 36, + -1, 11, 34, 12, -1, 7, 36, -1, 5, 36, + -1, 27, -1, 28, -1, 26, -1, 21, -1, 22, + -1, 23, -1, 37, -1, 37, 30, 38, -1, 38, + -1, 40, -1, 37, 13, 34, 14, -1, 37, 30, + 25, -1, 25, -1, 25, 11, 39, 12, -1, 39, + 31, 34, -1, 34, -1, -1, 40, 24, 25, -1, + 24, 25, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 84, 84, 93, 102, 106, 110, 114, 118, 122, + 126, 130, 134, 138, 142, 146, 150, 154, 163, 167, + 171, 175, 181, 187, 193, 197, 201, 205, 209, 218, + 222, 233, 240, 249, 260, 273, 280, 287, 295, 304 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_AND", "TOK_OR", "TOK_NOT", + "TOK_ADD", "TOK_SUB", "TOK_MUL", "TOK_DIV", "TOK_MOD", "TOK_LPAREN", + "TOK_RPAREN", "TOK_LBRACKET", "TOK_RBRACKET", "TOK_LESS_THAN", + "TOK_GREATER_THAN", "TOK_LESS_EQUAL", "TOK_GREATER_EQUAL", "TOK_EQUAL", + "TOK_NEQ", "TOK_TRUE", "TOK_FALSE", "TOK_NIL", "TOK_SCOPE_DELIMITER", + "TOK_IDENTIFIER", "TOK_STRING_LITERAL", "TOK_INTEGER_LITERAL", + "TOK_FLOATING_POINT_LITERAL", "UNARY_OP", "'.'", "','", "$accept", + "start", "expr", "binary", "unary", "entity", "function", "arg_list", + "constant", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 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, + 46, 44 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 32, 33, 34, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, + 36, 37, 37, 37, 38, 39, 39, 39, 40, 40 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 1, 3, 2, + 2, 1, 1, 1, 1, 1, 1, 1, 3, 1, + 1, 4, 3, 1, 4, 3, 1, 0, 3, 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 0, 0, 24, 25, 26, 0, 33, 23, + 21, 22, 0, 2, 3, 17, 27, 29, 30, 20, + 19, 0, 39, 37, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 36, 0, 11, 10, 15, 16, 12, 13, + 14, 4, 5, 6, 7, 8, 9, 0, 32, 28, + 38, 34, 0, 31, 35 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 12, 13, 14, 15, 16, 17, 43, 18 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -20 +static const yysigned_char yypact[] = +{ + 0, 0, 0, 0, -20, -20, -20, -19, 1, -20, + -20, -20, 13, -20, 30, -20, -12, -20, -10, -20, + -20, 3, -20, 0, -20, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -9, + -8, -20, -20, -2, 63, 48, -6, -6, -20, -20, + -20, 78, 78, 78, 78, 78, 78, 5, 1, -20, + -20, -20, 0, -20, -20 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -20, -20, -3, 74, 7, -20, -7, -20, -20 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yysigned_char yytable[] = +{ + 21, 38, 29, 30, 31, 1, 22, 2, 19, 20, + 61, 3, 23, 24, 40, 41, 58, 60, 39, 63, + 42, 4, 5, 6, 7, 8, 9, 10, 11, 62, + 0, 0, 59, 25, 26, 57, 27, 28, 29, 30, + 31, 0, 0, 0, 0, 32, 33, 34, 35, 36, + 37, 25, 0, 0, 27, 28, 29, 30, 31, 64, + 0, 0, 0, 32, 33, 34, 35, 36, 37, 27, + 28, 29, 30, 31, 0, 0, 0, 0, 32, 33, + 34, 35, 36, 37, 27, 28, 29, 30, 31, 0, + 0, 0, 0, -1, -1, -1, -1, -1, -1, 44, + 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, + 55, 56 +}; + +static const yysigned_char yycheck[] = +{ + 3, 13, 8, 9, 10, 5, 25, 7, 1, 2, + 12, 11, 11, 0, 24, 12, 25, 25, 30, 14, + 23, 21, 22, 23, 24, 25, 26, 27, 28, 31, + -1, -1, 39, 3, 4, 38, 6, 7, 8, 9, + 10, -1, -1, -1, -1, 15, 16, 17, 18, 19, + 20, 3, -1, -1, 6, 7, 8, 9, 10, 62, + -1, -1, -1, 15, 16, 17, 18, 19, 20, 6, + 7, 8, 9, 10, -1, -1, -1, -1, 15, 16, + 17, 18, 19, 20, 6, 7, 8, 9, 10, -1, + -1, -1, -1, 15, 16, 17, 18, 19, 20, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 5, 7, 11, 21, 22, 23, 24, 25, 26, + 27, 28, 33, 34, 35, 36, 37, 38, 40, 36, + 36, 34, 25, 11, 0, 3, 4, 6, 7, 8, + 9, 10, 15, 16, 17, 18, 19, 20, 13, 30, + 24, 12, 34, 39, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 34, 25, 38, + 25, 12, 31, 14, 34 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 85 "../FreezeScript/Grammar.y" + { + parseResult = yyvsp[0]; +;} + break; + + case 3: +#line 94 "../FreezeScript/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 4: +#line 103 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpLess, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 5: +#line 107 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpGreater, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 6: +#line 111 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpLessEq, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 7: +#line 115 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpGrEq, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 8: +#line 119 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpEq, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 9: +#line 123 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpNotEq, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 10: +#line 127 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpOr, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 11: +#line 131 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpAnd, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 12: +#line 135 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpMul, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 13: +#line 139 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpDiv, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 14: +#line 143 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpMod, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 15: +#line 147 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpAdd, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 16: +#line 151 "../FreezeScript/Grammar.y" + { + yyval = new BinaryNode(BinOpSub, parseDataFactory, yyvsp[-2], yyvsp[0]); +;} + break; + + case 17: +#line 155 "../FreezeScript/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 18: +#line 164 "../FreezeScript/Grammar.y" + { + yyval = yyvsp[-1]; +;} + break; + + case 19: +#line 168 "../FreezeScript/Grammar.y" + { + yyval = new UnaryNode(UnaryOpNeg, parseDataFactory, yyvsp[0]); +;} + break; + + case 20: +#line 172 "../FreezeScript/Grammar.y" + { + yyval = new UnaryNode(UnaryOpNot, parseDataFactory, yyvsp[0]); +;} + break; + + case 21: +#line 176 "../FreezeScript/Grammar.y" + { + IntegerTokPtr intVal = IntegerTokPtr::dynamicCast(yyvsp[0]); + assert(intVal); + yyval = new DataNode(parseDataFactory->createInteger(intVal->v, true)); +;} + break; + + case 22: +#line 182 "../FreezeScript/Grammar.y" + { + FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast(yyvsp[0]); + assert(floatVal); + yyval = new DataNode(parseDataFactory->createDouble(floatVal->v, true)); +;} + break; + + case 23: +#line 188 "../FreezeScript/Grammar.y" + { + StringTokPtr stringVal = StringTokPtr::dynamicCast(yyvsp[0]); + assert(stringVal); + yyval = new DataNode(parseDataFactory->createString(stringVal->v, true)); +;} + break; + + case 24: +#line 194 "../FreezeScript/Grammar.y" + { + yyval = new DataNode(parseDataFactory->createBoolean(true, true)); +;} + break; + + case 25: +#line 198 "../FreezeScript/Grammar.y" + { + yyval = new DataNode(parseDataFactory->createBoolean(false, true)); +;} + break; + + case 26: +#line 202 "../FreezeScript/Grammar.y" + { + yyval = new DataNode(parseDataFactory->createNil(true)); +;} + break; + + case 27: +#line 206 "../FreezeScript/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 28: +#line 210 "../FreezeScript/Grammar.y" + { + EntityNodePtr entity = EntityNodePtr::dynamicCast(yyvsp[-2]); + assert(entity); + FunctionNodePtr func = FunctionNodePtr::dynamicCast(yyvsp[0]); + assert(func); + func->setTarget(entity); + yyval = yyvsp[0]; +;} + break; + + case 29: +#line 219 "../FreezeScript/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 30: +#line 223 "../FreezeScript/Grammar.y" + { + StringTokPtr stringVal = StringTokPtr::dynamicCast(yyvsp[0]); + assert(stringVal); + yyval = new ConstantNode(stringVal->v); +;} + break; + + case 31: +#line 234 "../FreezeScript/Grammar.y" + { + EntityNodePtr entity = EntityNodePtr::dynamicCast(yyvsp[-3]); + assert(entity); + entity->append(new ElementNode(yyvsp[-1])); + yyval = yyvsp[-3]; +;} + break; + + case 32: +#line 241 "../FreezeScript/Grammar.y" + { + StringTokPtr stringVal = StringTokPtr::dynamicCast(yyvsp[0]); + assert(stringVal); + EntityNodePtr entity = EntityNodePtr::dynamicCast(yyvsp[-2]); + assert(entity); + entity->append(new IdentNode(stringVal->v)); + yyval = yyvsp[-2]; +;} + break; + + case 33: +#line 250 "../FreezeScript/Grammar.y" + { + StringTokPtr stringVal = StringTokPtr::dynamicCast(yyvsp[0]); + assert(stringVal); + yyval = new IdentNode(stringVal->v); +;} + break; + + case 34: +#line 261 "../FreezeScript/Grammar.y" + { + StringTokPtr func = StringTokPtr::dynamicCast(yyvsp[-3]); + assert(func); + NodeListTokPtr args = NodeListTokPtr::dynamicCast(yyvsp[-1]); + assert(args); + yyval = new FunctionNode(func->v, args->v); +;} + break; + + case 35: +#line 274 "../FreezeScript/Grammar.y" + { + NodeListTokPtr l = NodeListTokPtr::dynamicCast(yyvsp[-2]); + assert(l); + l->v.push_back(yyvsp[0]); + yyval = yyvsp[-2]; +;} + break; + + case 36: +#line 281 "../FreezeScript/Grammar.y" + { + NodeListTokPtr result = new NodeListTok; + result->v.push_back(yyvsp[0]); + yyval = result; +;} + break; + + case 37: +#line 287 "../FreezeScript/Grammar.y" + { + yyval = new NodeListTok; +;} + break; + + case 38: +#line 296 "../FreezeScript/Grammar.y" + { + StringTokPtr stringVal = StringTokPtr::dynamicCast(yyvsp[-2]); + assert(stringVal); + StringTokPtr idVal = StringTokPtr::dynamicCast(yyvsp[0]); + assert(idVal); + stringVal->v.append("::" + idVal->v); + yyval = yyvsp[-2]; +;} + break; + + case 39: +#line 305 "../FreezeScript/Grammar.y" + { + StringTokPtr idVal = StringTokPtr::dynamicCast(yyvsp[0]); + assert(idVal); + StringTokPtr stringVal = new StringTok; + stringVal->v.append("::" + idVal->v); + yyval = stringVal; +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 1448 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 314 "../FreezeScript/Grammar.y" + + diff --git a/cpp/src/FreezeScript/Grammar.h b/cpp/src/FreezeScript/Grammar.h new file mode 100644 index 00000000000..be9f0c7bc5e --- /dev/null +++ b/cpp/src/FreezeScript/Grammar.h @@ -0,0 +1,102 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_AND = 258, + TOK_OR = 259, + TOK_NOT = 260, + TOK_ADD = 261, + TOK_SUB = 262, + TOK_MUL = 263, + TOK_DIV = 264, + TOK_MOD = 265, + TOK_LPAREN = 266, + TOK_RPAREN = 267, + TOK_LBRACKET = 268, + TOK_RBRACKET = 269, + TOK_LESS_THAN = 270, + TOK_GREATER_THAN = 271, + TOK_LESS_EQUAL = 272, + TOK_GREATER_EQUAL = 273, + TOK_EQUAL = 274, + TOK_NEQ = 275, + TOK_TRUE = 276, + TOK_FALSE = 277, + TOK_NIL = 278, + TOK_SCOPE_DELIMITER = 279, + TOK_IDENTIFIER = 280, + TOK_STRING_LITERAL = 281, + TOK_INTEGER_LITERAL = 282, + TOK_FLOATING_POINT_LITERAL = 283, + UNARY_OP = 284 + }; +#endif +#define TOK_AND 258 +#define TOK_OR 259 +#define TOK_NOT 260 +#define TOK_ADD 261 +#define TOK_SUB 262 +#define TOK_MUL 263 +#define TOK_DIV 264 +#define TOK_MOD 265 +#define TOK_LPAREN 266 +#define TOK_RPAREN 267 +#define TOK_LBRACKET 268 +#define TOK_RBRACKET 269 +#define TOK_LESS_THAN 270 +#define TOK_GREATER_THAN 271 +#define TOK_LESS_EQUAL 272 +#define TOK_GREATER_EQUAL 273 +#define TOK_EQUAL 274 +#define TOK_NEQ 275 +#define TOK_TRUE 276 +#define TOK_FALSE 277 +#define TOK_NIL 278 +#define TOK_SCOPE_DELIMITER 279 +#define TOK_IDENTIFIER 280 +#define TOK_STRING_LITERAL 281 +#define TOK_INTEGER_LITERAL 282 +#define TOK_FLOATING_POINT_LITERAL 283 +#define UNARY_OP 284 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/src/FreezeScript/Makefile b/cpp/src/FreezeScript/Makefile index 8022a7e35d5..3949d79e94b 100644 --- a/cpp/src/FreezeScript/Makefile +++ b/cpp/src/FreezeScript/Makefile @@ -50,11 +50,6 @@ $(DUMPDB): $(DUMP_OBJS) $(COMMON_OBJS) rm -f $@ $(CXX) $(LDFLAGS) -o $@ $(DUMP_OBJS) $(COMMON_OBJS) -lSlice $(EXPAT_RPATH_LINK) -lIceXML $(DB_RPATH_LINK) -lFreeze $(LIBS) $(DB_LIBS) - -clean:: - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp - install:: all $(call installprogram,$(TRANSFORMDB),$(install_bindir)) $(call installprogram,$(DUMPDB),$(install_bindir)) diff --git a/cpp/src/FreezeScript/Makefile.mak b/cpp/src/FreezeScript/Makefile.mak index 63715213fee..8f72c15194b 100644 --- a/cpp/src/FreezeScript/Makefile.mak +++ b/cpp/src/FreezeScript/Makefile.mak @@ -84,8 +84,6 @@ Grammar.cpp Grammar.h: Grammar.y clean:: -del /q $(TRANSFORMDB:.exe=.*) -del /q $(DUMPDB:.exe=.*) - -del /q Grammar.cpp Grammar.h - -del /q Scanner.cpp -del /q TransformDB.res DumpDB.res install:: all diff --git a/cpp/src/FreezeScript/Scanner.cpp b/cpp/src/FreezeScript/Scanner.cpp new file mode 100644 index 00000000000..5c503d2fb5b --- /dev/null +++ b/cpp/src/FreezeScript/Scanner.cpp @@ -0,0 +1,2000 @@ +#include +#define yy_create_buffer freeze_script__create_buffer +#define yy_delete_buffer freeze_script__delete_buffer +#define yy_scan_buffer freeze_script__scan_buffer +#define yy_scan_string freeze_script__scan_string +#define yy_scan_bytes freeze_script__scan_bytes +#define yy_flex_debug freeze_script__flex_debug +#define yy_init_buffer freeze_script__init_buffer +#define yy_flush_buffer freeze_script__flush_buffer +#define yy_load_buffer_state freeze_script__load_buffer_state +#define yy_switch_to_buffer freeze_script__switch_to_buffer +#define yyin freeze_script_in +#define yyleng freeze_script_leng +#define yylex freeze_script_lex +#define yyout freeze_script_out +#define yyrestart freeze_script_restart +#define yytext freeze_script_text + +#line 19 "lex.yy.c" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 26 +#define YY_END_OF_BUFFER 27 +static yyconst short int yy_accept[51] = + { 0, + 0, 0, 27, 25, 8, 8, 25, 4, 19, 5, + 20, 21, 17, 15, 16, 25, 18, 6, 6, 25, + 9, 25, 10, 3, 22, 23, 14, 0, 6, 6, + 7, 2, 1, 7, 6, 0, 0, 24, 11, 13, + 12, 3, 0, 7, 0, 7, 6, 0, 7, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 1, 1, 6, 1, 7, 8, + 9, 10, 11, 1, 12, 13, 14, 15, 16, 16, + 16, 16, 16, 16, 16, 17, 17, 18, 1, 19, + 20, 21, 1, 1, 22, 22, 22, 22, 23, 24, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 26, 1, 27, 1, 25, 1, 22, 22, 22, 22, + + 28, 24, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 29, + 25, 25, 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, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[30] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 1, 1, 3, 3, 3, 1, 1, 1, + 1, 4, 4, 4, 5, 1, 1, 4, 5 + } ; + +static yyconst short int yy_base[55] = + { 0, + 0, 0, 72, 104, 104, 104, 51, 104, 104, 104, + 104, 104, 104, 17, 22, 25, 33, 35, 30, 44, + 29, 24, 16, 0, 104, 104, 104, 38, 0, 0, + 50, 104, 104, 0, 2, 45, 0, 104, 104, 104, + 104, 0, 49, 104, 53, 60, 0, 64, 70, 104, + 92, 96, 97, 100 + } ; + +static yyconst short int yy_def[55] = + { 0, + 50, 1, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 18, 50, + 50, 50, 50, 51, 50, 50, 50, 50, 18, 19, + 50, 50, 50, 31, 18, 52, 53, 50, 50, 50, + 50, 51, 54, 50, 50, 50, 53, 50, 50, 0, + 50, 50, 50, 50 + } ; + +static yyconst short int yy_nxt[134] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, + 23, 24, 24, 24, 24, 25, 26, 24, 24, 28, + 50, 29, 30, 30, 28, 41, 29, 30, 30, 31, + 31, 31, 32, 40, 30, 30, 33, 34, 39, 35, + 35, 30, 31, 31, 31, 45, 45, 36, 50, 48, + 48, 38, 36, 37, 31, 31, 31, 46, 46, 46, + 27, 50, 43, 44, 46, 46, 46, 43, 49, 49, + 49, 50, 50, 44, 49, 49, 49, 50, 50, 50, + 50, 50, 50, 44, 42, 42, 42, 46, 46, 47, + + 47, 49, 49, 3, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50 + } ; + +static yyconst short int yy_chk[134] = + { 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, 14, + 35, 14, 14, 14, 15, 23, 15, 15, 15, 16, + 16, 16, 17, 22, 19, 19, 17, 18, 21, 18, + 18, 18, 28, 28, 28, 36, 36, 18, 19, 43, + 43, 20, 18, 18, 31, 31, 31, 45, 45, 45, + 7, 3, 31, 31, 46, 46, 46, 31, 48, 48, + 48, 0, 0, 46, 49, 49, 49, 0, 0, 0, + 0, 0, 0, 49, 51, 51, 51, 52, 52, 53, + + 53, 54, 54, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include // Before Grammar.h, so that YYSTYPE is defined +#include +#include + +#include +#include + +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; +using namespace FreezeScript; + +namespace FreezeScript +{ + +typedef map KeywordMap; +static KeywordMap keywordMap; + +void initScanner(); +int checkKeyword(const string&); +StringTokPtr parseString(char); + +} + +#define YY_USER_INIT initScanner(); + +#define YY_INPUT(buf, result, max_size) { result = getInput(buf, max_size); } +#define YY_NEVER_INTERACTIVE 1 +#line 475 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 60 "Scanner.l" + + +#line 629 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 51 ) + 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_base[yy_current_state] != 104 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 62 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + if(c == '\n') + { + parseLine++; + } + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 76 "Scanner.l" +{ + // C-style comment + while(true) + { + int c = yyinput(); + if(c == '\n') + { + parseLine++; + } + else if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + unput(next); + } + } + else if(c == EOF) + { + parseErrorReporter->expressionSyntaxError("EOF in comment"); + break; + } + } +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 105 "Scanner.l" +{ + StringTokPtr ident = new StringTok; + ident->v = yytext; + *yylvalp = ident; + return checkKeyword(ident->v); +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 112 "Scanner.l" +{ + StringTokPtr str = parseString('"'); + *yylvalp = str; + return TOK_STRING_LITERAL; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 118 "Scanner.l" +{ + StringTokPtr str = parseString('\''); + *yylvalp = str; + return TOK_STRING_LITERAL; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 124 "Scanner.l" +{ + IntegerTokPtr itp = new IntegerTok; + *yylvalp = itp; + if(!IceUtilInternal::stringToInt64(string(yytext), itp->v)) + { + assert(itp->v != 0); + string msg = "integer constant `"; + msg += yytext; + msg += "' out of range"; + parseErrorReporter->expressionSyntaxError(msg); + } + return TOK_INTEGER_LITERAL; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 138 "Scanner.l" +{ + errno = 0; + FloatingTokPtr ftp = new FloatingTok; + *yylvalp = ftp; + string literal(yytext); + char lastChar = literal[literal.size() - 1]; + if(lastChar == 'f' || lastChar == 'F') + { + literal = literal.substr(0, literal.size() - 1); // Clobber trailing 'f' or 'F' suffix + } + ftp->v = strtod(literal.c_str(), 0); + if((ftp->v == HUGE_VAL || ftp->v == -HUGE_VAL) && errno == ERANGE) + { + string msg = "floating-point constant `"; + msg += yytext; + msg += "' too large (overflow)"; + parseErrorReporter->expressionSyntaxError(msg); + } + else if(ftp->v == 0 && errno == ERANGE) + { + string msg = "floating-point constant `"; + msg += yytext; + msg += "' too small (underflow)"; + parseErrorReporter->expressionSyntaxError(msg); + } + return TOK_FLOATING_POINT_LITERAL; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 166 "Scanner.l" +{ + // Igore white-space + + if(yytext[0] == '\n') + { + parseLine++; + } +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 175 "Scanner.l" +return TOK_LESS_THAN; + YY_BREAK +case 10: +YY_RULE_SETUP +#line 176 "Scanner.l" +return TOK_GREATER_THAN; + YY_BREAK +case 11: +YY_RULE_SETUP +#line 177 "Scanner.l" +return TOK_LESS_EQUAL; + YY_BREAK +case 12: +YY_RULE_SETUP +#line 178 "Scanner.l" +return TOK_GREATER_EQUAL; + YY_BREAK +case 13: +YY_RULE_SETUP +#line 179 "Scanner.l" +return TOK_EQUAL; + YY_BREAK +case 14: +YY_RULE_SETUP +#line 180 "Scanner.l" +return TOK_NEQ; + YY_BREAK +case 15: +YY_RULE_SETUP +#line 181 "Scanner.l" +return TOK_ADD; + YY_BREAK +case 16: +YY_RULE_SETUP +#line 182 "Scanner.l" +return TOK_SUB; + YY_BREAK +case 17: +YY_RULE_SETUP +#line 183 "Scanner.l" +return TOK_MUL; + YY_BREAK +case 18: +YY_RULE_SETUP +#line 184 "Scanner.l" +return TOK_DIV; + YY_BREAK +case 19: +YY_RULE_SETUP +#line 185 "Scanner.l" +return TOK_MOD; + YY_BREAK +case 20: +YY_RULE_SETUP +#line 186 "Scanner.l" +return TOK_LPAREN; + YY_BREAK +case 21: +YY_RULE_SETUP +#line 187 "Scanner.l" +return TOK_RPAREN; + YY_BREAK +case 22: +YY_RULE_SETUP +#line 188 "Scanner.l" +return TOK_LBRACKET; + YY_BREAK +case 23: +YY_RULE_SETUP +#line 189 "Scanner.l" +return TOK_RBRACKET; + YY_BREAK +case 24: +YY_RULE_SETUP +#line 190 "Scanner.l" +return TOK_SCOPE_DELIMITER; + YY_BREAK +case 25: +YY_RULE_SETUP +#line 192 "Scanner.l" +{ + return yytext[0]; +} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 196 "Scanner.l" +ECHO; + YY_BREAK +#line 941 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 51 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 51 ) + 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 == 50); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 196 "Scanner.l" + + +namespace FreezeScript +{ + +void +initScanner() +{ + keywordMap["true"] = TOK_TRUE; + keywordMap["false"] = TOK_FALSE; + keywordMap["and"] = TOK_AND; + keywordMap["or"] = TOK_OR; + keywordMap["not"] = TOK_NOT; + keywordMap["nil"] = TOK_NIL; +} + +int +checkKeyword(const string& id) +{ + KeywordMap::const_iterator pos = keywordMap.find(id); + if(pos != keywordMap.end()) + { + return pos->second; + } + return TOK_IDENTIFIER; +} + +StringTokPtr +parseString(char start) +{ + StringTokPtr str = new StringTok; + while(true) + { + char c = static_cast(yyinput()); + if(c == start) + { + break; + } + else if(c == EOF) + { + parseErrorReporter->expressionSyntaxError("EOF in string"); + break; + } + else if(c == '\n') + { + parseErrorReporter->expressionSyntaxError("newline in string"); + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + switch(next) + { + case '\\': + case '"': + case '\'': + { + str->v += next; + break; + } + + case 'n': + { + str->v += '\n'; + break; + } + + case 'r': + { + str->v += '\r'; + break; + } + + case 't': + { + str->v += '\t'; + break; + } + + case 'v': + { + str->v += '\v'; + break; + } + + case 'f': + { + str->v += '\f'; + break; + } + + case 'a': + { + str->v += '\a'; + break; + } + + case 'b': + { + str->v += '\b'; + break; + } + + case '?': + { + str->v += '\?'; + break; + } + + case '0': + case '1': + case '2': + case '3': + { + static string octalDigits = "01234567"; + unsigned short us = next - '0'; + if(octalDigits.find_first_of(next = static_cast(yyinput())) != string::npos) + { + us = us * 8 + next - '0'; + if(octalDigits.find_first_of(next = static_cast(yyinput())) != string::npos) + { + us = us * 8 + next - '0'; + } + else + { + unput(next); + } + } + else + { + unput(next); + } + str->v += static_cast(us); + break; + } + case 'x': + { + IceUtil::Int64 ull = 0; + while(isxdigit(static_cast(next = static_cast(yyinput())))) + { + ull *= 16; + if(isdigit(static_cast(next))) + { + ull += next - '0'; + } + else if(islower(static_cast(next))) + { + ull += next - 'a' + 10; + } + else + { + ull += next - 'A' + 10; + } + } + unput(next); + str->v += static_cast(ull); + break; + } + + // TODO: add universal character names + + default: + { + str->v += c; + unput(next); + } + } + } + else + { + str->v += c; + } + } + + return str; +} + +} // End of namespace FreezeScript diff --git a/cpp/src/IceGrid/.gitignore b/cpp/src/IceGrid/.gitignore index 9c92c4e432e..21d09e4ace5 100644 --- a/cpp/src/IceGrid/.gitignore +++ b/cpp/src/IceGrid/.gitignore @@ -9,6 +9,3 @@ IdentityObjectInfoDict.h IdentityObjectInfoDict.cpp StringAdapterInfoDict.h StringAdapterInfoDict.cpp -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/src/IceGrid/Grammar.cpp b/cpp/src/IceGrid/Grammar.cpp new file mode 100644 index 00000000000..16c562d9eb4 --- /dev/null +++ b/cpp/src/IceGrid/Grammar.cpp @@ -0,0 +1,3224 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_GRID_HELP = 258, + ICE_GRID_EXIT = 259, + ICE_GRID_APPLICATION = 260, + ICE_GRID_NODE = 261, + ICE_GRID_REGISTRY = 262, + ICE_GRID_SERVER = 263, + ICE_GRID_ADAPTER = 264, + ICE_GRID_PING = 265, + ICE_GRID_LOAD = 266, + ICE_GRID_ADD = 267, + ICE_GRID_REMOVE = 268, + ICE_GRID_LIST = 269, + ICE_GRID_SHUTDOWN = 270, + ICE_GRID_STRING = 271, + ICE_GRID_START = 272, + ICE_GRID_STOP = 273, + ICE_GRID_PATCH = 274, + ICE_GRID_SIGNAL = 275, + ICE_GRID_STDOUT = 276, + ICE_GRID_STDERR = 277, + ICE_GRID_DESCRIBE = 278, + ICE_GRID_PROPERTIES = 279, + ICE_GRID_PROPERTY = 280, + ICE_GRID_STATE = 281, + ICE_GRID_PID = 282, + ICE_GRID_ENDPOINTS = 283, + ICE_GRID_ACTIVATION = 284, + ICE_GRID_OBJECT = 285, + ICE_GRID_FIND = 286, + ICE_GRID_SHOW = 287, + ICE_GRID_COPYING = 288, + ICE_GRID_WARRANTY = 289, + ICE_GRID_DIFF = 290, + ICE_GRID_UPDATE = 291, + ICE_GRID_INSTANTIATE = 292, + ICE_GRID_TEMPLATE = 293, + ICE_GRID_SERVICE = 294, + ICE_GRID_ENABLE = 295, + ICE_GRID_DISABLE = 296 + }; +#endif +#define ICE_GRID_HELP 258 +#define ICE_GRID_EXIT 259 +#define ICE_GRID_APPLICATION 260 +#define ICE_GRID_NODE 261 +#define ICE_GRID_REGISTRY 262 +#define ICE_GRID_SERVER 263 +#define ICE_GRID_ADAPTER 264 +#define ICE_GRID_PING 265 +#define ICE_GRID_LOAD 266 +#define ICE_GRID_ADD 267 +#define ICE_GRID_REMOVE 268 +#define ICE_GRID_LIST 269 +#define ICE_GRID_SHUTDOWN 270 +#define ICE_GRID_STRING 271 +#define ICE_GRID_START 272 +#define ICE_GRID_STOP 273 +#define ICE_GRID_PATCH 274 +#define ICE_GRID_SIGNAL 275 +#define ICE_GRID_STDOUT 276 +#define ICE_GRID_STDERR 277 +#define ICE_GRID_DESCRIBE 278 +#define ICE_GRID_PROPERTIES 279 +#define ICE_GRID_PROPERTY 280 +#define ICE_GRID_STATE 281 +#define ICE_GRID_PID 282 +#define ICE_GRID_ENDPOINTS 283 +#define ICE_GRID_ACTIVATION 284 +#define ICE_GRID_OBJECT 285 +#define ICE_GRID_FIND 286 +#define ICE_GRID_SHOW 287 +#define ICE_GRID_COPYING 288 +#define ICE_GRID_WARRANTY 289 +#define ICE_GRID_DIFF 290 +#define ICE_GRID_UPDATE 291 +#define ICE_GRID_INSTANTIATE 292 +#define ICE_GRID_TEMPLATE 293 +#define ICE_GRID_SERVICE 294 +#define ICE_GRID_ENABLE 295 +#define ICE_GRID_DISABLE 296 + + + + +/* Copy the first part of user declarations. */ +#line 1 "Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; +using namespace Ice; +using namespace IceGrid; + +void +yyerror(const char* s) +{ + parser->invalidCommand(s); +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 203 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 4 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 2510 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 43 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 7 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 169 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 361 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 296 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 42, + 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short yyprhs[] = +{ + 0, 0, 3, 5, 6, 10, 13, 14, 17, 20, + 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, + 75, 80, 85, 90, 96, 102, 108, 114, 119, 125, + 131, 136, 141, 146, 151, 156, 161, 166, 171, 176, + 181, 186, 191, 196, 201, 206, 211, 216, 221, 226, + 231, 236, 241, 246, 251, 256, 261, 266, 271, 276, + 281, 286, 291, 296, 301, 306, 311, 316, 321, 326, + 331, 336, 341, 346, 351, 356, 361, 366, 371, 376, + 381, 386, 391, 396, 401, 406, 411, 416, 421, 426, + 431, 436, 441, 446, 451, 456, 461, 466, 471, 476, + 481, 486, 491, 496, 501, 506, 511, 516, 521, 526, + 531, 536, 541, 546, 550, 554, 558, 563, 569, 575, + 582, 587, 591, 595, 600, 604, 608, 611, 613, 616, + 619, 623, 627, 628, 630, 632, 634, 636, 638, 640, + 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, + 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, + 682, 684, 686, 688, 690, 692, 694, 696, 698, 700 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 44, 0, -1, 45, -1, -1, 45, 46, 47, -1, + 46, 47, -1, -1, 3, 42, -1, 4, 42, -1, + 5, 12, 48, 42, -1, 5, 12, 3, 42, -1, + 5, 13, 48, 42, -1, 5, 13, 3, 42, -1, + 5, 35, 48, 42, -1, 5, 35, 3, 42, -1, + 5, 36, 48, 42, -1, 5, 36, 3, 42, -1, + 5, 23, 48, 42, -1, 5, 23, 3, 42, -1, + 5, 19, 48, 42, -1, 5, 19, 3, 42, -1, + 5, 14, 48, 42, -1, 5, 14, 3, 42, -1, + 8, 38, 23, 48, 42, -1, 8, 38, 23, 3, + 42, -1, 8, 38, 37, 48, 42, -1, 8, 38, + 37, 3, 42, -1, 8, 38, 3, 42, -1, 39, + 38, 23, 48, 42, -1, 39, 38, 23, 3, 42, + -1, 39, 38, 3, 42, -1, 6, 23, 48, 42, + -1, 6, 23, 3, 42, -1, 6, 10, 48, 42, + -1, 6, 10, 3, 42, -1, 6, 11, 48, 42, + -1, 6, 11, 3, 42, -1, 6, 15, 48, 42, + -1, 6, 15, 3, 42, -1, 6, 14, 48, 42, + -1, 6, 14, 3, 42, -1, 6, 32, 48, 42, + -1, 6, 32, 3, 42, -1, 7, 23, 48, 42, + -1, 7, 23, 3, 42, -1, 7, 10, 48, 42, + -1, 7, 10, 3, 42, -1, 7, 15, 48, 42, + -1, 7, 15, 3, 42, -1, 7, 14, 48, 42, + -1, 7, 14, 3, 42, -1, 7, 32, 48, 42, + -1, 7, 32, 3, 42, -1, 8, 13, 48, 42, + -1, 8, 13, 3, 42, -1, 8, 23, 48, 42, + -1, 8, 23, 3, 42, -1, 8, 17, 48, 42, + -1, 8, 17, 3, 42, -1, 8, 18, 48, 42, + -1, 8, 18, 3, 42, -1, 8, 19, 48, 42, + -1, 8, 19, 3, 42, -1, 8, 20, 48, 42, + -1, 8, 20, 3, 42, -1, 8, 21, 48, 42, + -1, 8, 21, 3, 42, -1, 8, 22, 48, 42, + -1, 8, 22, 3, 42, -1, 8, 26, 48, 42, + -1, 8, 26, 3, 42, -1, 8, 27, 48, 42, + -1, 8, 27, 3, 42, -1, 8, 24, 48, 42, + -1, 8, 24, 3, 42, -1, 8, 25, 48, 42, + -1, 8, 25, 3, 42, -1, 8, 40, 48, 42, + -1, 8, 40, 3, 42, -1, 8, 41, 48, 42, + -1, 8, 41, 3, 42, -1, 8, 14, 48, 42, + -1, 8, 14, 3, 42, -1, 8, 32, 48, 42, + -1, 8, 32, 3, 42, -1, 39, 17, 48, 42, + -1, 39, 17, 3, 42, -1, 39, 18, 48, 42, + -1, 39, 18, 3, 42, -1, 39, 23, 48, 42, + -1, 39, 23, 3, 42, -1, 39, 24, 48, 42, + -1, 39, 24, 3, 42, -1, 39, 25, 48, 42, + -1, 39, 25, 3, 42, -1, 39, 14, 48, 42, + -1, 39, 14, 3, 42, -1, 9, 28, 48, 42, + -1, 9, 28, 3, 42, -1, 9, 13, 48, 42, + -1, 9, 13, 3, 42, -1, 9, 14, 48, 42, + -1, 9, 14, 3, 42, -1, 30, 12, 48, 42, + -1, 30, 12, 3, 42, -1, 30, 13, 48, 42, + -1, 30, 13, 3, 42, -1, 30, 31, 48, 42, + -1, 30, 31, 3, 42, -1, 30, 14, 48, 42, + -1, 30, 14, 3, 42, -1, 30, 23, 48, 42, + -1, 30, 23, 3, 42, -1, 32, 33, 42, -1, + 32, 34, 42, -1, 3, 49, 42, -1, 3, 49, + 49, 42, -1, 3, 49, 16, 48, 42, -1, 3, + 49, 49, 49, 42, -1, 3, 49, 49, 16, 48, + 42, -1, 3, 16, 48, 42, -1, 3, 1, 42, + -1, 49, 3, 42, -1, 49, 16, 1, 42, -1, + 49, 1, 42, -1, 16, 1, 42, -1, 1, 42, + -1, 42, -1, 16, 48, -1, 49, 48, -1, 16, + 3, 48, -1, 49, 3, 48, -1, -1, 4, -1, + 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, + 10, -1, 11, -1, 12, -1, 13, -1, 14, -1, + 15, -1, 17, -1, 18, -1, 19, -1, 20, -1, + 23, -1, 26, -1, 27, -1, 24, -1, 25, -1, + 28, -1, 29, -1, 30, -1, 31, -1, 32, -1, + 33, -1, 34, -1, 35, -1, 36, -1, 37, -1, + 38, -1, 39, -1, 40, -1, 41, -1, 22, -1, + 21, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 87, 87, 91, 98, 101, 108, 116, 120, 124, + 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, + 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, + 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, + 248, 252, 256, 260, 264, 268, 272, 276, 280, 284, + 288, 292, 296, 300, 304, 308, 312, 316, 320, 324, + 328, 332, 336, 340, 344, 348, 352, 356, 360, 364, + 368, 372, 376, 380, 384, 388, 392, 396, 400, 404, + 408, 412, 416, 420, 424, 428, 432, 436, 440, 444, + 448, 452, 456, 460, 464, 468, 472, 476, 480, 484, + 488, 492, 496, 500, 504, 508, 512, 516, 520, 524, + 528, 532, 536, 540, 544, 548, 552, 563, 567, 578, + 589, 593, 597, 601, 607, 612, 617, 621, 630, 635, + 640, 646, 653, 661, 664, 667, 670, 673, 676, 679, + 682, 685, 688, 691, 694, 697, 700, 703, 706, 709, + 712, 715, 718, 721, 724, 727, 730, 733, 736, 739, + 742, 745, 748, 751, 754, 757, 760, 763, 766, 769 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ICE_GRID_HELP", "ICE_GRID_EXIT", + "ICE_GRID_APPLICATION", "ICE_GRID_NODE", "ICE_GRID_REGISTRY", + "ICE_GRID_SERVER", "ICE_GRID_ADAPTER", "ICE_GRID_PING", "ICE_GRID_LOAD", + "ICE_GRID_ADD", "ICE_GRID_REMOVE", "ICE_GRID_LIST", "ICE_GRID_SHUTDOWN", + "ICE_GRID_STRING", "ICE_GRID_START", "ICE_GRID_STOP", "ICE_GRID_PATCH", + "ICE_GRID_SIGNAL", "ICE_GRID_STDOUT", "ICE_GRID_STDERR", + "ICE_GRID_DESCRIBE", "ICE_GRID_PROPERTIES", "ICE_GRID_PROPERTY", + "ICE_GRID_STATE", "ICE_GRID_PID", "ICE_GRID_ENDPOINTS", + "ICE_GRID_ACTIVATION", "ICE_GRID_OBJECT", "ICE_GRID_FIND", + "ICE_GRID_SHOW", "ICE_GRID_COPYING", "ICE_GRID_WARRANTY", + "ICE_GRID_DIFF", "ICE_GRID_UPDATE", "ICE_GRID_INSTANTIATE", + "ICE_GRID_TEMPLATE", "ICE_GRID_SERVICE", "ICE_GRID_ENABLE", + "ICE_GRID_DISABLE", "';'", "$accept", "start", "commands", + "checkInterrupted", "command", "strings", "keyword", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 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, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 43, 44, 44, 45, 45, 46, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, + 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 0, 3, 2, 0, 2, 2, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 5, 5, 5, 5, 4, 5, 5, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 3, 3, 3, 4, 5, 5, 6, + 4, 3, 3, 4, 3, 3, 2, 1, 2, 2, + 3, 3, 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 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 6, 0, 6, 0, 1, 0, 0, 0, 133, 134, + 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, + 0, 145, 146, 147, 148, 169, 168, 149, 152, 153, + 150, 151, 154, 155, 156, 157, 158, 159, 160, 161, + 162, 163, 164, 165, 166, 167, 127, 5, 0, 4, + 126, 0, 133, 134, 135, 136, 137, 138, 132, 156, + 158, 165, 7, 0, 8, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, + 132, 132, 132, 132, 132, 132, 132, 0, 132, 132, + 132, 132, 132, 0, 132, 132, 132, 132, 132, 0, + 0, 132, 132, 132, 132, 132, 132, 0, 0, 0, + 0, 121, 132, 0, 132, 132, 115, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 132, 132, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 125, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 113, 114, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 132, 124, 122, 0, 132, 128, 120, 132, 129, + 0, 132, 116, 0, 10, 9, 12, 11, 22, 21, + 20, 19, 18, 17, 14, 13, 16, 15, 34, 33, + 36, 35, 40, 39, 38, 37, 32, 31, 42, 41, + 46, 45, 50, 49, 48, 47, 44, 43, 52, 51, + 54, 53, 82, 81, 58, 57, 60, 59, 62, 61, + 64, 63, 66, 65, 68, 67, 56, 55, 74, 73, + 76, 75, 70, 69, 72, 71, 84, 83, 27, 0, + 0, 0, 0, 78, 77, 80, 79, 100, 99, 102, + 101, 98, 97, 104, 103, 106, 105, 110, 109, 112, + 111, 108, 107, 96, 95, 86, 85, 88, 87, 90, + 89, 92, 91, 94, 93, 30, 0, 0, 123, 130, + 131, 117, 0, 118, 24, 23, 26, 25, 29, 28, + 119 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 1, 2, 3, 47, 123, 124 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -66 +static const short yypact[] = +{ + 38, 53, 55, 60, -66, 60, 20, 176, 62, 96, + 140, 142, 121, 98, -66, -66, -66, -66, -66, -66, + 112, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, 93, -66, 11, -66, -66, -66, + -66, -66, -66, 2388, -66, -66, -66, -66, 117, -66, + -66, 75, -66, -66, -66, -66, -66, -66, 2360, -66, + -66, -66, -66, 215, -66, 255, 294, 333, 372, 411, + 450, 489, 528, 567, 606, 645, 684, 723, 762, 801, + 840, 879, 918, 957, 996, 1035, 1074, 1113, 1152, 1191, + 1230, 1269, 1308, 1347, 1386, 1425, 1464, 100, 1503, 1542, + 1581, 1620, 1659, 79, 1698, 1737, 1776, 1815, 1854, 80, + 83, 1893, 1932, 1971, 2010, 2049, 2088, 29, 85, 88, + 135, -66, 2127, 107, 2166, 2360, -66, 2204, 116, 118, + 122, 125, 126, 127, 129, 133, 137, 2361, 2362, 2365, + 2366, 2367, 2368, 2372, 2373, 2374, 2375, 2376, 2377, 2378, + 2379, 2380, 2381, 2382, 2383, 2385, 2386, 2387, 2389, 2390, + 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, + 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, + 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, + 2421, 2422, 2423, 2244, 2283, 2424, 2425, 2426, 2427, 2428, + 2429, 2430, 2431, 2432, 2433, -66, 2434, 2435, 2436, 2437, + 2438, 2439, 2440, 2441, 2442, 2443, -66, -66, 2444, 2445, + 2446, 2447, 2448, 2449, 2450, 2451, 2452, 2453, 2454, 2455, + 2456, 2322, -66, -66, 2457, 2360, -66, -66, 2360, -66, + 2458, 2360, -66, 2459, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, 2460, + 2461, 2462, 2463, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, -66, -66, -66, -66, + -66, -66, -66, -66, -66, -66, 2464, 2465, -66, -66, + -66, -66, 2466, -66, -66, -66, -66, -66, -66, -66, + -66 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short yypgoto[] = +{ + -66, -66, -66, 2507, 2505, -65, 51 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const short yytable[] = +{ + 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, + 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, + 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, + 189, 191, 230, 196, 198, 200, 202, 204, -3, 207, + 209, 211, 213, 215, 109, 110, 219, 221, 223, 225, + 227, 229, 231, 4, 48, -2, 48, 236, 63, 239, + 240, 6, 50, 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, + 44, 45, 46, 192, 64, 104, 105, 106, 65, 66, + 67, 100, 101, 103, 127, 68, 107, 121, 118, 69, + 119, 205, 216, 193, 108, 217, 102, 232, 310, 312, + 233, 70, 71, 120, 83, 84, 234, 194, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 237, + 72, 73, 78, 96, 74, 75, 79, 80, 244, 97, + 245, 98, 99, 76, 246, 81, 347, 247, 248, 249, + 349, 250, 77, 350, 82, 251, 352, 51, 243, 252, + 52, 53, 54, 55, 56, 57, 14, 15, 16, 17, + 18, 19, 58, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 59, 35, 60, 37, + 38, 39, 40, 41, 42, 61, 44, 45, 62, 52, + 53, 54, 55, 56, 57, 14, 15, 16, 17, 18, + 19, 125, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 59, 35, 60, 37, 38, + 39, 40, 41, 42, 61, 44, 45, 126, 128, 52, + 53, 54, 55, 56, 57, 14, 15, 16, 17, 18, + 19, 122, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 59, 35, 60, 37, 38, + 39, 40, 41, 42, 61, 44, 45, 130, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 122, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 132, 52, 53, 54, + 55, 56, 57, 14, 15, 16, 17, 18, 19, 122, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 59, 35, 60, 37, 38, 39, 40, + 41, 42, 61, 44, 45, 134, 52, 53, 54, 55, + 56, 57, 14, 15, 16, 17, 18, 19, 122, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 59, 35, 60, 37, 38, 39, 40, 41, + 42, 61, 44, 45, 136, 52, 53, 54, 55, 56, + 57, 14, 15, 16, 17, 18, 19, 122, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 59, 35, 60, 37, 38, 39, 40, 41, 42, + 61, 44, 45, 138, 52, 53, 54, 55, 56, 57, + 14, 15, 16, 17, 18, 19, 122, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 59, 35, 60, 37, 38, 39, 40, 41, 42, 61, + 44, 45, 140, 52, 53, 54, 55, 56, 57, 14, + 15, 16, 17, 18, 19, 122, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 59, + 35, 60, 37, 38, 39, 40, 41, 42, 61, 44, + 45, 142, 52, 53, 54, 55, 56, 57, 14, 15, + 16, 17, 18, 19, 122, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 59, 35, + 60, 37, 38, 39, 40, 41, 42, 61, 44, 45, + 144, 52, 53, 54, 55, 56, 57, 14, 15, 16, + 17, 18, 19, 122, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 59, 35, 60, + 37, 38, 39, 40, 41, 42, 61, 44, 45, 146, + 52, 53, 54, 55, 56, 57, 14, 15, 16, 17, + 18, 19, 122, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 59, 35, 60, 37, + 38, 39, 40, 41, 42, 61, 44, 45, 148, 52, + 53, 54, 55, 56, 57, 14, 15, 16, 17, 18, + 19, 122, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 59, 35, 60, 37, 38, + 39, 40, 41, 42, 61, 44, 45, 150, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 122, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 152, 52, 53, 54, + 55, 56, 57, 14, 15, 16, 17, 18, 19, 122, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 59, 35, 60, 37, 38, 39, 40, + 41, 42, 61, 44, 45, 154, 52, 53, 54, 55, + 56, 57, 14, 15, 16, 17, 18, 19, 122, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 59, 35, 60, 37, 38, 39, 40, 41, + 42, 61, 44, 45, 156, 52, 53, 54, 55, 56, + 57, 14, 15, 16, 17, 18, 19, 122, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 59, 35, 60, 37, 38, 39, 40, 41, 42, + 61, 44, 45, 158, 52, 53, 54, 55, 56, 57, + 14, 15, 16, 17, 18, 19, 122, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 59, 35, 60, 37, 38, 39, 40, 41, 42, 61, + 44, 45, 160, 52, 53, 54, 55, 56, 57, 14, + 15, 16, 17, 18, 19, 122, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 59, + 35, 60, 37, 38, 39, 40, 41, 42, 61, 44, + 45, 162, 52, 53, 54, 55, 56, 57, 14, 15, + 16, 17, 18, 19, 122, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 59, 35, + 60, 37, 38, 39, 40, 41, 42, 61, 44, 45, + 164, 52, 53, 54, 55, 56, 57, 14, 15, 16, + 17, 18, 19, 122, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 59, 35, 60, + 37, 38, 39, 40, 41, 42, 61, 44, 45, 166, + 52, 53, 54, 55, 56, 57, 14, 15, 16, 17, + 18, 19, 122, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 59, 35, 60, 37, + 38, 39, 40, 41, 42, 61, 44, 45, 168, 52, + 53, 54, 55, 56, 57, 14, 15, 16, 17, 18, + 19, 122, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 59, 35, 60, 37, 38, + 39, 40, 41, 42, 61, 44, 45, 170, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 122, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 172, 52, 53, 54, + 55, 56, 57, 14, 15, 16, 17, 18, 19, 122, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 59, 35, 60, 37, 38, 39, 40, + 41, 42, 61, 44, 45, 174, 52, 53, 54, 55, + 56, 57, 14, 15, 16, 17, 18, 19, 122, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 59, 35, 60, 37, 38, 39, 40, 41, + 42, 61, 44, 45, 176, 52, 53, 54, 55, 56, + 57, 14, 15, 16, 17, 18, 19, 122, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 59, 35, 60, 37, 38, 39, 40, 41, 42, + 61, 44, 45, 178, 52, 53, 54, 55, 56, 57, + 14, 15, 16, 17, 18, 19, 122, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 59, 35, 60, 37, 38, 39, 40, 41, 42, 61, + 44, 45, 180, 52, 53, 54, 55, 56, 57, 14, + 15, 16, 17, 18, 19, 122, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 59, + 35, 60, 37, 38, 39, 40, 41, 42, 61, 44, + 45, 182, 52, 53, 54, 55, 56, 57, 14, 15, + 16, 17, 18, 19, 122, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 59, 35, + 60, 37, 38, 39, 40, 41, 42, 61, 44, 45, + 184, 52, 53, 54, 55, 56, 57, 14, 15, 16, + 17, 18, 19, 122, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 59, 35, 60, + 37, 38, 39, 40, 41, 42, 61, 44, 45, 186, + 52, 53, 54, 55, 56, 57, 14, 15, 16, 17, + 18, 19, 122, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 59, 35, 60, 37, + 38, 39, 40, 41, 42, 61, 44, 45, 188, 52, + 53, 54, 55, 56, 57, 14, 15, 16, 17, 18, + 19, 122, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 59, 35, 60, 37, 38, + 39, 40, 41, 42, 61, 44, 45, 190, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 122, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 195, 52, 53, 54, + 55, 56, 57, 14, 15, 16, 17, 18, 19, 122, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 59, 35, 60, 37, 38, 39, 40, + 41, 42, 61, 44, 45, 197, 52, 53, 54, 55, + 56, 57, 14, 15, 16, 17, 18, 19, 122, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 59, 35, 60, 37, 38, 39, 40, 41, + 42, 61, 44, 45, 199, 52, 53, 54, 55, 56, + 57, 14, 15, 16, 17, 18, 19, 122, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 59, 35, 60, 37, 38, 39, 40, 41, 42, + 61, 44, 45, 201, 52, 53, 54, 55, 56, 57, + 14, 15, 16, 17, 18, 19, 122, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 59, 35, 60, 37, 38, 39, 40, 41, 42, 61, + 44, 45, 203, 52, 53, 54, 55, 56, 57, 14, + 15, 16, 17, 18, 19, 122, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 59, + 35, 60, 37, 38, 39, 40, 41, 42, 61, 44, + 45, 206, 52, 53, 54, 55, 56, 57, 14, 15, + 16, 17, 18, 19, 122, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 59, 35, + 60, 37, 38, 39, 40, 41, 42, 61, 44, 45, + 208, 52, 53, 54, 55, 56, 57, 14, 15, 16, + 17, 18, 19, 122, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 59, 35, 60, + 37, 38, 39, 40, 41, 42, 61, 44, 45, 210, + 52, 53, 54, 55, 56, 57, 14, 15, 16, 17, + 18, 19, 122, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 59, 35, 60, 37, + 38, 39, 40, 41, 42, 61, 44, 45, 212, 52, + 53, 54, 55, 56, 57, 14, 15, 16, 17, 18, + 19, 122, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 59, 35, 60, 37, 38, + 39, 40, 41, 42, 61, 44, 45, 214, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 122, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 218, 52, 53, 54, + 55, 56, 57, 14, 15, 16, 17, 18, 19, 122, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 59, 35, 60, 37, 38, 39, 40, + 41, 42, 61, 44, 45, 220, 52, 53, 54, 55, + 56, 57, 14, 15, 16, 17, 18, 19, 122, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 59, 35, 60, 37, 38, 39, 40, 41, + 42, 61, 44, 45, 222, 52, 53, 54, 55, 56, + 57, 14, 15, 16, 17, 18, 19, 122, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 59, 35, 60, 37, 38, 39, 40, 41, 42, + 61, 44, 45, 224, 52, 53, 54, 55, 56, 57, + 14, 15, 16, 17, 18, 19, 122, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 59, 35, 60, 37, 38, 39, 40, 41, 42, 61, + 44, 45, 226, 52, 53, 54, 55, 56, 57, 14, + 15, 16, 17, 18, 19, 122, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 59, + 35, 60, 37, 38, 39, 40, 41, 42, 61, 44, + 45, 228, 52, 53, 54, 55, 56, 57, 14, 15, + 16, 17, 18, 19, 122, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 59, 35, + 60, 37, 38, 39, 40, 41, 42, 61, 44, 45, + 235, 52, 53, 54, 55, 56, 57, 14, 15, 16, + 17, 18, 19, 122, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 59, 35, 60, + 37, 38, 39, 40, 41, 42, 61, 44, 45, 238, + 52, 53, 54, 55, 56, 57, 14, 15, 16, 17, + 18, 19, 122, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 59, 35, 60, 37, + 38, 39, 40, 41, 42, 61, 44, 45, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 241, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 242, 309, 52, 53, + 54, 55, 56, 57, 14, 15, 16, 17, 18, 19, + 122, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 59, 35, 60, 37, 38, 39, + 40, 41, 42, 61, 44, 45, 311, 52, 53, 54, + 55, 56, 57, 14, 15, 16, 17, 18, 19, 122, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 59, 35, 60, 37, 38, 39, 40, + 41, 42, 61, 44, 45, 346, 52, 53, 54, 55, + 56, 57, 14, 15, 16, 17, 18, 19, 122, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 59, 35, 60, 37, 38, 39, 40, 41, + 42, 61, 44, 45, 52, 53, 54, 55, 56, 57, + 14, 15, 16, 17, 18, 19, 122, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 59, 35, 60, 37, 38, 39, 40, 41, 42, 61, + 44, 45, 111, 253, 254, 112, 113, 255, 256, 257, + 258, 114, 115, 116, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 117, 271, 272, 273, + 0, 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, 299, 300, 301, 302, + 303, 304, 305, 306, 307, 308, 313, 314, 315, 316, + 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, + 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, + 337, 338, 339, 340, 341, 342, 343, 344, 345, 348, + 351, 353, 354, 355, 356, 357, 358, 359, 360, 5, + 49 +}; + +static const short yycheck[] = +{ + 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, + 95, 96, 3, 98, 99, 100, 101, 102, 0, 104, + 105, 106, 107, 108, 33, 34, 111, 112, 113, 114, + 115, 116, 23, 0, 3, 0, 5, 122, 7, 124, + 125, 1, 42, 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, 3, 42, 12, 13, 14, 12, 13, + 14, 13, 14, 1, 63, 19, 23, 42, 1, 23, + 3, 42, 42, 23, 31, 42, 28, 42, 193, 194, + 42, 35, 36, 16, 13, 14, 1, 37, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 42, + 10, 11, 10, 32, 14, 15, 14, 15, 42, 38, + 42, 40, 41, 23, 42, 23, 231, 42, 42, 42, + 235, 42, 32, 238, 32, 42, 241, 1, 127, 42, + 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, + 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, 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, 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, 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, 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, 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, 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, 14, 42, 42, 17, 18, 42, 42, 42, + 42, 23, 24, 25, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 38, 42, 42, 42, + -1, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 2, + 5 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 44, 45, 46, 0, 46, 1, 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, 47, 49, 47, + 42, 1, 4, 5, 6, 7, 8, 9, 16, 30, + 32, 39, 42, 49, 42, 12, 13, 14, 19, 23, + 35, 36, 10, 11, 14, 15, 23, 32, 10, 14, + 15, 23, 32, 13, 14, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 32, 38, 40, 41, + 13, 14, 28, 1, 12, 13, 14, 23, 31, 33, + 34, 14, 17, 18, 23, 24, 25, 38, 1, 3, + 16, 42, 16, 48, 49, 16, 42, 49, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 48, 3, 23, 37, 3, 48, 3, 48, 3, + 48, 3, 48, 3, 48, 42, 3, 48, 3, 48, + 3, 48, 3, 48, 3, 48, 42, 42, 3, 48, + 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, + 3, 23, 42, 42, 1, 3, 48, 42, 3, 48, + 48, 16, 42, 49, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 3, + 48, 3, 48, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 3, 48, 42, 48, + 48, 42, 48, 42, 42, 42, 42, 42, 42, 42, + 42 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 88 "Grammar.y" + { +;} + break; + + case 3: +#line 91 "Grammar.y" + { +;} + break; + + case 4: +#line 99 "Grammar.y" + { +;} + break; + + case 5: +#line 102 "Grammar.y" + { +;} + break; + + case 6: +#line 108 "Grammar.y" + { + parser->checkInterrupted(); +;} + break; + + case 7: +#line 117 "Grammar.y" + { + parser->usage(); +;} + break; + + case 8: +#line 121 "Grammar.y" + { + return 0; +;} + break; + + case 9: +#line 125 "Grammar.y" + { + parser->addApplication(yyvsp[-1]); +;} + break; + + case 10: +#line 129 "Grammar.y" + { + parser->usage("application", "add"); +;} + break; + + case 11: +#line 133 "Grammar.y" + { + parser->removeApplication(yyvsp[-1]); +;} + break; + + case 12: +#line 137 "Grammar.y" + { + parser->usage("application", "remove"); +;} + break; + + case 13: +#line 141 "Grammar.y" + { + parser->diffApplication(yyvsp[-1]); +;} + break; + + case 14: +#line 145 "Grammar.y" + { + parser->usage("application", "diff"); +;} + break; + + case 15: +#line 149 "Grammar.y" + { + parser->updateApplication(yyvsp[-1]); +;} + break; + + case 16: +#line 153 "Grammar.y" + { + parser->usage("application", "update"); +;} + break; + + case 17: +#line 157 "Grammar.y" + { + parser->describeApplication(yyvsp[-1]); +;} + break; + + case 18: +#line 161 "Grammar.y" + { + parser->usage("application", "describe"); +;} + break; + + case 19: +#line 165 "Grammar.y" + { + parser->patchApplication(yyvsp[-1]); +;} + break; + + case 20: +#line 169 "Grammar.y" + { + parser->usage("application", "patch"); +;} + break; + + case 21: +#line 173 "Grammar.y" + { + parser->listAllApplications(yyvsp[-1]); +;} + break; + + case 22: +#line 177 "Grammar.y" + { + parser->usage("application", "list"); +;} + break; + + case 23: +#line 181 "Grammar.y" + { + parser->describeServerTemplate(yyvsp[-1]); +;} + break; + + case 24: +#line 185 "Grammar.y" + { + parser->usage("server template", "describe"); +;} + break; + + case 25: +#line 189 "Grammar.y" + { + parser->instantiateServerTemplate(yyvsp[-1]); +;} + break; + + case 26: +#line 193 "Grammar.y" + { + parser->usage("server template", "instantiate"); +;} + break; + + case 27: +#line 197 "Grammar.y" + { + parser->usage("server template"); +;} + break; + + case 28: +#line 201 "Grammar.y" + { + parser->describeServiceTemplate(yyvsp[-1]); +;} + break; + + case 29: +#line 205 "Grammar.y" + { + parser->usage("service template", "describe"); +;} + break; + + case 30: +#line 209 "Grammar.y" + { + parser->usage("service template"); +;} + break; + + case 31: +#line 213 "Grammar.y" + { + parser->describeNode(yyvsp[-1]); +;} + break; + + case 32: +#line 217 "Grammar.y" + { + parser->usage("node", "describe"); +;} + break; + + case 33: +#line 221 "Grammar.y" + { + parser->pingNode(yyvsp[-1]); +;} + break; + + case 34: +#line 225 "Grammar.y" + { + parser->usage("node", "ping"); +;} + break; + + case 35: +#line 229 "Grammar.y" + { + parser->printLoadNode(yyvsp[-1]); +;} + break; + + case 36: +#line 233 "Grammar.y" + { + parser->usage("node", "lost"); +;} + break; + + case 37: +#line 237 "Grammar.y" + { + parser->shutdownNode(yyvsp[-1]); +;} + break; + + case 38: +#line 241 "Grammar.y" + { + parser->usage("node", "shutdown"); +;} + break; + + case 39: +#line 245 "Grammar.y" + { + parser->listAllNodes(yyvsp[-1]); +;} + break; + + case 40: +#line 249 "Grammar.y" + { + parser->usage("node", "list"); +;} + break; + + case 41: +#line 253 "Grammar.y" + { + parser->showFile("node", yyvsp[-1]); +;} + break; + + case 42: +#line 257 "Grammar.y" + { + parser->usage("node", "show"); +;} + break; + + case 43: +#line 261 "Grammar.y" + { + parser->describeRegistry(yyvsp[-1]); +;} + break; + + case 44: +#line 265 "Grammar.y" + { + parser->usage("registry", "describe"); +;} + break; + + case 45: +#line 269 "Grammar.y" + { + parser->pingRegistry(yyvsp[-1]); +;} + break; + + case 46: +#line 273 "Grammar.y" + { + parser->usage("registry", "ping"); +;} + break; + + case 47: +#line 277 "Grammar.y" + { + parser->shutdownRegistry(yyvsp[-1]); +;} + break; + + case 48: +#line 281 "Grammar.y" + { + parser->usage("registry", "shutdown"); +;} + break; + + case 49: +#line 285 "Grammar.y" + { + parser->listAllRegistries(yyvsp[-1]); +;} + break; + + case 50: +#line 289 "Grammar.y" + { + parser->usage("registry", "list"); +;} + break; + + case 51: +#line 293 "Grammar.y" + { + parser->showFile("registry", yyvsp[-1]); +;} + break; + + case 52: +#line 297 "Grammar.y" + { + parser->usage("registry", "show"); +;} + break; + + case 53: +#line 301 "Grammar.y" + { + parser->removeServer(yyvsp[-1]); +;} + break; + + case 54: +#line 305 "Grammar.y" + { + parser->usage("server", "remove"); +;} + break; + + case 55: +#line 309 "Grammar.y" + { + parser->describeServer(yyvsp[-1]); +;} + break; + + case 56: +#line 313 "Grammar.y" + { + parser->usage("server", "describe"); +;} + break; + + case 57: +#line 317 "Grammar.y" + { + parser->startServer(yyvsp[-1]); +;} + break; + + case 58: +#line 321 "Grammar.y" + { + parser->usage("server", "start"); +;} + break; + + case 59: +#line 325 "Grammar.y" + { + parser->stopServer(yyvsp[-1]); +;} + break; + + case 60: +#line 329 "Grammar.y" + { + parser->usage("server", "stop"); +;} + break; + + case 61: +#line 333 "Grammar.y" + { + parser->patchServer(yyvsp[-1]); +;} + break; + + case 62: +#line 337 "Grammar.y" + { + parser->usage("server", "patch"); +;} + break; + + case 63: +#line 341 "Grammar.y" + { + parser->signalServer(yyvsp[-1]); +;} + break; + + case 64: +#line 345 "Grammar.y" + { + parser->usage("server", "signal"); +;} + break; + + case 65: +#line 349 "Grammar.y" + { + parser->writeMessage(yyvsp[-1], 1); +;} + break; + + case 66: +#line 353 "Grammar.y" + { + parser->usage("server", "stdout"); +;} + break; + + case 67: +#line 357 "Grammar.y" + { + parser->writeMessage(yyvsp[-1], 2); +;} + break; + + case 68: +#line 361 "Grammar.y" + { + parser->usage("server", "stderr"); +;} + break; + + case 69: +#line 365 "Grammar.y" + { + parser->stateServer(yyvsp[-1]); +;} + break; + + case 70: +#line 369 "Grammar.y" + { + parser->usage("server", "start"); +;} + break; + + case 71: +#line 373 "Grammar.y" + { + parser->pidServer(yyvsp[-1]); +;} + break; + + case 72: +#line 377 "Grammar.y" + { + parser->usage("server", "pid"); +;} + break; + + case 73: +#line 381 "Grammar.y" + { + parser->propertiesServer(yyvsp[-1], false); +;} + break; + + case 74: +#line 385 "Grammar.y" + { + parser->usage("server", "properties"); +;} + break; + + case 75: +#line 389 "Grammar.y" + { + parser->propertiesServer(yyvsp[-1], true); +;} + break; + + case 76: +#line 393 "Grammar.y" + { + parser->usage("server", "property"); +;} + break; + + case 77: +#line 397 "Grammar.y" + { + parser->enableServer(yyvsp[-1], true); +;} + break; + + case 78: +#line 401 "Grammar.y" + { + parser->usage("server", "enable"); +;} + break; + + case 79: +#line 405 "Grammar.y" + { + parser->enableServer(yyvsp[-1], false); +;} + break; + + case 80: +#line 409 "Grammar.y" + { + parser->usage("server", "disable"); +;} + break; + + case 81: +#line 413 "Grammar.y" + { + parser->listAllServers(yyvsp[-1]); +;} + break; + + case 82: +#line 417 "Grammar.y" + { + parser->usage("server", "list"); +;} + break; + + case 83: +#line 421 "Grammar.y" + { + parser->showFile("server", yyvsp[-1]); +;} + break; + + case 84: +#line 425 "Grammar.y" + { + parser->usage("server", "show"); +;} + break; + + case 85: +#line 429 "Grammar.y" + { + parser->startService(yyvsp[-1]); +;} + break; + + case 86: +#line 433 "Grammar.y" + { + parser->usage("service", "start"); +;} + break; + + case 87: +#line 437 "Grammar.y" + { + parser->stopService(yyvsp[-1]); +;} + break; + + case 88: +#line 441 "Grammar.y" + { + parser->usage("service", "stop"); +;} + break; + + case 89: +#line 445 "Grammar.y" + { + parser->describeService(yyvsp[-1]); +;} + break; + + case 90: +#line 449 "Grammar.y" + { + parser->usage("service", "describe"); +;} + break; + + case 91: +#line 453 "Grammar.y" + { + parser->propertiesService(yyvsp[-1], false); +;} + break; + + case 92: +#line 457 "Grammar.y" + { + parser->usage("service", "properties"); +;} + break; + + case 93: +#line 461 "Grammar.y" + { + parser->propertiesService(yyvsp[-1], true); +;} + break; + + case 94: +#line 465 "Grammar.y" + { + parser->usage("service", "property"); +;} + break; + + case 95: +#line 469 "Grammar.y" + { + parser->listServices(yyvsp[-1]); +;} + break; + + case 96: +#line 473 "Grammar.y" + { + parser->usage("service", "list"); +;} + break; + + case 97: +#line 477 "Grammar.y" + { + parser->endpointsAdapter(yyvsp[-1]); +;} + break; + + case 98: +#line 481 "Grammar.y" + { + parser->usage("adapter", "endpoints"); +;} + break; + + case 99: +#line 485 "Grammar.y" + { + parser->removeAdapter(yyvsp[-1]); +;} + break; + + case 100: +#line 489 "Grammar.y" + { + parser->usage("adapter", "remove"); +;} + break; + + case 101: +#line 493 "Grammar.y" + { + parser->listAllAdapters(yyvsp[-1]); +;} + break; + + case 102: +#line 497 "Grammar.y" + { + parser->usage("adapter", "list"); +;} + break; + + case 103: +#line 501 "Grammar.y" + { + parser->addObject(yyvsp[-1]); +;} + break; + + case 104: +#line 505 "Grammar.y" + { + parser->usage("object", "add"); +;} + break; + + case 105: +#line 509 "Grammar.y" + { + parser->removeObject(yyvsp[-1]); +;} + break; + + case 106: +#line 513 "Grammar.y" + { + parser->usage("object", "remove"); +;} + break; + + case 107: +#line 517 "Grammar.y" + { + parser->findObject(yyvsp[-1]); +;} + break; + + case 108: +#line 521 "Grammar.y" + { + parser->usage("object", "find"); +;} + break; + + case 109: +#line 525 "Grammar.y" + { + parser->listObject(yyvsp[-1]); +;} + break; + + case 110: +#line 529 "Grammar.y" + { + parser->usage("object", "list"); +;} + break; + + case 111: +#line 533 "Grammar.y" + { + parser->describeObject(yyvsp[-1]); +;} + break; + + case 112: +#line 537 "Grammar.y" + { + parser->usage("object", "describe"); +;} + break; + + case 113: +#line 541 "Grammar.y" + { + parser->showCopying(); +;} + break; + + case 114: +#line 545 "Grammar.y" + { + parser->showWarranty(); +;} + break; + + case 115: +#line 549 "Grammar.y" + { + parser->usage(yyvsp[-1].front()); +;} + break; + + case 116: +#line 553 "Grammar.y" + { + if((yyvsp[-2].front() == "server" || yyvsp[-2].front() == "service") && yyvsp[-1].front() == "template") + { + parser->usage(yyvsp[-2].front() + " " + yyvsp[-1].front()); + } + else + { + parser->usage(yyvsp[-2].front(), yyvsp[-1].front()); + } +;} + break; + + case 117: +#line 564 "Grammar.y" + { + parser->usage(yyvsp[-3].front(), yyvsp[-2].front()); +;} + break; + + case 118: +#line 568 "Grammar.y" + { + if((yyvsp[-3].front() == "server" || yyvsp[-3].front() == "service") && yyvsp[-2].front() == "template") + { + parser->usage(yyvsp[-3].front() + " " + yyvsp[-2].front(), yyvsp[-1].front()); + } + else + { + parser->usage(yyvsp[-3].front(), yyvsp[-2].front()); + } +;} + break; + + case 119: +#line 579 "Grammar.y" + { + if((yyvsp[-4].front() == "server" || yyvsp[-4].front() == "service") && yyvsp[-3].front() == "template") + { + parser->usage(yyvsp[-4].front() + " " + yyvsp[-3].front(), yyvsp[-2].front()); + } + else + { + parser->usage(yyvsp[-4].front(), yyvsp[-3].front()); + } +;} + break; + + case 120: +#line 590 "Grammar.y" + { + parser->usage(yyvsp[-2].front()); +;} + break; + + case 121: +#line 594 "Grammar.y" + { + parser->usage(); +;} + break; + + case 122: +#line 598 "Grammar.y" + { + parser->usage(yyvsp[-2].front()); +;} + break; + + case 123: +#line 602 "Grammar.y" + { + yyvsp[-3].push_back(yyvsp[-2].front()); + parser->invalidCommand(yyvsp[-3]); + yyerrok; +;} + break; + + case 124: +#line 608 "Grammar.y" + { + parser->invalidCommand(yyvsp[-2]); + yyerrok; +;} + break; + + case 125: +#line 613 "Grammar.y" + { + parser->invalidCommand(yyvsp[-2]); + yyerrok; +;} + break; + + case 126: +#line 618 "Grammar.y" + { + yyerrok; +;} + break; + + case 127: +#line 622 "Grammar.y" + { +;} + break; + + case 128: +#line 631 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 129: +#line 636 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 130: +#line 641 "Grammar.y" + { + yyval = yyvsp[-1]; + yyval.push_front("help"); + yyval.push_front(yyvsp[-2].front()); +;} + break; + + case 131: +#line 647 "Grammar.y" + { + yyval = yyvsp[-1]; + yyval.push_front("help"); + yyval.push_front(yyvsp[-2].front()); +;} + break; + + case 132: +#line 653 "Grammar.y" + { + yyval = YYSTYPE(); +;} + break; + + case 133: +#line 662 "Grammar.y" + { +;} + break; + + case 134: +#line 665 "Grammar.y" + { +;} + break; + + case 135: +#line 668 "Grammar.y" + { +;} + break; + + case 136: +#line 671 "Grammar.y" + { +;} + break; + + case 137: +#line 674 "Grammar.y" + { +;} + break; + + case 138: +#line 677 "Grammar.y" + { +;} + break; + + case 139: +#line 680 "Grammar.y" + { +;} + break; + + case 140: +#line 683 "Grammar.y" + { +;} + break; + + case 141: +#line 686 "Grammar.y" + { +;} + break; + + case 142: +#line 689 "Grammar.y" + { +;} + break; + + case 143: +#line 692 "Grammar.y" + { +;} + break; + + case 144: +#line 695 "Grammar.y" + { +;} + break; + + case 145: +#line 698 "Grammar.y" + { +;} + break; + + case 146: +#line 701 "Grammar.y" + { +;} + break; + + case 147: +#line 704 "Grammar.y" + { +;} + break; + + case 148: +#line 707 "Grammar.y" + { +;} + break; + + case 149: +#line 710 "Grammar.y" + { +;} + break; + + case 150: +#line 713 "Grammar.y" + { +;} + break; + + case 151: +#line 716 "Grammar.y" + { +;} + break; + + case 152: +#line 719 "Grammar.y" + { +;} + break; + + case 153: +#line 722 "Grammar.y" + { +;} + break; + + case 154: +#line 725 "Grammar.y" + { +;} + break; + + case 155: +#line 728 "Grammar.y" + { +;} + break; + + case 156: +#line 731 "Grammar.y" + { +;} + break; + + case 157: +#line 734 "Grammar.y" + { +;} + break; + + case 158: +#line 737 "Grammar.y" + { +;} + break; + + case 159: +#line 740 "Grammar.y" + { +;} + break; + + case 160: +#line 743 "Grammar.y" + { +;} + break; + + case 161: +#line 746 "Grammar.y" + { +;} + break; + + case 162: +#line 749 "Grammar.y" + { +;} + break; + + case 163: +#line 752 "Grammar.y" + { +;} + break; + + case 164: +#line 755 "Grammar.y" + { +;} + break; + + case 165: +#line 758 "Grammar.y" + { +;} + break; + + case 166: +#line 761 "Grammar.y" + { +;} + break; + + case 167: +#line 764 "Grammar.y" + { +;} + break; + + case 168: +#line 767 "Grammar.y" + { +;} + break; + + case 169: +#line 770 "Grammar.y" + { +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 3000 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + + diff --git a/cpp/src/IceGrid/Grammar.h b/cpp/src/IceGrid/Grammar.h new file mode 100644 index 00000000000..2c459182ea0 --- /dev/null +++ b/cpp/src/IceGrid/Grammar.h @@ -0,0 +1,126 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_GRID_HELP = 258, + ICE_GRID_EXIT = 259, + ICE_GRID_APPLICATION = 260, + ICE_GRID_NODE = 261, + ICE_GRID_REGISTRY = 262, + ICE_GRID_SERVER = 263, + ICE_GRID_ADAPTER = 264, + ICE_GRID_PING = 265, + ICE_GRID_LOAD = 266, + ICE_GRID_ADD = 267, + ICE_GRID_REMOVE = 268, + ICE_GRID_LIST = 269, + ICE_GRID_SHUTDOWN = 270, + ICE_GRID_STRING = 271, + ICE_GRID_START = 272, + ICE_GRID_STOP = 273, + ICE_GRID_PATCH = 274, + ICE_GRID_SIGNAL = 275, + ICE_GRID_STDOUT = 276, + ICE_GRID_STDERR = 277, + ICE_GRID_DESCRIBE = 278, + ICE_GRID_PROPERTIES = 279, + ICE_GRID_PROPERTY = 280, + ICE_GRID_STATE = 281, + ICE_GRID_PID = 282, + ICE_GRID_ENDPOINTS = 283, + ICE_GRID_ACTIVATION = 284, + ICE_GRID_OBJECT = 285, + ICE_GRID_FIND = 286, + ICE_GRID_SHOW = 287, + ICE_GRID_COPYING = 288, + ICE_GRID_WARRANTY = 289, + ICE_GRID_DIFF = 290, + ICE_GRID_UPDATE = 291, + ICE_GRID_INSTANTIATE = 292, + ICE_GRID_TEMPLATE = 293, + ICE_GRID_SERVICE = 294, + ICE_GRID_ENABLE = 295, + ICE_GRID_DISABLE = 296 + }; +#endif +#define ICE_GRID_HELP 258 +#define ICE_GRID_EXIT 259 +#define ICE_GRID_APPLICATION 260 +#define ICE_GRID_NODE 261 +#define ICE_GRID_REGISTRY 262 +#define ICE_GRID_SERVER 263 +#define ICE_GRID_ADAPTER 264 +#define ICE_GRID_PING 265 +#define ICE_GRID_LOAD 266 +#define ICE_GRID_ADD 267 +#define ICE_GRID_REMOVE 268 +#define ICE_GRID_LIST 269 +#define ICE_GRID_SHUTDOWN 270 +#define ICE_GRID_STRING 271 +#define ICE_GRID_START 272 +#define ICE_GRID_STOP 273 +#define ICE_GRID_PATCH 274 +#define ICE_GRID_SIGNAL 275 +#define ICE_GRID_STDOUT 276 +#define ICE_GRID_STDERR 277 +#define ICE_GRID_DESCRIBE 278 +#define ICE_GRID_PROPERTIES 279 +#define ICE_GRID_PROPERTY 280 +#define ICE_GRID_STATE 281 +#define ICE_GRID_PID 282 +#define ICE_GRID_ENDPOINTS 283 +#define ICE_GRID_ACTIVATION 284 +#define ICE_GRID_OBJECT 285 +#define ICE_GRID_FIND 286 +#define ICE_GRID_SHOW 287 +#define ICE_GRID_COPYING 288 +#define ICE_GRID_WARRANTY 289 +#define ICE_GRID_DIFF 290 +#define ICE_GRID_UPDATE 291 +#define ICE_GRID_INSTANTIATE 292 +#define ICE_GRID_TEMPLATE 293 +#define ICE_GRID_SERVICE 294 +#define ICE_GRID_ENABLE 295 +#define ICE_GRID_DISABLE 296 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/src/IceGrid/Makefile b/cpp/src/IceGrid/Makefile index e3a135d0926..7fe143ef00d 100644 --- a/cpp/src/IceGrid/Makefile +++ b/cpp/src/IceGrid/Makefile @@ -148,10 +148,6 @@ clean:: # Needed for make -jn to work. #../IceGrid/Grammar.y: Grammar.h -clean:: - rm -f Grammar.cpp Grammar.h - rm -f Scanner.cpp - install:: all $(call installprogram,$(ADMIN),$(install_bindir)) $(call installprogram,$(NODE_SERVER),$(install_bindir)) diff --git a/cpp/src/IceGrid/Makefile.mak b/cpp/src/IceGrid/Makefile.mak index 6bee5960653..a8db26b4472 100644 --- a/cpp/src/IceGrid/Makefile.mak +++ b/cpp/src/IceGrid/Makefile.mak @@ -184,8 +184,6 @@ clean:: -del /q $(NODE_SERVER:.exe=.*) -del /q $(REGISTRY_SERVER:.exe=.*) -del /q IceGridAdmin.res IceGridNode.res IceGridRegistry.res - -del /q Grammar.cpp Grammar.h - -del /q Scanner.cpp install:: all copy $(ADMIN) $(install_bindir) diff --git a/cpp/src/IceGrid/Scanner.cpp b/cpp/src/IceGrid/Scanner.cpp new file mode 100644 index 00000000000..f5379d68444 --- /dev/null +++ b/cpp/src/IceGrid/Scanner.cpp @@ -0,0 +1,1790 @@ +#include +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 8 +#define YY_END_OF_BUFFER 9 +static yyconst short int yy_accept[19] = + { 0, + 3, 3, 9, 7, 3, 4, 5, 6, 7, 4, + 7, 3, 0, 2, 1, 0, 3, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 1, + 1, 6, 1, 1, 1, 1, 7, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 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, 9, 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, 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 int yy_meta[10] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst short int yy_base[19] = + { 0, + 0, 0, 11, 22, 8, 22, 22, 22, 12, 22, + 18, 0, 0, 22, 22, 0, 22, 22 + } ; + +static yyconst short int yy_def[19] = + { 0, + 18, 1, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 5, 11, 18, 18, 11, 18, 0 + } ; + +static yyconst short int yy_nxt[32] = + { 0, + 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, + 18, 18, 18, 18, 18, 18, 13, 14, 15, 16, + 17, 3, 18, 18, 18, 18, 18, 18, 18, 18, + 18 + } ; + +static yyconst short int yy_chk[32] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, + 3, 0, 0, 0, 0, 0, 5, 9, 9, 11, + 11, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; +using namespace Ice; +using namespace IceGrid; + +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) + +namespace IceGrid +{ + +typedef std::map StringTokenMap; +static StringTokenMap keywordMap; + +void initScanner(); + +} +#define YY_USER_INIT initScanner(); + +#define YY_ALWAYS_INTERACTIVE 1 +#line 416 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 50 "Scanner.l" + + +#line 570 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 19 ) + 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_base[yy_current_state] != 22 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 52 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 62 "Scanner.l" +{ + // C-style comment + while(true) + { + int c = yyinput(); + if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + unput(next); + } + } + else if(c == EOF) + { + parser->warning("EOF in comment"); + break; + } + } +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 87 "Scanner.l" +{ + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) + { + if(yytext[i] == '\\') + { + parser->continueLine(); + } + } +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 98 "Scanner.l" +{ + return ';'; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 102 "Scanner.l" +{ + // "..."-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '"') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + switch(next) + { + case '\\': + case '"': + { + s += next; + break; + } + + case 'n': + { + s += '\n'; + break; + } + + case 'r': + { + s += '\r'; + break; + } + + case 't': + { + s += '\t'; + break; + } + + case 'v': + { + s += '\v'; + break; + } + + case 'f': + { + s += '\f'; + break; + } + + default: + { + s += c; + unput(next); + } + } + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return ICE_GRID_STRING; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 176 "Scanner.l" +{ + // '...'-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '\'') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return ICE_GRID_STRING; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 201 "Scanner.l" +{ + // Simple strings + string s; + s += yytext[0]; + while(true) + { + char c = static_cast(yyinput()); + if(c == EOF) + { + break; + } + else if(isspace(static_cast(c)) || c == ';') + { + unput(c); + break; + } + + s += c; + } + + yylvalp->clear(); + yylvalp->push_back(s); + + StringTokenMap::const_iterator pos = keywordMap.find(s); + return pos != keywordMap.end() ? pos->second : ICE_GRID_STRING; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 228 "Scanner.l" +ECHO; + YY_BREAK +#line 855 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 19 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 19 ) + 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 == 18); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 228 "Scanner.l" + + +namespace IceGrid { + +// +// initScanner() fills the keyword map with all keyword-token pairs. +// + +void +initScanner() +{ + keywordMap["help"] = ICE_GRID_HELP; + keywordMap["quit"] = ICE_GRID_EXIT; + keywordMap["exit"] = ICE_GRID_EXIT; + keywordMap["application"] = ICE_GRID_APPLICATION; + keywordMap["server"] = ICE_GRID_SERVER; + keywordMap["adapter"] = ICE_GRID_ADAPTER; + keywordMap["add"] = ICE_GRID_ADD; + keywordMap["remove"] = ICE_GRID_REMOVE; + keywordMap["list"] = ICE_GRID_LIST; + keywordMap["shutdown"] = ICE_GRID_SHUTDOWN; + keywordMap["describe"] = ICE_GRID_DESCRIBE; + keywordMap["properties"] = ICE_GRID_PROPERTIES; + keywordMap["property"] = ICE_GRID_PROPERTY; + keywordMap["state"] = ICE_GRID_STATE; + keywordMap["pid"] = ICE_GRID_PID; + keywordMap["endpoints"] = ICE_GRID_ENDPOINTS; + keywordMap["start"] = ICE_GRID_START; + keywordMap["patch"] = ICE_GRID_PATCH; + keywordMap["stop"] = ICE_GRID_STOP; + keywordMap["signal"] = ICE_GRID_SIGNAL; + keywordMap["stdout"] = ICE_GRID_STDOUT; + keywordMap["stderr"] = ICE_GRID_STDERR; + keywordMap["node"] = ICE_GRID_NODE; + keywordMap["registry"] = ICE_GRID_REGISTRY; + keywordMap["ping"] = ICE_GRID_PING; + keywordMap["load"] = ICE_GRID_LOAD; + keywordMap["activation"] = ICE_GRID_ACTIVATION; + keywordMap["object"] = ICE_GRID_OBJECT; + keywordMap["find"] = ICE_GRID_FIND; + keywordMap["show"] = ICE_GRID_SHOW; + keywordMap["copying"] = ICE_GRID_COPYING; + keywordMap["warranty"] = ICE_GRID_WARRANTY; + keywordMap["diff"] = ICE_GRID_DIFF; + keywordMap["update"] = ICE_GRID_UPDATE; + keywordMap["instantiate"] = ICE_GRID_INSTANTIATE; + keywordMap["template"] = ICE_GRID_TEMPLATE; + keywordMap["service"] = ICE_GRID_SERVICE; + keywordMap["enable"] = ICE_GRID_ENABLE; + keywordMap["disable"] = ICE_GRID_DISABLE; +} + +} diff --git a/cpp/src/IceStorm/.gitignore b/cpp/src/IceStorm/.gitignore index 4b4d093745b..b64cca51538 100644 --- a/cpp/src/IceStorm/.gitignore +++ b/cpp/src/IceStorm/.gitignore @@ -25,6 +25,3 @@ V31FormatDB.h V31FormatDB.cpp LLUMap.h LLUMap.cpp -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/src/IceStorm/Grammar.cpp b/cpp/src/IceStorm/Grammar.cpp new file mode 100644 index 00000000000..05a4dcdb6fa --- /dev/null +++ b/cpp/src/IceStorm/Grammar.cpp @@ -0,0 +1,1484 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_STORM_HELP = 258, + ICE_STORM_EXIT = 259, + ICE_STORM_CURRENT = 260, + ICE_STORM_CREATE = 261, + ICE_STORM_DESTROY = 262, + ICE_STORM_LINK = 263, + ICE_STORM_UNLINK = 264, + ICE_STORM_LINKS = 265, + ICE_STORM_TOPICS = 266, + ICE_STORM_REPLICA = 267, + ICE_STORM_STRING = 268 + }; +#endif +#define ICE_STORM_HELP 258 +#define ICE_STORM_EXIT 259 +#define ICE_STORM_CURRENT 260 +#define ICE_STORM_CREATE 261 +#define ICE_STORM_DESTROY 262 +#define ICE_STORM_LINK 263 +#define ICE_STORM_UNLINK 264 +#define ICE_STORM_LINKS 265 +#define ICE_STORM_TOPICS 266 +#define ICE_STORM_REPLICA 267 +#define ICE_STORM_STRING 268 + + + + +/* Copy the first part of user declarations. */ +#line 1 "Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; +using namespace Ice; +using namespace IceStorm; + +void +yyerror(const char* s) +{ + parser->error(s); +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 147 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 40 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 62 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 15 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 6 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 30 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 53 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 268 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 14, + 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 6, 9, 11, 14, 17, 21, + 25, 29, 33, 37, 41, 45, 49, 53, 56, 58, + 61, 64, 65, 67, 69, 71, 73, 75, 77, 79, + 81 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 16, 0, -1, 17, -1, -1, 17, 18, -1, 18, + -1, 3, 14, -1, 4, 14, -1, 6, 19, 14, + -1, 5, 19, 14, -1, 7, 19, 14, -1, 8, + 19, 14, -1, 9, 19, 14, -1, 10, 19, 14, + -1, 11, 19, 14, -1, 12, 19, 14, -1, 13, + 1, 14, -1, 1, 14, -1, 14, -1, 13, 19, + -1, 20, 19, -1, -1, 3, -1, 4, -1, 5, + -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, + -1, 11, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 59, 59, 63, 70, 73, 81, 85, 89, 93, + 97, 101, 105, 109, 113, 117, 121, 125, 129, 137, + 142, 148, 156, 159, 162, 165, 168, 171, 174, 177, + 180 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ICE_STORM_HELP", "ICE_STORM_EXIT", + "ICE_STORM_CURRENT", "ICE_STORM_CREATE", "ICE_STORM_DESTROY", + "ICE_STORM_LINK", "ICE_STORM_UNLINK", "ICE_STORM_LINKS", + "ICE_STORM_TOPICS", "ICE_STORM_REPLICA", "ICE_STORM_STRING", "';'", + "$accept", "start", "commands", "command", "strings", "keyword", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 15, 16, 16, 17, 17, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, + 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, + 20 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 0, 2, 1, 2, 2, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 2, 1, 2, + 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, + 21, 21, 0, 18, 0, 0, 5, 17, 6, 7, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 21, + 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 4, 19, 9, 20, 8, 10, 11, 12, 13, + 14, 15, 16 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 14, 15, 16, 30, 31 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -7 +static const yysigned_char yypact[] = +{ + 7, 8, 9, 11, 39, 39, 39, 39, 39, 39, + 39, 39, 28, -7, 51, 27, -7, -7, -7, -7, + -7, -7, -7, -7, -7, -7, -7, -7, -7, 39, + 40, 39, 41, 42, 43, 44, 45, 46, 47, 48, + -7, -7, -7, -7, -7, -7, -7, -7, -7, -7, + -7, -7, -7 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -7, -7, -7, -6, -5, -7 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -4 +static const yysigned_char yytable[] = +{ + 32, 33, 34, 35, 36, 37, 38, -3, 1, 41, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 17, 18, 42, 19, 44, -2, 1, 39, + 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + 12, 13, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 40, 29, 0, 43, 45, 46, 47, 48, 49, + 50, 51, 52 +}; + +static const yysigned_char yycheck[] = +{ + 5, 6, 7, 8, 9, 10, 11, 0, 1, 15, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 14, 14, 29, 14, 31, 0, 1, 1, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 0, 13, -1, 14, 14, 14, 14, 14, 14, + 14, 14, 14 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 1, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 16, 17, 18, 14, 14, 14, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, + 19, 20, 19, 19, 19, 19, 19, 19, 19, 1, + 0, 18, 19, 14, 19, 14, 14, 14, 14, 14, + 14, 14, 14 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 60 "Grammar.y" + { +;} + break; + + case 3: +#line 63 "Grammar.y" + { +;} + break; + + case 4: +#line 71 "Grammar.y" + { +;} + break; + + case 5: +#line 74 "Grammar.y" + { +;} + break; + + case 6: +#line 82 "Grammar.y" + { + parser->usage(); +;} + break; + + case 7: +#line 86 "Grammar.y" + { + return 0; +;} + break; + + case 8: +#line 90 "Grammar.y" + { + parser->create(yyvsp[-1]); +;} + break; + + case 9: +#line 94 "Grammar.y" + { + parser->current(yyvsp[-1]); +;} + break; + + case 10: +#line 98 "Grammar.y" + { + parser->destroy(yyvsp[-1]); +;} + break; + + case 11: +#line 102 "Grammar.y" + { + parser->link(yyvsp[-1]); +;} + break; + + case 12: +#line 106 "Grammar.y" + { + parser->unlink(yyvsp[-1]); +;} + break; + + case 13: +#line 110 "Grammar.y" + { + parser->links(yyvsp[-1]); +;} + break; + + case 14: +#line 114 "Grammar.y" + { + parser->topics(yyvsp[-1]); +;} + break; + + case 15: +#line 118 "Grammar.y" + { + parser->replica(yyvsp[-1]); +;} + break; + + case 16: +#line 122 "Grammar.y" + { + parser->invalidCommand("unknown command `" + yyvsp[-2].front() + "' (type `help' for more info)"); +;} + break; + + case 17: +#line 126 "Grammar.y" + { + yyerrok; +;} + break; + + case 18: +#line 130 "Grammar.y" + { +;} + break; + + case 19: +#line 138 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 20: +#line 143 "Grammar.y" + { + yyval = yyvsp[0]; + yyval.push_front(yyvsp[-1].front()); +;} + break; + + case 21: +#line 148 "Grammar.y" + { + yyval = YYSTYPE(); +;} + break; + + case 22: +#line 157 "Grammar.y" + { +;} + break; + + case 23: +#line 160 "Grammar.y" + { +;} + break; + + case 24: +#line 163 "Grammar.y" + { +;} + break; + + case 25: +#line 166 "Grammar.y" + { +;} + break; + + case 26: +#line 169 "Grammar.y" + { +;} + break; + + case 27: +#line 172 "Grammar.y" + { +;} + break; + + case 28: +#line 175 "Grammar.y" + { +;} + break; + + case 29: +#line 178 "Grammar.y" + { +;} + break; + + case 30: +#line 181 "Grammar.y" + { +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 1258 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 184 "Grammar.y" + + diff --git a/cpp/src/IceStorm/Grammar.h b/cpp/src/IceStorm/Grammar.h new file mode 100644 index 00000000000..e685dcc41c1 --- /dev/null +++ b/cpp/src/IceStorm/Grammar.h @@ -0,0 +1,70 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_STORM_HELP = 258, + ICE_STORM_EXIT = 259, + ICE_STORM_CURRENT = 260, + ICE_STORM_CREATE = 261, + ICE_STORM_DESTROY = 262, + ICE_STORM_LINK = 263, + ICE_STORM_UNLINK = 264, + ICE_STORM_LINKS = 265, + ICE_STORM_TOPICS = 266, + ICE_STORM_REPLICA = 267, + ICE_STORM_STRING = 268 + }; +#endif +#define ICE_STORM_HELP 258 +#define ICE_STORM_EXIT 259 +#define ICE_STORM_CURRENT 260 +#define ICE_STORM_CREATE 261 +#define ICE_STORM_DESTROY 262 +#define ICE_STORM_LINK 263 +#define ICE_STORM_UNLINK 264 +#define ICE_STORM_LINKS 265 +#define ICE_STORM_TOPICS 266 +#define ICE_STORM_REPLICA 267 +#define ICE_STORM_STRING 268 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/src/IceStorm/Makefile b/cpp/src/IceStorm/Makefile index cf3c0ed2053..4d8f0a16e28 100644 --- a/cpp/src/IceStorm/Makefile +++ b/cpp/src/IceStorm/Makefile @@ -157,8 +157,6 @@ clean:: -rm -f V32FormatDB.h V32FormatDB.cpp -rm -f V31FormatDB.h V31FormatDB.cpp -rm -f LLUMap.h LLUMap.cpp - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) diff --git a/cpp/src/IceStorm/Makefile.mak b/cpp/src/IceStorm/Makefile.mak index 091b7488aa5..abd7abe4ef8 100644 --- a/cpp/src/IceStorm/Makefile.mak +++ b/cpp/src/IceStorm/Makefile.mak @@ -194,10 +194,6 @@ clean:: -del /q $(MIGRATE:.exe=.*) -del /q IceStormAdmin.res IceStormMigrate.res IceStorm.res IceStormService.res -clean:: - del /q Grammar.cpp Grammar.h - del /q Scanner.cpp - install:: all copy $(LIBNAME) $(install_libdir) copy $(DLLNAME) $(install_bindir) diff --git a/cpp/src/IceStorm/Scanner.cpp b/cpp/src/IceStorm/Scanner.cpp new file mode 100644 index 00000000000..e4938c279da --- /dev/null +++ b/cpp/src/IceStorm/Scanner.cpp @@ -0,0 +1,1762 @@ +#include +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 8 +#define YY_END_OF_BUFFER 9 +static yyconst short int yy_accept[19] = + { 0, + 3, 3, 9, 7, 3, 4, 5, 6, 7, 4, + 7, 3, 0, 2, 1, 0, 3, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 5, 1, + 1, 6, 1, 1, 1, 1, 7, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 8, 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, 9, 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, 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 int yy_meta[10] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst short int yy_base[19] = + { 0, + 0, 0, 11, 22, 8, 22, 22, 22, 12, 22, + 18, 0, 0, 22, 22, 0, 22, 22 + } ; + +static yyconst short int yy_def[19] = + { 0, + 18, 1, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 5, 11, 18, 18, 11, 18, 0 + } ; + +static yyconst short int yy_nxt[32] = + { 0, + 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, + 18, 18, 18, 18, 18, 18, 13, 14, 15, 16, + 17, 3, 18, 18, 18, 18, 18, 18, 18, 18, + 18 + } ; + +static yyconst short int yy_chk[32] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, + 3, 0, 0, 0, 0, 0, 5, 9, 9, 11, + 11, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; +using namespace Ice; +using namespace IceStorm; + +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) + +namespace IceStorm +{ + +typedef std::map StringTokenMap; +static StringTokenMap keywordMap; + +void initScanner(); + +} +#define YY_USER_INIT initScanner(); + +#define YY_ALWAYS_INTERACTIVE 1 +#line 416 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 50 "Scanner.l" + + +#line 570 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 19 ) + 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_base[yy_current_state] != 22 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 52 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 62 "Scanner.l" +{ + // C-style comment + while(true) + { + int c = yyinput(); + if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + unput(next); + } + } + else if(c == EOF) + { + parser->warning("EOF in comment"); + break; + } + } +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 87 "Scanner.l" +{ + size_t len = strlen(yytext); + for(size_t i = 0; i < len; ++i) + { + if(yytext[i] == '\\') + { + parser->continueLine(); + } + } +} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 98 "Scanner.l" +{ + return ';'; +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 102 "Scanner.l" +{ + // "..."-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '"') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + switch(next) + { + case '\\': + case '"': + { + s += next; + break; + } + + case 'n': + { + s += '\n'; + break; + } + + case 'r': + { + s += '\r'; + break; + } + + case 't': + { + s += '\t'; + break; + } + + case 'v': + { + s += '\v'; + break; + } + + case 'f': + { + s += '\f'; + break; + } + + default: + { + s += c; + unput(next); + } + } + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return ICE_STORM_STRING; +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 176 "Scanner.l" +{ + // '...'-type strings + string s; + while(true) + { + char c = static_cast(yyinput()); + if(c == '\'') + { + break; + } + else if(c == EOF) + { + parser->warning("EOF in string"); + break; + } + else + { + s += c; + } + } + yylvalp->clear(); + yylvalp->push_back(s); + return ICE_STORM_STRING; +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 201 "Scanner.l" +{ + // Simple strings + string s; + s += yytext[0]; + while(true) + { + char c = static_cast(yyinput()); + if(c == EOF) + { + break; + } + else if(isspace(static_cast(c)) || c == ';') + { + unput(c); + break; + } + + s += c; + } + + yylvalp->clear(); + yylvalp->push_back(s); + + StringTokenMap::const_iterator pos = keywordMap.find(s); + return pos != keywordMap.end() ? pos->second : ICE_STORM_STRING; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 228 "Scanner.l" +ECHO; + YY_BREAK +#line 855 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 19 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 19 ) + 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 == 18); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 228 "Scanner.l" + + +namespace IceStorm { + +// +// initScanner() fills the keyword map with all keyword-token pairs. +// + +void +initScanner() +{ + keywordMap["help"] = ICE_STORM_HELP; + keywordMap["quit"] = ICE_STORM_EXIT; + keywordMap["exit"] = ICE_STORM_EXIT; + keywordMap["current"] = ICE_STORM_CURRENT; + keywordMap["create"] = ICE_STORM_CREATE; + keywordMap["destroy"] = ICE_STORM_DESTROY; + keywordMap["link"] = ICE_STORM_LINK; + keywordMap["unlink"] = ICE_STORM_UNLINK; + keywordMap["links"] = ICE_STORM_LINKS; + keywordMap["topics"] = ICE_STORM_TOPICS; + keywordMap["replica"] = ICE_STORM_REPLICA; +} + +} diff --git a/cpp/src/Slice/.gitignore b/cpp/src/Slice/.gitignore deleted file mode 100644 index da581c67fd4..00000000000 --- a/cpp/src/Slice/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -// Generated by makegitignore.py - -// IMPORTANT: Do not edit this file -- any edits made here will be lost! -Grammar.cpp -Grammar.h -Scanner.cpp diff --git a/cpp/src/Slice/Grammar.cpp b/cpp/src/Slice/Grammar.cpp new file mode 100644 index 00000000000..9d94b2eae25 --- /dev/null +++ b/cpp/src/Slice/Grammar.cpp @@ -0,0 +1,3655 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* If NAME_PREFIX is specified substitute the variables and functions + names. */ +#define yyparse slice_parse +#define yylex slice_lex +#define yyerror slice_error +#define yylval slice_lval +#define yychar slice_char +#define yydebug slice_debug +#define yynerrs slice_nerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_MODULE = 258, + ICE_CLASS = 259, + ICE_INTERFACE = 260, + ICE_EXCEPTION = 261, + ICE_STRUCT = 262, + ICE_SEQUENCE = 263, + ICE_DICTIONARY = 264, + ICE_ENUM = 265, + ICE_OUT = 266, + ICE_EXTENDS = 267, + ICE_IMPLEMENTS = 268, + ICE_THROWS = 269, + ICE_VOID = 270, + ICE_BYTE = 271, + ICE_BOOL = 272, + ICE_SHORT = 273, + ICE_INT = 274, + ICE_LONG = 275, + ICE_FLOAT = 276, + ICE_DOUBLE = 277, + ICE_STRING = 278, + ICE_OBJECT = 279, + ICE_LOCAL_OBJECT = 280, + ICE_LOCAL = 281, + ICE_CONST = 282, + ICE_FALSE = 283, + ICE_TRUE = 284, + ICE_NONMUTATING = 285, + ICE_IDEMPOTENT = 286, + ICE_SCOPE_DELIMITER = 287, + ICE_IDENTIFIER = 288, + ICE_STRING_LITERAL = 289, + ICE_INTEGER_LITERAL = 290, + ICE_FLOATING_POINT_LITERAL = 291, + ICE_IDENT_OP = 292, + ICE_KEYWORD_OP = 293, + ICE_METADATA_OPEN = 294, + ICE_METADATA_CLOSE = 295, + ICE_GLOBAL_METADATA_OPEN = 296, + ICE_GLOBAL_METADATA_CLOSE = 297, + BAD_CHAR = 298 + }; +#endif +#define ICE_MODULE 258 +#define ICE_CLASS 259 +#define ICE_INTERFACE 260 +#define ICE_EXCEPTION 261 +#define ICE_STRUCT 262 +#define ICE_SEQUENCE 263 +#define ICE_DICTIONARY 264 +#define ICE_ENUM 265 +#define ICE_OUT 266 +#define ICE_EXTENDS 267 +#define ICE_IMPLEMENTS 268 +#define ICE_THROWS 269 +#define ICE_VOID 270 +#define ICE_BYTE 271 +#define ICE_BOOL 272 +#define ICE_SHORT 273 +#define ICE_INT 274 +#define ICE_LONG 275 +#define ICE_FLOAT 276 +#define ICE_DOUBLE 277 +#define ICE_STRING 278 +#define ICE_OBJECT 279 +#define ICE_LOCAL_OBJECT 280 +#define ICE_LOCAL 281 +#define ICE_CONST 282 +#define ICE_FALSE 283 +#define ICE_TRUE 284 +#define ICE_NONMUTATING 285 +#define ICE_IDEMPOTENT 286 +#define ICE_SCOPE_DELIMITER 287 +#define ICE_IDENTIFIER 288 +#define ICE_STRING_LITERAL 289 +#define ICE_INTEGER_LITERAL 290 +#define ICE_FLOATING_POINT_LITERAL 291 +#define ICE_IDENT_OP 292 +#define ICE_KEYWORD_OP 293 +#define ICE_METADATA_OPEN 294 +#define ICE_METADATA_CLOSE 295 +#define ICE_GLOBAL_METADATA_OPEN 296 +#define ICE_GLOBAL_METADATA_CLOSE 297 +#define BAD_CHAR 298 + + + + +/* Copy the first part of user declarations. */ +#line 1 "../Slice/Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; +using namespace Slice; + +void +slice_error(const char* s) +{ + // yacc and recent versions of Bison use "syntax error" instead + // of "parse error". + + if (strcmp(s, "parse error") == 0) + { + unit->error("syntax error"); + } + else + { + unit->error(s); + } +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 226 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 13 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 775 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 53 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 67 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 184 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 269 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 298 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, 47, 51, 2, 48, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 44, + 49, 52, 50, 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, 45, 2, 46, 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 YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned short yyprhs[] = +{ + 0, 0, 3, 5, 9, 13, 14, 15, 19, 20, + 26, 27, 32, 35, 36, 38, 40, 42, 44, 46, + 48, 50, 52, 54, 56, 58, 60, 62, 63, 70, + 73, 76, 79, 80, 88, 91, 92, 97, 101, 104, + 105, 108, 110, 113, 116, 119, 120, 127, 132, 136, + 139, 140, 142, 145, 148, 151, 152, 161, 164, 165, + 168, 169, 174, 178, 181, 182, 184, 187, 189, 191, + 193, 196, 200, 204, 207, 211, 215, 216, 222, 223, + 229, 231, 233, 236, 239, 242, 243, 251, 255, 257, + 259, 262, 263, 268, 272, 275, 276, 278, 282, 284, + 286, 288, 296, 304, 315, 326, 329, 332, 333, 340, + 346, 350, 352, 354, 356, 357, 359, 360, 361, 365, + 371, 376, 383, 387, 393, 396, 397, 399, 402, 406, + 408, 410, 412, 414, 416, 418, 420, 422, 424, 427, + 429, 431, 434, 437, 439, 443, 445, 447, 448, 450, + 452, 454, 456, 458, 460, 467, 473, 475, 477, 479, + 481, 483, 485, 487, 489, 491, 493, 495, 497, 499, + 501, 503, 505, 507, 509, 511, 513, 515, 517, 519, + 521, 523, 525, 527, 529 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 54, 0, -1, 57, -1, 41, 115, 42, -1, 39, + 115, 40, -1, -1, -1, 55, 58, 57, -1, -1, + 56, 61, 59, 44, 57, -1, -1, 1, 44, 60, + 57, -1, 56, 61, -1, -1, 62, -1, 79, -1, + 80, -1, 93, -1, 94, -1, 65, -1, 66, -1, + 73, -1, 74, -1, 102, -1, 103, -1, 105, -1, + 118, -1, -1, 3, 33, 63, 45, 57, 46, -1, + 6, 33, -1, 6, 119, -1, 116, 64, -1, -1, + 116, 64, 68, 67, 45, 69, 46, -1, 12, 112, + -1, -1, 56, 71, 44, 69, -1, 1, 44, 69, + -1, 56, 71, -1, -1, 113, 33, -1, 85, -1, + 7, 33, -1, 7, 119, -1, 116, 72, -1, -1, + 116, 72, 75, 45, 76, 46, -1, 56, 77, 44, + 76, -1, 1, 44, 76, -1, 56, 77, -1, -1, + 85, -1, 4, 33, -1, 4, 119, -1, 116, 78, + -1, -1, 116, 78, 82, 83, 81, 45, 84, 46, + -1, 12, 112, -1, -1, 13, 96, -1, -1, 56, + 91, 44, 84, -1, 1, 44, 84, -1, 56, 91, + -1, -1, 70, -1, 113, 119, -1, 113, -1, 113, + -1, 15, -1, 86, 37, -1, 30, 86, 37, -1, + 31, 86, 37, -1, 86, 38, -1, 30, 86, 38, + -1, 31, 86, 38, -1, -1, 87, 110, 47, 89, + 111, -1, -1, 87, 1, 47, 90, 111, -1, 85, + -1, 88, -1, 5, 33, -1, 5, 119, -1, 116, + 92, -1, -1, 116, 92, 97, 95, 45, 98, 46, + -1, 112, 48, 96, -1, 112, -1, 24, -1, 12, + 96, -1, -1, 56, 99, 44, 98, -1, 1, 44, + 98, -1, 56, 99, -1, -1, 88, -1, 101, 48, + 100, -1, 101, -1, 112, -1, 119, -1, 116, 8, + 49, 56, 113, 50, 33, -1, 116, 8, 49, 56, + 113, 50, 119, -1, 116, 9, 49, 56, 113, 48, + 56, 113, 50, 33, -1, 116, 9, 49, 56, 113, + 48, 56, 113, 50, 119, -1, 10, 33, -1, 10, + 119, -1, -1, 116, 104, 106, 45, 107, 46, -1, + 116, 10, 45, 107, 46, -1, 108, 48, 107, -1, + 108, -1, 33, -1, 119, -1, -1, 11, -1, -1, + -1, 109, 56, 70, -1, 110, 48, 109, 56, 70, + -1, 109, 56, 113, 119, -1, 110, 48, 109, 56, + 113, 119, -1, 109, 56, 113, -1, 110, 48, 109, + 56, 113, -1, 14, 100, -1, -1, 33, -1, 32, + 33, -1, 112, 32, 33, -1, 16, -1, 17, -1, + 18, -1, 19, -1, 20, -1, 21, -1, 22, -1, + 23, -1, 24, -1, 24, 51, -1, 25, -1, 112, + -1, 112, 51, -1, 34, 114, -1, 34, -1, 115, + 48, 114, -1, 114, -1, 26, -1, -1, 35, -1, + 36, -1, 112, -1, 34, -1, 28, -1, 29, -1, + 27, 56, 113, 33, 52, 117, -1, 27, 56, 113, + 52, 117, -1, 3, -1, 4, -1, 5, -1, 6, + -1, 7, -1, 8, -1, 9, -1, 10, -1, 11, + -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, + -1, 17, -1, 18, -1, 19, -1, 20, -1, 21, + -1, 22, -1, 23, -1, 24, -1, 25, -1, 26, + -1, 27, -1, 28, -1, 29, -1, 30, -1, 31, + -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned short yyrline[] = +{ + 0, 105, 105, 113, 122, 127, 136, 135, 145, 144, + 156, 155, 160, 165, 172, 176, 180, 184, 188, 192, + 196, 200, 204, 208, 212, 216, 220, 230, 229, 262, + 266, 277, 288, 287, 314, 323, 331, 340, 343, 348, + 355, 368, 374, 378, 389, 400, 399, 435, 444, 447, + 452, 459, 465, 469, 480, 494, 493, 533, 568, 576, + 581, 589, 598, 601, 606, 613, 636, 658, 684, 685, + 694, 718, 759, 783, 807, 831, 861, 860, 883, 882, + 905, 906, 912, 916, 927, 942, 941, 976, 1011, 1046, + 1056, 1061, 1069, 1078, 1081, 1086, 1093, 1099, 1106, 1118, + 1130, 1141, 1150, 1165, 1176, 1193, 1197, 1209, 1208, 1232, + 1247, 1253, 1261, 1273, 1281, 1290, 1297, 1308, 1310, 1328, + 1346, 1358, 1370, 1381, 1397, 1402, 1410, 1413, 1419, 1432, + 1436, 1440, 1444, 1448, 1452, 1456, 1460, 1464, 1468, 1472, + 1476, 1495, 1536, 1542, 1550, 1557, 1569, 1576, 1586, 1599, + 1612, 1647, 1658, 1669, 1685, 1694, 1709, 1712, 1715, 1718, + 1721, 1724, 1727, 1730, 1733, 1736, 1739, 1742, 1745, 1748, + 1751, 1754, 1757, 1760, 1763, 1766, 1769, 1772, 1775, 1778, + 1781, 1784, 1787, 1790, 1793 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "ICE_MODULE", "ICE_CLASS", + "ICE_INTERFACE", "ICE_EXCEPTION", "ICE_STRUCT", "ICE_SEQUENCE", + "ICE_DICTIONARY", "ICE_ENUM", "ICE_OUT", "ICE_EXTENDS", "ICE_IMPLEMENTS", + "ICE_THROWS", "ICE_VOID", "ICE_BYTE", "ICE_BOOL", "ICE_SHORT", "ICE_INT", + "ICE_LONG", "ICE_FLOAT", "ICE_DOUBLE", "ICE_STRING", "ICE_OBJECT", + "ICE_LOCAL_OBJECT", "ICE_LOCAL", "ICE_CONST", "ICE_FALSE", "ICE_TRUE", + "ICE_NONMUTATING", "ICE_IDEMPOTENT", "ICE_SCOPE_DELIMITER", + "ICE_IDENTIFIER", "ICE_STRING_LITERAL", "ICE_INTEGER_LITERAL", + "ICE_FLOATING_POINT_LITERAL", "ICE_IDENT_OP", "ICE_KEYWORD_OP", + "ICE_METADATA_OPEN", "ICE_METADATA_CLOSE", "ICE_GLOBAL_METADATA_OPEN", + "ICE_GLOBAL_METADATA_CLOSE", "BAD_CHAR", "';'", "'{'", "'}'", "')'", + "','", "'<'", "'>'", "'*'", "'='", "$accept", "start", + "global_meta_data", "meta_data", "definitions", "@1", "@2", "@3", + "definition", "module_def", "@4", "exception_id", "exception_decl", + "exception_def", "@5", "exception_extends", "exception_exports", + "type_id", "exception_export", "struct_id", "struct_decl", "struct_def", + "@6", "struct_exports", "struct_export", "class_id", "class_decl", + "class_def", "@7", "class_extends", "implements", "class_exports", + "data_member", "return_type", "operation_preamble", "operation", "@8", + "@9", "class_export", "interface_id", "interface_decl", "interface_def", + "@10", "interface_list", "interface_extends", "interface_exports", + "interface_export", "exception_list", "exception", "sequence_def", + "dictionary_def", "enum_id", "enum_def", "@11", "enumerator_list", + "enumerator", "out_qualifier", "parameters", "throws", "scoped_name", + "type", "string_literal", "string_list", "local_qualifier", + "const_initializer", "const_def", "keyword", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 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, 59, 123, 125, 41, 44, 60, + 62, 42, 61 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 53, 54, 55, 56, 56, 58, 57, 59, 57, + 60, 57, 57, 57, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 63, 62, 64, + 64, 65, 67, 66, 68, 68, 69, 69, 69, 69, + 70, 71, 72, 72, 73, 75, 74, 76, 76, 76, + 76, 77, 78, 78, 79, 81, 80, 82, 82, 83, + 83, 84, 84, 84, 84, 85, 85, 85, 86, 86, + 87, 87, 87, 87, 87, 87, 89, 88, 90, 88, + 91, 91, 92, 92, 93, 95, 94, 96, 96, 96, + 97, 97, 98, 98, 98, 98, 99, 100, 100, 101, + 101, 102, 102, 103, 103, 104, 104, 106, 105, 105, + 107, 107, 108, 108, 108, 109, 109, 110, 110, 110, + 110, 110, 110, 110, 111, 111, 112, 112, 112, 113, + 113, 113, 113, 113, 113, 113, 113, 113, 113, 113, + 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, + 117, 117, 117, 117, 118, 118, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 3, 3, 0, 0, 3, 0, 5, + 0, 4, 2, 0, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 0, 6, 2, + 2, 2, 0, 7, 2, 0, 4, 3, 2, 0, + 2, 1, 2, 2, 2, 0, 6, 4, 3, 2, + 0, 1, 2, 2, 2, 0, 8, 2, 0, 2, + 0, 4, 3, 2, 0, 1, 2, 1, 1, 1, + 2, 3, 3, 2, 3, 3, 0, 5, 0, 5, + 1, 1, 2, 2, 2, 0, 7, 3, 1, 1, + 2, 0, 4, 3, 2, 0, 1, 3, 1, 1, + 1, 7, 7, 10, 10, 2, 2, 0, 6, 5, + 3, 1, 1, 1, 0, 1, 0, 0, 3, 5, + 4, 6, 3, 5, 2, 0, 1, 2, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, + 1, 2, 2, 1, 3, 1, 1, 0, 1, 1, + 1, 1, 1, 1, 6, 5, 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 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 0, 0, 0, 0, 6, 147, 2, 10, 143, + 145, 0, 0, 1, 0, 0, 146, 5, 12, 14, + 19, 20, 21, 22, 15, 16, 17, 18, 23, 24, + 25, 0, 26, 0, 142, 4, 0, 3, 7, 27, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, + 44, 54, 84, 107, 11, 144, 0, 129, 130, 131, + 132, 133, 134, 135, 136, 137, 139, 0, 126, 140, + 0, 0, 156, 157, 158, 159, 160, 161, 162, 163, + 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, + 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, + 184, 52, 53, 82, 83, 29, 30, 42, 43, 5, + 5, 105, 114, 106, 0, 32, 0, 0, 60, 0, + 85, 0, 0, 138, 127, 0, 141, 0, 0, 9, + 0, 0, 112, 0, 111, 113, 34, 0, 0, 57, + 0, 55, 89, 90, 88, 0, 114, 0, 128, 0, + 152, 153, 151, 148, 149, 150, 155, 0, 0, 109, + 114, 0, 0, 0, 0, 59, 0, 0, 0, 0, + 28, 154, 0, 5, 110, 0, 0, 0, 0, 65, + 49, 51, 67, 46, 0, 87, 0, 0, 0, 108, + 101, 102, 0, 0, 38, 41, 33, 48, 0, 40, + 66, 0, 0, 0, 0, 69, 0, 0, 0, 0, + 96, 94, 68, 86, 0, 37, 0, 47, 0, 80, + 81, 63, 67, 56, 93, 0, 0, 70, 73, 0, + 115, 5, 0, 0, 0, 36, 62, 0, 71, 74, + 72, 75, 78, 0, 76, 116, 92, 103, 104, 61, + 125, 118, 122, 125, 5, 0, 79, 120, 77, 0, + 124, 98, 99, 100, 119, 123, 0, 121, 97 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const short yydefgoto[] = +{ + -1, 4, 5, 6, 7, 14, 41, 33, 18, 19, + 56, 49, 20, 21, 137, 115, 177, 179, 194, 50, + 22, 23, 116, 164, 180, 51, 24, 25, 166, 118, + 141, 203, 181, 208, 209, 210, 253, 250, 221, 52, + 26, 27, 145, 143, 120, 188, 211, 260, 261, 28, + 29, 53, 30, 121, 133, 134, 231, 232, 256, 69, + 212, 10, 11, 31, 156, 32, 135 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -192 +static const short yypact[] = +{ + 400, -26, -9, -9, 27, -192, 62, -192, -192, -9, + -192, 18, 20, -192, 77, 30, -192, 35, 58, -192, + -192, -192, -192, -192, -192, -192, -192, -192, -192, -192, + -192, 130, -192, 77, -192, -192, -9, -192, -192, -192, + 186, 78, 506, 537, 568, 599, 75, 79, 366, -11, + 34, 9, 11, -192, -192, -192, 61, -192, -192, -192, + -192, -192, -192, -192, -192, 76, -192, 96, -192, -15, + 38, 77, -192, -192, -192, -192, -192, -192, -192, -192, + -192, -192, -192, -192, -192, -192, -192, -192, -192, -192, + -192, -192, -192, -192, -192, -192, -192, -192, -192, -192, + -192, -192, -192, -192, -192, -192, -192, -192, -192, 35, + 35, -192, 630, -192, -2, -192, 103, -2, 128, 93, + -192, 107, 104, -192, -192, 116, -192, 101, 156, -192, + 186, 186, -192, 108, 109, -192, 123, 114, 289, 123, + 93, -192, -192, -192, -8, 115, 630, 117, -192, 156, + -192, -192, -192, -192, -192, 123, -192, 118, 121, -192, + 630, 322, 120, 186, 119, -192, 125, 93, 223, 127, + -192, -192, 661, 35, -192, 122, 186, 129, 289, -192, + 133, -192, 692, -192, 256, -192, 134, 398, 137, -192, + -192, -192, 186, 322, 135, -192, -192, -192, 289, -192, + -192, 136, 398, 140, 223, -192, 742, 742, 32, 28, + -192, 149, -192, -192, 124, -192, 322, -192, 256, -192, + -192, 151, 439, -192, -192, 57, 59, -192, -192, 150, + -192, 35, 51, 223, 723, -192, -192, 256, -192, -192, + -192, -192, -192, 186, -192, 160, -192, -192, -192, -192, + 182, -192, 692, 182, 35, 475, -192, -192, -192, 186, + -192, 152, 123, -192, -192, 692, 475, -192, -192 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const short yypgoto[] = +{ + -192, -192, -192, -17, -7, -192, -192, -192, -192, -192, + -192, -192, -192, -192, -192, -192, -179, -186, -192, -192, + -192, -192, -192, -163, -192, -192, -192, -192, -192, -192, + -192, -146, -164, -87, -192, -4, -192, -192, -192, -192, + -192, -192, -192, -124, -192, -191, -192, -49, -192, -192, + -192, -192, -192, -192, -127, -192, -24, -192, -31, -108, + -30, 19, 220, -192, 81, -192, -40 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -118 +static const short yytable[] = +{ + 40, 114, 102, 104, 106, 108, 136, 38, 113, 139, + 70, 144, 195, 224, 215, 197, 165, 125, 8, 169, + 155, 117, -58, 119, 125, 9, 54, 13, 34, 229, + 67, 68, 144, 174, -35, 217, 126, 235, 219, 230, + 167, 155, 246, 185, -116, -116, -116, -116, -116, -116, + -116, -116, -116, -116, -58, 55, -91, 251, 35, 144, + -116, -116, 37, 39, 129, 15, 36, -116, 36, 227, + 228, 127, 236, 264, 2, -117, -117, -13, 1, -45, + -5, -5, -5, -5, -5, -5, -5, -5, 16, 17, + 128, 249, 130, 131, 238, 239, 240, 241, 244, 245, + 157, 158, -8, -5, -5, 1, 122, -5, -5, -5, + -5, -5, -5, -5, -5, 147, 2, 142, 3, 225, + 226, 163, 71, -13, 109, 67, 68, 123, 110, 124, + -5, -5, 191, 182, 42, 43, 44, 45, 46, 47, + 48, 140, 200, 2, 176, 3, 182, 262, 138, 148, + -13, 187, 146, 149, 159, 125, 192, 160, 262, 161, + 168, 163, 214, 170, 178, 183, 193, 202, 172, 173, + 184, 230, 222, 189, 234, 196, 176, 198, 204, 216, + 218, 163, 200, 213, 150, 151, 223, 187, 67, 68, + 152, 153, 154, 233, 248, 237, 255, 242, 220, 176, + 266, 202, 57, 58, 59, 60, 61, 62, 63, 64, + 65, 66, 257, 252, 243, 263, 187, 268, 67, 68, + 202, 254, 258, 12, 186, 267, 263, 0, 0, 265, + 171, 0, 0, 0, 0, 0, 0, 259, -5, -5, + -5, -5, -5, -5, -5, -5, -5, -5, -5, 0, + 0, 0, 0, -5, -5, -5, -5, 201, 0, 0, + 0, 0, 2, 0, 0, 0, 0, 0, 0, -95, + 0, -5, -5, -5, -5, -5, -5, -5, -5, -5, + -5, -5, 0, 0, 0, 0, -5, -5, -5, -5, + 162, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, -64, 0, 0, -5, -5, -5, -5, -5, + -5, -5, -5, -5, -5, 0, 0, 0, 0, 0, + 0, -5, -5, 175, 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, -50, 0, 0, -5, -5, + -5, -5, -5, -5, -5, -5, -5, -5, 0, 0, + 0, 0, 0, 0, -5, -5, 0, 0, 0, 0, + 0, 2, 0, 0, 0, 0, 0, 0, -39, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 0, 111, + -13, 1, 0, -5, -5, -5, -5, -5, -5, -5, + -5, 112, 0, 205, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 0, 0, -5, -5, 206, 207, + 67, 68, 0, 0, 0, 0, 0, 0, 0, 2, + 0, 3, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 0, 199, 0, 0, 0, -68, -68, 72, 73, + 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, + 94, 95, 96, 97, 98, 99, 100, 67, 68, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, + 93, 94, 95, 96, 97, 98, 99, 100, 0, 101, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 0, + 103, 72, 73, 74, 75, 76, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, + 0, 105, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 0, 107, 72, 73, 74, 75, 76, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, + 99, 100, 0, 132, 72, 73, 74, 75, 76, 77, + 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 0, 190, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 0, 199, 72, 73, 74, 75, + 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, + 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 0, 247, 205, 57, 58, + 59, 60, 61, 62, 63, 64, 65, 66, 0, 0, + 0, 0, 0, 0, 67, 68 +}; + +static const short yycheck[] = +{ + 17, 12, 42, 43, 44, 45, 114, 14, 48, 117, + 40, 119, 176, 204, 193, 178, 140, 32, 44, 146, + 128, 12, 13, 12, 32, 34, 33, 0, 9, 1, + 32, 33, 140, 160, 45, 198, 51, 216, 202, 11, + 48, 149, 233, 167, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 45, 36, 45, 243, 40, 167, + 32, 33, 42, 33, 71, 3, 48, 39, 48, 37, + 38, 33, 218, 259, 39, 47, 48, 0, 1, 45, + 3, 4, 5, 6, 7, 8, 9, 10, 26, 27, + 52, 237, 109, 110, 37, 38, 37, 38, 47, 48, + 130, 131, 44, 26, 27, 1, 45, 3, 4, 5, + 6, 7, 8, 9, 10, 122, 39, 24, 41, 206, + 207, 138, 44, 46, 49, 32, 33, 51, 49, 33, + 26, 27, 172, 163, 4, 5, 6, 7, 8, 9, + 10, 13, 182, 39, 161, 41, 176, 255, 45, 33, + 46, 168, 45, 52, 46, 32, 173, 48, 266, 45, + 45, 178, 192, 46, 44, 46, 44, 184, 50, 48, + 45, 11, 202, 46, 50, 46, 193, 44, 44, 44, + 44, 198, 222, 46, 28, 29, 46, 204, 32, 33, + 34, 35, 36, 44, 234, 44, 14, 47, 202, 216, + 48, 218, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 252, 243, 231, 255, 233, 266, 32, 33, + 237, 245, 253, 3, 1, 265, 266, -1, -1, 259, + 149, -1, -1, -1, -1, -1, -1, 254, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, + -1, -1, -1, 30, 31, 32, 33, 1, -1, -1, + -1, -1, 39, -1, -1, -1, -1, -1, -1, 46, + -1, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, -1, -1, -1, -1, 30, 31, 32, 33, + 1, -1, -1, -1, -1, 39, -1, -1, -1, -1, + -1, -1, 46, -1, -1, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, + -1, 32, 33, 1, -1, -1, -1, -1, 39, -1, + -1, -1, -1, -1, -1, 46, -1, -1, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, + -1, -1, -1, -1, 32, 33, -1, -1, -1, -1, + -1, 39, -1, -1, -1, -1, -1, -1, 46, 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, -1, 33, + 0, 1, -1, 3, 4, 5, 6, 7, 8, 9, + 10, 45, -1, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, -1, -1, 26, 27, 30, 31, + 32, 33, -1, -1, -1, -1, -1, -1, -1, 39, + -1, 41, 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, -1, 33, -1, -1, -1, 37, 38, 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, 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, -1, 33, + 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, -1, + 33, 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, + -1, 33, 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, -1, 33, 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, -1, 33, 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, -1, 33, 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, -1, 33, 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, -1, 33, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, + -1, -1, -1, -1, 32, 33 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 1, 39, 41, 54, 55, 56, 57, 44, 34, + 114, 115, 115, 0, 58, 3, 26, 27, 61, 62, + 65, 66, 73, 74, 79, 80, 93, 94, 102, 103, + 105, 116, 118, 60, 114, 40, 48, 42, 57, 33, + 56, 59, 4, 5, 6, 7, 8, 9, 10, 64, + 72, 78, 92, 104, 57, 114, 63, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 32, 33, 112, + 113, 44, 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, 33, 119, 33, 119, 33, 119, 33, 119, 49, + 49, 33, 45, 119, 12, 68, 75, 12, 82, 12, + 97, 106, 45, 51, 33, 32, 51, 33, 52, 57, + 56, 56, 33, 107, 108, 119, 112, 67, 45, 112, + 13, 83, 24, 96, 112, 95, 45, 57, 33, 52, + 28, 29, 34, 35, 36, 112, 117, 113, 113, 46, + 48, 45, 1, 56, 76, 96, 81, 48, 45, 107, + 46, 117, 50, 48, 107, 1, 56, 69, 44, 70, + 77, 85, 113, 46, 45, 96, 1, 56, 98, 46, + 33, 119, 56, 44, 71, 85, 46, 76, 44, 33, + 119, 1, 56, 84, 44, 15, 30, 31, 86, 87, + 88, 99, 113, 46, 113, 69, 44, 76, 44, 85, + 88, 91, 113, 46, 98, 86, 86, 37, 38, 1, + 11, 109, 110, 44, 50, 69, 84, 44, 37, 38, + 37, 38, 47, 56, 47, 48, 98, 33, 119, 84, + 90, 70, 113, 89, 109, 14, 111, 119, 111, 56, + 100, 101, 112, 119, 70, 113, 48, 119, 100 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 106 "../Slice/Grammar.y" + { +;} + break; + + case 3: +#line 114 "../Slice/Grammar.y" + { + yyval = yyvsp[-1]; +;} + break; + + case 4: +#line 123 "../Slice/Grammar.y" + { + yyval = yyvsp[-1]; +;} + break; + + case 5: +#line 127 "../Slice/Grammar.y" + { + yyval = new StringListTok; +;} + break; + + case 6: +#line 136 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[0]); + if(!metaData->v.empty()) + { + unit->addGlobalMetaData(metaData->v); + } +;} + break; + + case 8: +#line 145 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-1]); + ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[0]); + if(contained && !metaData->v.empty()) + { + contained->setMetaData(metaData->v); + } + unit->setSeenDefinition(); +;} + break; + + case 10: +#line 156 "../Slice/Grammar.y" + { + yyerrok; +;} + break; + + case 12: +#line 161 "../Slice/Grammar.y" + { + unit->error("`;' missing after definition"); +;} + break; + + case 13: +#line 165 "../Slice/Grammar.y" + { +;} + break; + + case 14: +#line 173 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ModulePtr::dynamicCast(yyvsp[0])); +;} + break; + + case 15: +#line 177 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ClassDeclPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 16: +#line 181 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ClassDefPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 17: +#line 185 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ClassDeclPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 18: +#line 189 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ClassDefPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 19: +#line 193 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0); +;} + break; + + case 20: +#line 197 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ExceptionPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 21: +#line 201 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0); +;} + break; + + case 22: +#line 205 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || StructPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 23: +#line 209 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || SequencePtr::dynamicCast(yyvsp[0])); +;} + break; + + case 24: +#line 213 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || DictionaryPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 25: +#line 217 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || EnumPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 26: +#line 221 "../Slice/Grammar.y" + { + assert(yyvsp[0] == 0 || ConstPtr::dynamicCast(yyvsp[0])); +;} + break; + + case 27: +#line 230 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + ModulePtr module = cont->createModule(ident->v); + if(module) + { + cont->checkIntroduced(ident->v, module); + unit->pushContainer(module); + yyval = module; + } + else + { + yyval = 0; + } +;} + break; + + case 28: +#line 246 "../Slice/Grammar.y" + { + if(yyvsp[-3]) + { + unit->popContainer(); + yyval = yyvsp[-3]; + } + else + { + yyval = 0; + } +;} + break; + + case 29: +#line 263 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 30: +#line 267 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as exception name"); + yyval = yyvsp[0]; // Dummy +;} + break; + + case 31: +#line 278 "../Slice/Grammar.y" + { + unit->error("exceptions cannot be forward declared"); + yyval = 0; +;} + break; + + case 32: +#line 288 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-2]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-1]); + ExceptionPtr base = ExceptionPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + ExceptionPtr ex = cont->createException(ident->v, base, local->v); + if(ex) + { + cont->checkIntroduced(ident->v, ex); + unit->pushContainer(ex); + } + yyval = ex; +;} + break; + + case 33: +#line 302 "../Slice/Grammar.y" + { + if(yyvsp[-3]) + { + unit->popContainer(); + } + yyval = yyvsp[-3]; +;} + break; + + case 34: +#line 315 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + ContainedPtr contained = cont->lookupException(scoped->v); + cont->checkIntroduced(scoped->v); + yyval = contained; +;} + break; + + case 35: +#line 323 "../Slice/Grammar.y" + { + yyval = 0; +;} + break; + + case 36: +#line 332 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + if(contained && !metaData->v.empty()) + { + contained->setMetaData(metaData->v); + } +;} + break; + + case 37: +#line 341 "../Slice/Grammar.y" + { +;} + break; + + case 38: +#line 344 "../Slice/Grammar.y" + { + unit->error("`;' missing after definition"); +;} + break; + + case 39: +#line 348 "../Slice/Grammar.y" + { +;} + break; + + case 40: +#line 356 "../Slice/Grammar.y" + { + TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + TypeStringTokPtr typestring = new TypeStringTok; + typestring->v = make_pair(type, ident->v); + yyval = typestring; +;} + break; + + case 42: +#line 375 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 43: +#line 379 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as struct name"); + yyval = yyvsp[0]; // Dummy +;} + break; + + case 44: +#line 390 "../Slice/Grammar.y" + { + unit->error("structs cannot be forward declared"); + yyval = 0; // Dummy +;} + break; + + case 45: +#line 400 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + StructPtr st = cont->createStruct(ident->v, local->v); + if(st) + { + cont->checkIntroduced(ident->v, st); + unit->pushContainer(st); + } + yyval = st; +;} + break; + + case 46: +#line 413 "../Slice/Grammar.y" + { + if(yyvsp[-3]) + { + unit->popContainer(); + } + yyval = yyvsp[-3]; + + // + // Empty structures are not allowed + // + StructPtr st = StructPtr::dynamicCast(yyval); + assert(st); + if(st->dataMembers().empty()) + { + unit->error("struct `" + st->name() + "' must have at least one member"); // $$ is a dummy + } +;} + break; + + case 47: +#line 436 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + if(contained && !metaData->v.empty()) + { + contained->setMetaData(metaData->v); + } +;} + break; + + case 48: +#line 445 "../Slice/Grammar.y" + { +;} + break; + + case 49: +#line 448 "../Slice/Grammar.y" + { + unit->error("`;' missing after definition"); +;} + break; + + case 50: +#line 452 "../Slice/Grammar.y" + { +;} + break; + + case 52: +#line 466 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 53: +#line 470 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as class name"); + yyval = yyvsp[0]; // Dummy +;} + break; + + case 54: +#line 481 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + ClassDeclPtr cl = cont->createClassDecl(ident->v, false, local->v); + yyval = cl; +;} + break; + + case 55: +#line 494 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-3]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-2]); + ContainerPtr cont = unit->currentContainer(); + ClassDefPtr base = ClassDefPtr::dynamicCast(yyvsp[-1]); + ClassListTokPtr bases = ClassListTokPtr::dynamicCast(yyvsp[0]); + if(base) + { + bases->v.push_front(base); + } + ClassDefPtr cl = cont->createClassDef(ident->v, false, bases->v, local->v); + if(cl) + { + cont->checkIntroduced(ident->v, cl); + unit->pushContainer(cl); + yyval = cl; + } + else + { + yyval = 0; + } +;} + break; + + case 56: +#line 517 "../Slice/Grammar.y" + { + if(yyvsp[-3]) + { + unit->popContainer(); + yyval = yyvsp[-3]; + } + else + { + yyval = 0; + } +;} + break; + + case 57: +#line 534 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + TypeList types = cont->lookupType(scoped->v); + yyval = 0; + if(!types.empty()) + { + ClassDeclPtr cl = ClassDeclPtr::dynamicCast(types.front()); + if(!cl || cl->isInterface()) + { + string msg = "`"; + msg += scoped->v; + msg += "' is not a class"; + unit->error(msg); + } + else + { + ClassDefPtr def = cl->definition(); + if(!def) + { + string msg = "`"; + msg += scoped->v; + msg += "' has been declared but not defined"; + unit->error(msg); + } + else + { + cont->checkIntroduced(scoped->v); + yyval = def; + } + } + } +;} + break; + + case 58: +#line 568 "../Slice/Grammar.y" + { + yyval = 0; +;} + break; + + case 59: +#line 577 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 60: +#line 581 "../Slice/Grammar.y" + { + yyval = new ClassListTok; +;} + break; + + case 61: +#line 590 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + if(contained && !metaData->v.empty()) + { + contained->setMetaData(metaData->v); + } +;} + break; + + case 62: +#line 599 "../Slice/Grammar.y" + { +;} + break; + + case 63: +#line 602 "../Slice/Grammar.y" + { + unit->error("`;' missing after definition"); +;} + break; + + case 64: +#line 606 "../Slice/Grammar.y" + { +;} + break; + + case 65: +#line 614 "../Slice/Grammar.y" + { + TypePtr type = TypeStringTokPtr::dynamicCast(yyvsp[0])->v.first; + string name = TypeStringTokPtr::dynamicCast(yyvsp[0])->v.second; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + DataMemberPtr dm; + if(cl) + { + dm = cl->createDataMember(name, type); + } + StructPtr st = StructPtr::dynamicCast(unit->currentContainer()); + if(st) + { + dm = st->createDataMember(name, type); + } + ExceptionPtr ex = ExceptionPtr::dynamicCast(unit->currentContainer()); + if(ex) + { + dm = ex->createDataMember(name, type); + } + unit->currentContainer()->checkIntroduced(name, dm); + yyval = dm; +;} + break; + + case 66: +#line 637 "../Slice/Grammar.y" + { + TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + yyval = cl->createDataMember(name, type); // Dummy + } + StructPtr st = StructPtr::dynamicCast(unit->currentContainer()); + if(st) + { + yyval = st->createDataMember(name, type); // Dummy + } + ExceptionPtr ex = ExceptionPtr::dynamicCast(unit->currentContainer()); + if(ex) + { + yyval = ex->createDataMember(name, type); // Dummy + } + assert(yyval); + unit->error("keyword `" + name + "' cannot be used as data member name"); +;} + break; + + case 67: +#line 659 "../Slice/Grammar.y" + { + TypePtr type = TypePtr::dynamicCast(yyvsp[0]); + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + yyval = cl->createDataMember(IceUtil::generateUUID(), type); // Dummy + } + StructPtr st = StructPtr::dynamicCast(unit->currentContainer()); + if(st) + { + yyval = st->createDataMember(IceUtil::generateUUID(), type); // Dummy + } + ExceptionPtr ex = ExceptionPtr::dynamicCast(unit->currentContainer()); + if(ex) + { + yyval = ex->createDataMember(IceUtil::generateUUID(), type); // Dummy + } + assert(yyval); + unit->error("missing data member name"); +;} + break; + + case 69: +#line 686 "../Slice/Grammar.y" + { + yyval = 0; +;} + break; + + case 70: +#line 695 "../Slice/Grammar.y" + { + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + OperationPtr op = cl->createOperation(name, returnType); + if(op) + { + cl->checkIntroduced(name, op); + unit->pushContainer(op); + yyval = op; + } + else + { + yyval = 0; + } + } + else + { + yyval = 0; + } +;} + break; + + case 71: +#line 719 "../Slice/Grammar.y" + { + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + OperationPtr op = cl->createOperation(name, returnType, Operation::Nonmutating); + if(op) + { + cl->checkIntroduced(name, op); + unit->pushContainer(op); + static bool firstWarning = true; + + string msg = "the keyword 'nonmutating' is deprecated"; + if(firstWarning) + { + msg += ";\n"; + msg += "You should use instead 'idempotent' plus:\n"; + msg += " - Freeze metadata ([\"freeze:read\"], [\"freeze:write\"]) if you implement your objects with a Freeze evictor\n"; + msg += " - [\"nonmutating\"], if you need to maintain compatibility with operations that expect "; + msg += "'Nonmutating' as operation-mode. With this metadata, the generated code sends "; + msg += "'Nonmutating' instead of 'Idempotent'\n"; + msg += " - [\"cpp:const\"], to get a const member function on the generated C++ servant base class"; + + firstWarning = false; + } + + unit->warning(msg); + yyval = op; + } + else + { + yyval = 0; + } + } + else + { + yyval = 0; + } +;} + break; + + case 72: +#line 760 "../Slice/Grammar.y" + { + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + OperationPtr op = cl->createOperation(name, returnType, Operation::Idempotent); + if(op) + { + cl->checkIntroduced(name, op); + unit->pushContainer(op); + yyval = op; + } + else + { + yyval = 0; + } + } + else + { + yyval = 0; + } +;} + break; + + case 73: +#line 784 "../Slice/Grammar.y" + { + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + OperationPtr op = cl->createOperation(name, returnType); + if(op) + { + unit->pushContainer(op); + unit->error("keyword `" + name + "' cannot be used as operation name"); + yyval = op; // Dummy + } + else + { + yyval = 0; + } + } + else + { + yyval = 0; + } +;} + break; + + case 74: +#line 808 "../Slice/Grammar.y" + { + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + OperationPtr op = cl->createOperation(name, returnType, Operation::Nonmutating); + if(op) + { + unit->pushContainer(op); + unit->error("keyword `" + name + "' cannot be used as operation name"); + yyval = op; // Dummy + } + else + { + yyval = 0; + } + } + else + { + yyval = 0; + } +;} + break; + + case 75: +#line 832 "../Slice/Grammar.y" + { + TypePtr returnType = TypePtr::dynamicCast(yyvsp[-1]); + string name = StringTokPtr::dynamicCast(yyvsp[0])->v; + ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer()); + if(cl) + { + OperationPtr op = cl->createOperation(name, returnType, Operation::Idempotent); + if(op) + { + unit->pushContainer(op); + unit->error("keyword `" + name + "' cannot be used as operation name"); + yyval = op; // Dummy + } + else + { + return 0; + } + } + else + { + yyval = 0; + } +;} + break; + + case 76: +#line 861 "../Slice/Grammar.y" + { + if(yyvsp[-2]) + { + unit->popContainer(); + yyval = yyvsp[-2]; + } + else + { + yyval = 0; + } +;} + break; + + case 77: +#line 873 "../Slice/Grammar.y" + { + OperationPtr op = OperationPtr::dynamicCast(yyvsp[-1]); + ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast(yyvsp[0]); + assert(el); + if(op) + { + op->setExceptionList(el->v); + } +;} + break; + + case 78: +#line 883 "../Slice/Grammar.y" + { + if(yyvsp[-2]) + { + unit->popContainer(); + } + yyerrok; +;} + break; + + case 79: +#line 891 "../Slice/Grammar.y" + { + OperationPtr op = OperationPtr::dynamicCast(yyvsp[-1]); + ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast(yyvsp[0]); + assert(el); + if(op) + { + op->setExceptionList(el->v); // Dummy + } +;} + break; + + case 82: +#line 913 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 83: +#line 917 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as interface name"); + yyval = yyvsp[0]; // Dummy +;} + break; + + case 84: +#line 928 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + ClassDeclPtr cl = cont->createClassDecl(ident->v, true, local->v); + cont->checkIntroduced(ident->v, cl); + yyval = cl; +;} + break; + + case 85: +#line 942 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-2]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-1]); + ContainerPtr cont = unit->currentContainer(); + ClassListTokPtr bases = ClassListTokPtr::dynamicCast(yyvsp[0]); + ClassDefPtr cl = cont->createClassDef(ident->v, true, bases->v, local->v); + if(cl) + { + cont->checkIntroduced(ident->v, cl); + unit->pushContainer(cl); + yyval = cl; + } + else + { + yyval = 0; + } +;} + break; + + case 86: +#line 960 "../Slice/Grammar.y" + { + if(yyvsp[-3]) + { + unit->popContainer(); + yyval = yyvsp[-3]; + } + else + { + yyval = 0; + } +;} + break; + + case 87: +#line 977 "../Slice/Grammar.y" + { + ClassListTokPtr intfs = ClassListTokPtr::dynamicCast(yyvsp[0]); + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[-2]); + ContainerPtr cont = unit->currentContainer(); + TypeList types = cont->lookupType(scoped->v); + if(!types.empty()) + { + ClassDeclPtr cl = ClassDeclPtr::dynamicCast(types.front()); + if(!cl || !cl->isInterface()) + { + string msg = "`"; + msg += scoped->v; + msg += "' is not an interface"; + unit->error(msg); + } + else + { + ClassDefPtr def = cl->definition(); + if(!def) + { + string msg = "`"; + msg += scoped->v; + msg += "' has been declared but not defined"; + unit->error(msg); + } + else + { + cont->checkIntroduced(scoped->v); + intfs->v.push_front(def); + } + } + } + yyval = intfs; +;} + break; + + case 88: +#line 1012 "../Slice/Grammar.y" + { + ClassListTokPtr intfs = new ClassListTok; + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + TypeList types = cont->lookupType(scoped->v); + if(!types.empty()) + { + ClassDeclPtr cl = ClassDeclPtr::dynamicCast(types.front()); + if(!cl || !cl->isInterface()) + { + string msg = "`"; + msg += scoped->v; + msg += "' is not an interface"; + unit->error(msg); // $$ is a dummy + } + else + { + ClassDefPtr def = cl->definition(); + if(!def) + { + string msg = "`"; + msg += scoped->v; + msg += "' has been declared but not defined"; + unit->error(msg); // $$ is a dummy + } + else + { + cont->checkIntroduced(scoped->v); + intfs->v.push_front(def); + } + } + } + yyval = intfs; +;} + break; + + case 89: +#line 1047 "../Slice/Grammar.y" + { + unit->error("illegal inheritance from type Object"); + yyval = new ClassListTok; // Dummy +;} + break; + + case 90: +#line 1057 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 91: +#line 1061 "../Slice/Grammar.y" + { + yyval = new ClassListTok; +;} + break; + + case 92: +#line 1070 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + ContainedPtr contained = ContainedPtr::dynamicCast(yyvsp[-2]); + if(contained && !metaData->v.empty()) + { + contained->setMetaData(metaData->v); + } +;} + break; + + case 93: +#line 1079 "../Slice/Grammar.y" + { +;} + break; + + case 94: +#line 1082 "../Slice/Grammar.y" + { + unit->error("`;' missing after definition"); +;} + break; + + case 95: +#line 1086 "../Slice/Grammar.y" + { +;} + break; + + case 97: +#line 1100 "../Slice/Grammar.y" + { + ExceptionPtr exception = ExceptionPtr::dynamicCast(yyvsp[-2]); + ExceptionListTokPtr exceptionList = ExceptionListTokPtr::dynamicCast(yyvsp[0]); + exceptionList->v.push_front(exception); + yyval = exceptionList; +;} + break; + + case 98: +#line 1107 "../Slice/Grammar.y" + { + ExceptionPtr exception = ExceptionPtr::dynamicCast(yyvsp[0]); + ExceptionListTokPtr exceptionList = new ExceptionListTok; + exceptionList->v.push_front(exception); + yyval = exceptionList; +;} + break; + + case 99: +#line 1119 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + ExceptionPtr exception = cont->lookupException(scoped->v); + if(!exception) + { + exception = cont->createException(IceUtil::generateUUID(), 0, false, Dummy); // Dummy + } + cont->checkIntroduced(scoped->v, exception); + yyval = exception; +;} + break; + + case 100: +#line 1131 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as exception name"); + yyval = unit->currentContainer()->createException(IceUtil::generateUUID(), 0, false, Dummy); // Dummy +;} + break; + + case 101: +#line 1142 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-6]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); + ContainerPtr cont = unit->currentContainer(); + yyval = cont->createSequence(ident->v, type, metaData->v, local->v); +;} + break; + + case 102: +#line 1151 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-6]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + TypePtr type = TypePtr::dynamicCast(yyvsp[-2]); + ContainerPtr cont = unit->currentContainer(); + yyval = cont->createSequence(ident->v, type, metaData->v, local->v); // Dummy + unit->error("keyword `" + ident->v + "' cannot be used as sequence name"); +;} + break; + + case 103: +#line 1166 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-9]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast(yyvsp[-6]); + TypePtr keyType = TypePtr::dynamicCast(yyvsp[-5]); + StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + TypePtr valueType = TypePtr::dynamicCast(yyvsp[-2]); + ContainerPtr cont = unit->currentContainer(); + yyval = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); +;} + break; + + case 104: +#line 1177 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-9]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr keyMetaData = StringListTokPtr::dynamicCast(yyvsp[-6]); + TypePtr keyType = TypePtr::dynamicCast(yyvsp[-5]); + StringListTokPtr valueMetaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + TypePtr valueType = TypePtr::dynamicCast(yyvsp[-2]); + ContainerPtr cont = unit->currentContainer(); + yyval = cont->createDictionary(ident->v, keyType, keyMetaData->v, valueType, valueMetaData->v, local->v); // Dummy + unit->error("keyword `" + ident->v + "' cannot be used as dictionary name"); +;} + break; + + case 105: +#line 1194 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 106: +#line 1198 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as enumeration name"); + yyval = yyvsp[0]; // Dummy +;} + break; + + case 107: +#line 1209 "../Slice/Grammar.y" + { + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + EnumPtr en = cont->createEnum(ident->v, local->v); + cont->checkIntroduced(ident->v, en); + yyval = en; +;} + break; + + case 108: +#line 1218 "../Slice/Grammar.y" + { + EnumPtr en = EnumPtr::dynamicCast(yyvsp[-3]); + if(en) + { + EnumeratorListTokPtr enumerators = EnumeratorListTokPtr::dynamicCast(yyvsp[-1]); + if(enumerators->v.empty()) + { + unit->error("enum `" + en->name() + "' must have at least one enumerator"); + } + en->setEnumerators(enumerators->v); // Dummy + } + yyval = yyvsp[-3]; +;} + break; + + case 109: +#line 1233 "../Slice/Grammar.y" + { + unit->error("missing enumeration name"); + BoolTokPtr local = BoolTokPtr::dynamicCast(yyvsp[-4]); + ContainerPtr cont = unit->currentContainer(); + EnumPtr en = cont->createEnum(IceUtil::generateUUID(), local->v, Dummy); // Dummy + EnumeratorListTokPtr enumerators = EnumeratorListTokPtr::dynamicCast(yyvsp[-1]); + en->setEnumerators(enumerators->v); // Dummy + yyval = en; +;} + break; + + case 110: +#line 1248 "../Slice/Grammar.y" + { + EnumeratorListTokPtr ens = EnumeratorListTokPtr::dynamicCast(yyvsp[-2]); + ens->v.splice(ens->v.end(), EnumeratorListTokPtr::dynamicCast(yyvsp[0])->v); + yyval = ens; +;} + break; + + case 111: +#line 1254 "../Slice/Grammar.y" + { +;} + break; + + case 112: +#line 1262 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + EnumeratorListTokPtr ens = new EnumeratorListTok; + ContainerPtr cont = unit->currentContainer(); + EnumeratorPtr en = cont->createEnumerator(ident->v); + if(en) + { + ens->v.push_front(en); + } + yyval = ens; +;} + break; + + case 113: +#line 1274 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + unit->error("keyword `" + ident->v + "' cannot be used as enumerator"); + EnumeratorListTokPtr ens = new EnumeratorListTok; // Dummy + yyval = ens; +;} + break; + + case 114: +#line 1281 "../Slice/Grammar.y" + { + EnumeratorListTokPtr ens = new EnumeratorListTok; + yyval = ens; // Dummy +;} + break; + + case 115: +#line 1291 "../Slice/Grammar.y" + { + BoolTokPtr out = new BoolTok; + out->v = true; + yyval = out; +;} + break; + + case 116: +#line 1297 "../Slice/Grammar.y" + { + BoolTokPtr out = new BoolTok; + out->v = false; + yyval = out; +;} + break; + + case 117: +#line 1308 "../Slice/Grammar.y" + { +;} + break; + + case 118: +#line 1311 "../Slice/Grammar.y" + { + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); + TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast(yyvsp[0]); + TypePtr type = tsp->v.first; + string ident = tsp->v.second; + OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); + if(op) + { + ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); + unit->currentContainer()->checkIntroduced(ident, pd); + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-1]); + if(!metaData->v.empty()) + { + pd->setMetaData(metaData->v); + } + } +;} + break; + + case 119: +#line 1329 "../Slice/Grammar.y" + { + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); + TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast(yyvsp[0]); + TypePtr type = tsp->v.first; + string ident = tsp->v.second; + OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); + if(op) + { + ParamDeclPtr pd = op->createParamDecl(ident, type, isOutParam->v); + unit->currentContainer()->checkIntroduced(ident, pd); + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-1]); + if(!metaData->v.empty()) + { + pd->setMetaData(metaData->v); + } + } +;} + break; + + case 120: +#line 1347 "../Slice/Grammar.y" + { + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-3]); + TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); + if(op) + { + op->createParamDecl(ident->v, type, isOutParam->v); // Dummy + unit->error("keyword `" + ident->v + "' cannot be used as parameter name"); + } +;} + break; + + case 121: +#line 1359 "../Slice/Grammar.y" + { + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-3]); + TypePtr type = TypePtr::dynamicCast(yyvsp[-1]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); + if(op) + { + op->createParamDecl(ident->v, type, isOutParam->v); // Dummy + unit->error("keyword `" + ident->v + "' cannot be used as parameter name"); + } +;} + break; + + case 122: +#line 1371 "../Slice/Grammar.y" + { + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); + TypePtr type = TypePtr::dynamicCast(yyvsp[0]); + OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); + if(op) + { + op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v); // Dummy + unit->error("missing parameter name"); + } +;} + break; + + case 123: +#line 1382 "../Slice/Grammar.y" + { + BoolTokPtr isOutParam = BoolTokPtr::dynamicCast(yyvsp[-2]); + TypePtr type = TypePtr::dynamicCast(yyvsp[0]); + OperationPtr op = OperationPtr::dynamicCast(unit->currentContainer()); + if(op) + { + op->createParamDecl(IceUtil::generateUUID(), type, isOutParam->v); // Dummy + unit->error("missing parameter name"); + } +;} + break; + + case 124: +#line 1398 "../Slice/Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 125: +#line 1402 "../Slice/Grammar.y" + { + yyval = new ExceptionListTok; +;} + break; + + case 126: +#line 1411 "../Slice/Grammar.y" + { +;} + break; + + case 127: +#line 1414 "../Slice/Grammar.y" + { + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + ident->v = "::" + ident->v; + yyval = ident; +;} + break; + + case 128: +#line 1420 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[-2]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[0]); + scoped->v += "::"; + scoped->v += ident->v; + yyval = scoped; +;} + break; + + case 129: +#line 1433 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindByte); +;} + break; + + case 130: +#line 1437 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindBool); +;} + break; + + case 131: +#line 1441 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindShort); +;} + break; + + case 132: +#line 1445 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindInt); +;} + break; + + case 133: +#line 1449 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindLong); +;} + break; + + case 134: +#line 1453 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindFloat); +;} + break; + + case 135: +#line 1457 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindDouble); +;} + break; + + case 136: +#line 1461 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindString); +;} + break; + + case 137: +#line 1465 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindObject); +;} + break; + + case 138: +#line 1469 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindObjectProxy); +;} + break; + + case 139: +#line 1473 "../Slice/Grammar.y" + { + yyval = unit->builtin(Builtin::KindLocalObject); +;} + break; + + case 140: +#line 1477 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + ContainerPtr cont = unit->currentContainer(); + if(cont) + { + TypeList types = cont->lookupType(scoped->v); + if(types.empty()) + { + YYERROR; // Can't continue, jump to next yyerrok + } + cont->checkIntroduced(scoped->v); + yyval = types.front(); + } + else + { + yyval = 0; + } +;} + break; + + case 141: +#line 1496 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[-1]); + ContainerPtr cont = unit->currentContainer(); + if(cont) + { + TypeList types = cont->lookupType(scoped->v); + if(types.empty()) + { + YYERROR; // Can't continue, jump to next yyerrok + } + for(TypeList::iterator p = types.begin(); p != types.end(); ++p) + { + ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p); + if(!cl) + { + string msg = "`"; + msg += scoped->v; + msg += "' must be class or interface"; + unit->error(msg); + YYERROR; // Can't continue, jump to next yyerrok + } + cont->checkIntroduced(scoped->v); + if(cl->isLocal()) + { + unit->error("cannot create proxy for " + cl->kindOf() + " `" + cl->name() + "'"); // $$ is dummy + } + *p = new Proxy(cl); + } + yyval = types.front(); + } + else + { + yyval = 0; + } +;} + break; + + case 142: +#line 1537 "../Slice/Grammar.y" + { + StringTokPtr str1 = StringTokPtr::dynamicCast(yyvsp[-1]); + StringTokPtr str2 = StringTokPtr::dynamicCast(yyvsp[0]); + str1->v += str2->v; +;} + break; + + case 143: +#line 1543 "../Slice/Grammar.y" + { +;} + break; + + case 144: +#line 1551 "../Slice/Grammar.y" + { + StringTokPtr str = StringTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr stringList = StringListTokPtr::dynamicCast(yyvsp[-2]); + stringList->v.push_back(str->v); + yyval = stringList; +;} + break; + + case 145: +#line 1558 "../Slice/Grammar.y" + { + StringTokPtr str = StringTokPtr::dynamicCast(yyvsp[0]); + StringListTokPtr stringList = new StringListTok; + stringList->v.push_back(str->v); + yyval = stringList; +;} + break; + + case 146: +#line 1570 "../Slice/Grammar.y" + { + BoolTokPtr local = new BoolTok; + local->v = true; + yyval = local; +;} + break; + + case 147: +#line 1576 "../Slice/Grammar.y" + { + BoolTokPtr local = new BoolTok; + local->v = false; + yyval = local; +;} + break; + + case 148: +#line 1587 "../Slice/Grammar.y" + { + BuiltinPtr type = unit->builtin(Builtin::KindLong); + IntegerTokPtr intVal = IntegerTokPtr::dynamicCast(yyvsp[0]); + ostringstream sstr; + sstr << intVal->v; + ConstDefTokPtr def = new ConstDefTok; + def->v.type = type; + def->v.value = type; + def->v.valueAsString = sstr.str(); + def->v.valueAsLiteral = intVal->literal; + yyval = def; +;} + break; + + case 149: +#line 1600 "../Slice/Grammar.y" + { + BuiltinPtr type = unit->builtin(Builtin::KindDouble); + FloatingTokPtr floatVal = FloatingTokPtr::dynamicCast(yyvsp[0]); + ostringstream sstr; + sstr << floatVal->v; + ConstDefTokPtr def = new ConstDefTok; + def->v.type = type; + def->v.value = type; + def->v.valueAsString = sstr.str(); + def->v.valueAsLiteral = floatVal->literal; + yyval = def; +;} + break; + + case 150: +#line 1613 "../Slice/Grammar.y" + { + StringTokPtr scoped = StringTokPtr::dynamicCast(yyvsp[0]); + ConstDefTokPtr def = new ConstDefTok; + ContainedList cl = unit->currentContainer()->lookupContained(scoped->v); + if(cl.empty()) + { + def->v.type = TypePtr(0); + def->v.value = TypePtr(0); + def->v.valueAsString = scoped->v; + def->v.valueAsLiteral = scoped->v; + } + else + { + EnumeratorPtr enumerator = EnumeratorPtr::dynamicCast(cl.front()); + if(!enumerator) + { + string msg = "illegal initializer: `" + scoped->v + "' is a"; + static const string vowels = "aeiou"; + string kindOf = cl.front()->kindOf(); + if(vowels.find_first_of(kindOf[0]) != string::npos) + { + msg += "n"; + } + msg += " " + kindOf; + unit->error(msg); // $$ is dummy + } + unit->currentContainer()->checkIntroduced(scoped->v, enumerator); + def->v.type = enumerator->type(); + def->v.value = enumerator; + def->v.valueAsString = scoped->v; + def->v.valueAsLiteral = scoped->v; + } + yyval = def; +;} + break; + + case 151: +#line 1648 "../Slice/Grammar.y" + { + BuiltinPtr type = unit->builtin(Builtin::KindString); + StringTokPtr literal = StringTokPtr::dynamicCast(yyvsp[0]); + ConstDefTokPtr def = new ConstDefTok; + def->v.type = type; + def->v.value = type; + def->v.valueAsString = literal->v; + def->v.valueAsLiteral = literal->literal; + yyval = def; +;} + break; + + case 152: +#line 1659 "../Slice/Grammar.y" + { + BuiltinPtr type = unit->builtin(Builtin::KindBool); + StringTokPtr literal = StringTokPtr::dynamicCast(yyvsp[0]); + ConstDefTokPtr def = new ConstDefTok; + def->v.type = type; + def->v.value = type; + def->v.valueAsString = literal->v; + def->v.valueAsLiteral = "false"; + yyval = def; +;} + break; + + case 153: +#line 1670 "../Slice/Grammar.y" + { + BuiltinPtr type = unit->builtin(Builtin::KindBool); + StringTokPtr literal = StringTokPtr::dynamicCast(yyvsp[0]); + ConstDefTokPtr def = new ConstDefTok; + def->v.type = type; + def->v.value = type; + def->v.valueAsString = literal->v; + def->v.valueAsLiteral = "true"; + yyval = def; +;} + break; + + case 154: +#line 1686 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-4]); + TypePtr const_type = TypePtr::dynamicCast(yyvsp[-3]); + StringTokPtr ident = StringTokPtr::dynamicCast(yyvsp[-2]); + ConstDefTokPtr value = ConstDefTokPtr::dynamicCast(yyvsp[0]); + yyval = unit->currentContainer()->createConst(ident->v, const_type, metaData->v, + value->v.value, value->v.valueAsString, value->v.valueAsLiteral); +;} + break; + + case 155: +#line 1695 "../Slice/Grammar.y" + { + StringListTokPtr metaData = StringListTokPtr::dynamicCast(yyvsp[-3]); + TypePtr const_type = TypePtr::dynamicCast(yyvsp[-2]); + ConstDefTokPtr value = ConstDefTokPtr::dynamicCast(yyvsp[0]); + unit->error("missing constant name"); + yyval = unit->currentContainer()->createConst(IceUtil::generateUUID(), const_type, metaData->v, + value->v.value, value->v.valueAsString, + value->v.valueAsLiteral, Dummy); // Dummy +;} + break; + + case 156: +#line 1710 "../Slice/Grammar.y" + { +;} + break; + + case 157: +#line 1713 "../Slice/Grammar.y" + { +;} + break; + + case 158: +#line 1716 "../Slice/Grammar.y" + { +;} + break; + + case 159: +#line 1719 "../Slice/Grammar.y" + { +;} + break; + + case 160: +#line 1722 "../Slice/Grammar.y" + { +;} + break; + + case 161: +#line 1725 "../Slice/Grammar.y" + { +;} + break; + + case 162: +#line 1728 "../Slice/Grammar.y" + { +;} + break; + + case 163: +#line 1731 "../Slice/Grammar.y" + { +;} + break; + + case 164: +#line 1734 "../Slice/Grammar.y" + { +;} + break; + + case 165: +#line 1737 "../Slice/Grammar.y" + { +;} + break; + + case 166: +#line 1740 "../Slice/Grammar.y" + { +;} + break; + + case 167: +#line 1743 "../Slice/Grammar.y" + { +;} + break; + + case 168: +#line 1746 "../Slice/Grammar.y" + { +;} + break; + + case 169: +#line 1749 "../Slice/Grammar.y" + { +;} + break; + + case 170: +#line 1752 "../Slice/Grammar.y" + { +;} + break; + + case 171: +#line 1755 "../Slice/Grammar.y" + { +;} + break; + + case 172: +#line 1758 "../Slice/Grammar.y" + { +;} + break; + + case 173: +#line 1761 "../Slice/Grammar.y" + { +;} + break; + + case 174: +#line 1764 "../Slice/Grammar.y" + { +;} + break; + + case 175: +#line 1767 "../Slice/Grammar.y" + { +;} + break; + + case 176: +#line 1770 "../Slice/Grammar.y" + { +;} + break; + + case 177: +#line 1773 "../Slice/Grammar.y" + { +;} + break; + + case 178: +#line 1776 "../Slice/Grammar.y" + { +;} + break; + + case 179: +#line 1779 "../Slice/Grammar.y" + { +;} + break; + + case 180: +#line 1782 "../Slice/Grammar.y" + { +;} + break; + + case 181: +#line 1785 "../Slice/Grammar.y" + { +;} + break; + + case 182: +#line 1788 "../Slice/Grammar.y" + { +;} + break; + + case 183: +#line 1791 "../Slice/Grammar.y" + { +;} + break; + + case 184: +#line 1794 "../Slice/Grammar.y" + { +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 3429 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 1798 "../Slice/Grammar.y" + + diff --git a/cpp/src/Slice/Grammar.h b/cpp/src/Slice/Grammar.h new file mode 100644 index 00000000000..08d77ed6fa6 --- /dev/null +++ b/cpp/src/Slice/Grammar.h @@ -0,0 +1,130 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + ICE_MODULE = 258, + ICE_CLASS = 259, + ICE_INTERFACE = 260, + ICE_EXCEPTION = 261, + ICE_STRUCT = 262, + ICE_SEQUENCE = 263, + ICE_DICTIONARY = 264, + ICE_ENUM = 265, + ICE_OUT = 266, + ICE_EXTENDS = 267, + ICE_IMPLEMENTS = 268, + ICE_THROWS = 269, + ICE_VOID = 270, + ICE_BYTE = 271, + ICE_BOOL = 272, + ICE_SHORT = 273, + ICE_INT = 274, + ICE_LONG = 275, + ICE_FLOAT = 276, + ICE_DOUBLE = 277, + ICE_STRING = 278, + ICE_OBJECT = 279, + ICE_LOCAL_OBJECT = 280, + ICE_LOCAL = 281, + ICE_CONST = 282, + ICE_FALSE = 283, + ICE_TRUE = 284, + ICE_NONMUTATING = 285, + ICE_IDEMPOTENT = 286, + ICE_SCOPE_DELIMITER = 287, + ICE_IDENTIFIER = 288, + ICE_STRING_LITERAL = 289, + ICE_INTEGER_LITERAL = 290, + ICE_FLOATING_POINT_LITERAL = 291, + ICE_IDENT_OP = 292, + ICE_KEYWORD_OP = 293, + ICE_METADATA_OPEN = 294, + ICE_METADATA_CLOSE = 295, + ICE_GLOBAL_METADATA_OPEN = 296, + ICE_GLOBAL_METADATA_CLOSE = 297, + BAD_CHAR = 298 + }; +#endif +#define ICE_MODULE 258 +#define ICE_CLASS 259 +#define ICE_INTERFACE 260 +#define ICE_EXCEPTION 261 +#define ICE_STRUCT 262 +#define ICE_SEQUENCE 263 +#define ICE_DICTIONARY 264 +#define ICE_ENUM 265 +#define ICE_OUT 266 +#define ICE_EXTENDS 267 +#define ICE_IMPLEMENTS 268 +#define ICE_THROWS 269 +#define ICE_VOID 270 +#define ICE_BYTE 271 +#define ICE_BOOL 272 +#define ICE_SHORT 273 +#define ICE_INT 274 +#define ICE_LONG 275 +#define ICE_FLOAT 276 +#define ICE_DOUBLE 277 +#define ICE_STRING 278 +#define ICE_OBJECT 279 +#define ICE_LOCAL_OBJECT 280 +#define ICE_LOCAL 281 +#define ICE_CONST 282 +#define ICE_FALSE 283 +#define ICE_TRUE 284 +#define ICE_NONMUTATING 285 +#define ICE_IDEMPOTENT 286 +#define ICE_SCOPE_DELIMITER 287 +#define ICE_IDENTIFIER 288 +#define ICE_STRING_LITERAL 289 +#define ICE_INTEGER_LITERAL 290 +#define ICE_FLOATING_POINT_LITERAL 291 +#define ICE_IDENT_OP 292 +#define ICE_KEYWORD_OP 293 +#define ICE_METADATA_OPEN 294 +#define ICE_METADATA_CLOSE 295 +#define ICE_GLOBAL_METADATA_OPEN 296 +#define ICE_GLOBAL_METADATA_CLOSE 297 +#define BAD_CHAR 298 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index d4cca349e2f..fb5c0d5268d 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -56,10 +56,6 @@ $(libdir)/$(LIBNAME): $(libdir)/$(SONAME) ln -s $(SONAME) $@ endif -clean:: - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp - install:: all $(call installlib,$(install_libdir),$(libdir),$(LIBFILENAME),$(SONAME),$(LIBNAME)) diff --git a/cpp/src/Slice/Makefile.mak b/cpp/src/Slice/Makefile.mak index 43a937cb48b..e9312581b07 100644 --- a/cpp/src/Slice/Makefile.mak +++ b/cpp/src/Slice/Makefile.mak @@ -80,8 +80,6 @@ Grammar.cpp Grammar.h: Grammar.y del /q Grammar.output clean:: - -del /q Grammar.cpp Grammar.h - -del /q Scanner.cpp -del /q Slice.res install:: all diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp new file mode 100644 index 00000000000..273f116578c --- /dev/null +++ b/cpp/src/Slice/Scanner.cpp @@ -0,0 +1,2133 @@ +#include +#define yy_create_buffer slice__create_buffer +#define yy_delete_buffer slice__delete_buffer +#define yy_scan_buffer slice__scan_buffer +#define yy_scan_string slice__scan_string +#define yy_scan_bytes slice__scan_bytes +#define yy_flex_debug slice__flex_debug +#define yy_init_buffer slice__init_buffer +#define yy_flush_buffer slice__flush_buffer +#define yy_load_buffer_state slice__load_buffer_state +#define yy_switch_to_buffer slice__switch_to_buffer +#define yyin slice_in +#define yyleng slice_leng +#define yylex slice_lex +#define yyout slice_out +#define yyrestart slice_restart +#define yytext slice_text + +#line 19 "lex.yy.c" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 19 +#define YY_END_OF_BUFFER 20 +static yyconst short int yy_accept[66] = + { 0, + 0, 0, 20, 18, 17, 17, 14, 18, 18, 18, + 15, 15, 18, 13, 8, 18, 9, 18, 0, 15, + 15, 16, 6, 5, 16, 15, 0, 0, 7, 0, + 12, 13, 10, 13, 11, 0, 0, 0, 0, 16, + 0, 16, 15, 0, 1, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, + 0, 0, 0, 4, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 1, 1, 1, 1, 7, + 1, 8, 9, 1, 10, 11, 12, 13, 14, 14, + 14, 14, 14, 14, 14, 15, 15, 16, 1, 1, + 1, 1, 1, 1, 17, 17, 17, 17, 18, 19, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 21, 22, 23, 1, 20, 1, 17, 17, 17, 17, + + 24, 19, 20, 20, 25, 20, 20, 26, 20, 27, + 20, 20, 20, 20, 20, 20, 20, 20, 20, 28, + 20, 20, 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, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[29] = + { 0, + 1, 2, 3, 4, 1, 1, 4, 1, 5, 5, + 1, 1, 6, 6, 6, 1, 7, 7, 7, 8, + 1, 1, 1, 7, 8, 9, 8, 8 + } ; + +static yyconst short int yy_base[78] = + { 0, + 0, 177, 182, 184, 184, 184, 184, 18, 21, 29, + 31, 25, 165, 54, 159, 0, 137, 28, 37, 0, + 0, 49, 184, 184, 0, 131, 38, 0, 184, 67, + 184, 73, 184, 0, 184, 58, 63, 110, 69, 184, + 68, 72, 0, 87, 184, 107, 80, 83, 121, 101, + 118, 119, 119, 109, 184, 86, 101, 103, 184, 102, + 67, 40, 37, 184, 184, 107, 110, 118, 123, 124, + 130, 132, 138, 147, 155, 161, 170 + } ; + +static yyconst short int yy_def[78] = + { 0, + 65, 1, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 11, 65, 66, 65, 67, 65, 68, 65, 11, + 12, 65, 65, 65, 22, 11, 69, 70, 65, 65, + 65, 66, 65, 32, 65, 68, 71, 65, 72, 65, + 65, 65, 70, 65, 65, 65, 65, 65, 73, 65, + 73, 74, 65, 74, 65, 65, 75, 65, 65, 76, + 76, 77, 77, 65, 0, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65 + } ; + +static yyconst short int yy_nxt[213] = + { 0, + 4, 5, 6, 5, 7, 4, 4, 4, 8, 8, + 9, 10, 11, 12, 12, 13, 14, 14, 14, 14, + 15, 16, 17, 14, 14, 14, 14, 14, 19, 36, + 20, 21, 21, 22, 22, 22, 23, 21, 21, 64, + 24, 25, 64, 26, 26, 21, 41, 41, 27, 22, + 22, 22, 65, 38, 27, 30, 30, 30, 28, 36, + 31, 22, 22, 22, 44, 45, 39, 40, 30, 30, + 30, 62, 39, 31, 30, 30, 30, 47, 47, 31, + 42, 42, 42, 38, 42, 42, 42, 56, 44, 45, + 40, 49, 48, 48, 48, 48, 48, 48, 57, 57, + + 57, 40, 58, 59, 58, 59, 62, 60, 32, 32, + 32, 55, 32, 32, 32, 32, 34, 34, 34, 37, + 56, 55, 52, 37, 53, 52, 37, 42, 42, 43, + 43, 37, 37, 50, 46, 37, 48, 48, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 57, 57, 65, 35, + 57, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 33, + 29, 65, 18, 3, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65 + } ; + +static yyconst short int yy_chk[213] = + { 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, 8, 18, + 8, 8, 8, 9, 9, 9, 10, 12, 12, 63, + 10, 11, 62, 11, 11, 11, 27, 27, 11, 19, + 19, 19, 12, 18, 11, 14, 14, 14, 11, 36, + 14, 22, 22, 22, 37, 37, 22, 22, 30, 30, + 30, 61, 22, 30, 32, 32, 32, 39, 39, 32, + 41, 41, 41, 36, 42, 42, 42, 56, 44, 44, + 42, 44, 47, 47, 47, 48, 48, 48, 56, 56, + + 56, 48, 57, 57, 58, 58, 60, 58, 66, 66, + 66, 54, 66, 66, 66, 66, 67, 67, 67, 68, + 53, 52, 51, 68, 50, 49, 68, 69, 69, 70, + 70, 71, 71, 46, 38, 71, 72, 72, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 74, 74, 74, + 74, 74, 74, 74, 74, 74, 75, 75, 26, 17, + 75, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 15, + 13, 3, 2, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include // Before Grammer.h, so that YYSTYPE is defined +#include +#include + +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// '=' : conversion from 'size_t' to 'int', possible loss of data +// The result of fread() is a size_t and gets inserted into an int +// +# pragma warning( 4 : 4267 ) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; +using namespace Slice; + +namespace Slice +{ + +// +// Definitions for the case-insensitive keyword-token map. +// +typedef std::map StringTokenMap; +static StringTokenMap keywordMap; + +void initScanner(); +void checkIdentifier(const string&); +int checkKeyword(string&); + +} + +#define YY_USER_INIT initScanner(); + +#define YY_NEVER_INTERACTIVE 1 +#line 504 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + yy_current_buffer->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 65 "Scanner.l" + + +#line 661 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 66 ) + 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_base[yy_current_state] != 184 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 67 "Scanner.l" +{ + unit->scanPosition(yytext); +} + YY_BREAK +case 2: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 71 "Scanner.l" +{ + unit->scanPosition(yytext); +} + YY_BREAK +case 3: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 75 "Scanner.l" +{ + unit->scanPosition(yytext); +} + YY_BREAK +case 4: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 79 "Scanner.l" +{ + unit->scanPosition(yytext); +} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 83 "Scanner.l" +{ + // C++-style comment + int c; + do + { + c = yyinput(); + if(c == '\n') + { + unit->nextLine(); + } + } + while(c != '\n' && c != EOF); +} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 97 "Scanner.l" +{ + // C-style comment + string comment = yytext + 2; + while(true) + { + int c = yyinput(); + if(c == '\n') + { + comment += static_cast(c); + unit->nextLine(); + } + else if(c == '*') + { + int next = yyinput(); + if(next == '/') + { + break; + } + else + { + comment += static_cast(c); + unput(next); + } + } + else if(c == EOF) + { + unit->warning("EOF in comment"); + break; + } + else + { + comment += static_cast(c); + } + } + if(comment[0] == '*') + { + unit->setComment(comment); + } +} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 137 "Scanner.l" +{ + return ICE_SCOPE_DELIMITER; +} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 141 "Scanner.l" +{ + return ICE_METADATA_OPEN; +} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 145 "Scanner.l" +{ + return ICE_METADATA_CLOSE; +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 149 "Scanner.l" +{ + return ICE_GLOBAL_METADATA_OPEN; +} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 153 "Scanner.l" +{ + return ICE_GLOBAL_METADATA_CLOSE; +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 157 "Scanner.l" +{ + StringTokPtr ident = new StringTok; + ident->v = *yytext == '\\' ? yytext + 1 : yytext; + ident->v.erase(ident->v.find_first_of(" \t\v\n\r\f(")); + *yylvalp = ident; + checkIdentifier(ident->v); + if(*yytext == '\\') + { + return ICE_IDENT_OP; + } + return checkKeyword(ident->v) == ICE_IDENTIFIER ? ICE_IDENT_OP : ICE_KEYWORD_OP; +} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 170 "Scanner.l" +{ + StringTokPtr ident = new StringTok; + ident->v = *yytext == '\\' ? yytext + 1 : yytext; + *yylvalp = ident; + checkIdentifier(ident->v); + return *yytext == '\\' ? ICE_IDENTIFIER : checkKeyword(ident->v); +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 178 "Scanner.l" +{ + StringTokPtr str = new StringTok; + str->literal = "\""; + while(true) + { + char c = static_cast(yyinput()); + str->literal += c; + if(c == '"') + { + break; + } + else if(c == EOF) + { + unit->error("EOF in string"); + break; + } + else if(c == '\n') + { + unit->error("newline in string"); + } + else if(c == '\\') + { + char next = static_cast(yyinput()); + str->literal += next; + switch(next) + { + case '\\': + case '"': + case '\'': + { + str->v += next; + break; + } + + case 'n': + { + str->v += '\n'; + break; + } + + case 'r': + { + str->v += '\r'; + break; + } + + case 't': + { + str->v += '\t'; + break; + } + + case 'v': + { + str->v += '\v'; + break; + } + + case 'f': + { + str->v += '\f'; + break; + } + + case 'a': + { + str->v += '\a'; + break; + } + + case 'b': + { + str->v += '\b'; + break; + } + + case '?': + { + str->v += '\?'; + break; + } + + case '0': + case '1': + case '2': + case '3': + { + static string octalDigits = "01234567"; + unsigned short us = next - '0'; + if(octalDigits.find_first_of(next = static_cast(yyinput())) != string::npos) + { + str->literal += next; + us = us * 8 + next - '0'; + if(octalDigits.find_first_of(next = static_cast(yyinput())) != string::npos) + { + us = us * 8 + next - '0'; + } + else + { + unput(next); + } + } + else + { + unput(next); + } + if(us == 0) + { + unit->error("illegal NUL character in string constant"); + } + str->v += static_cast(us); + break; + } + case 'x': + { + IceUtil::Int64 ull = 0; + while(isxdigit(static_cast(next = static_cast(yyinput())))) + { + str->literal += next; + ull *= 16; + if(isdigit(static_cast(next))) + { + ull += next - '0'; + } + else if(islower(static_cast(next))) + { + ull += next - 'a' + 10; + } + else + { + ull += next - 'A' + 10; + } + } + unput(next); + if(ull == 0) + { + unit->error("illegal NUL character in string constant"); + } + str->v += static_cast(ull); + break; + } + + // TODO: add universal character names + + default: + { + str->v += c; + unput(next); + } + } + } + else + { + str->v += c; + } + } + *yylvalp = str; + return ICE_STRING_LITERAL; +} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 338 "Scanner.l" +{ + IntegerTokPtr itp = new IntegerTok; + itp->literal = string(yytext); + *yylvalp = itp; + if(!IceUtilInternal::stringToInt64(string(yytext), itp->v)) + { + assert(itp->v != 0); + string msg = "integer constant `"; + msg += yytext; + msg += "' out of range"; + unit->error(msg); + } + return ICE_INTEGER_LITERAL; +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 353 "Scanner.l" +{ + errno = 0; + FloatingTokPtr ftp = new FloatingTok; + *yylvalp = ftp; + string literal(yytext); + ftp->literal = literal; + char lastChar = literal[literal.size() - 1]; + if(lastChar == 'f' || lastChar == 'F') + { + literal = literal.substr(0, literal.size() - 1); // Clobber trailing 'f' or 'F' suffix + } + ftp->v = strtod(literal.c_str(), 0); + if((ftp->v == HUGE_VAL || ftp->v == -HUGE_VAL) && errno == ERANGE) + { + string msg = "floating-point constant `"; + msg += yytext; + msg += "' too large (overflow)"; + unit->error(msg); + } + else if(ftp->v == 0 && errno == ERANGE) + { + string msg = "floating-point constant `"; + msg += yytext; + msg += "' too small (underflow)"; + unit->error(msg); + } + return ICE_FLOATING_POINT_LITERAL; +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 382 "Scanner.l" +{ + // Igore white-space + + if(yytext[0] == '\n') + { + unit->nextLine(); + } +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 391 "Scanner.l" +{ + if(yytext[0] < 32 || yytext[0] > 126) + { + stringstream s; + s << "illegal input character: '\\"; + s.width(3); + s.fill('0'); + s << oct << static_cast(static_cast(yytext[0])); + s << "'"; + unit->error(s.str()); + return BAD_CHAR; + } + return yytext[0]; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 406 "Scanner.l" +ECHO; + YY_BREAK +#line 1155 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 66 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 66 ) + 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 == 65); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + yy_current_buffer->yy_at_bol = (c == '\n'); + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 406 "Scanner.l" + + +namespace Slice { + +// +// initScanner() fills the keyword map with all keyword-token pairs. +// + +void +initScanner() +{ + keywordMap["module"] = ICE_MODULE; + keywordMap["class"] = ICE_CLASS; + keywordMap["interface"] = ICE_INTERFACE; + keywordMap["exception"] = ICE_EXCEPTION; + keywordMap["struct"] = ICE_STRUCT; + keywordMap["sequence"] = ICE_SEQUENCE; + keywordMap["dictionary"] = ICE_DICTIONARY; + keywordMap["enum"] = ICE_ENUM; + keywordMap["out"] = ICE_OUT; + keywordMap["extends"] = ICE_EXTENDS; + keywordMap["implements"] = ICE_IMPLEMENTS; + keywordMap["throws"] = ICE_THROWS; + keywordMap["void"] = ICE_VOID; + keywordMap["byte"] = ICE_BYTE; + keywordMap["bool"] = ICE_BOOL; + keywordMap["short"] = ICE_SHORT; + keywordMap["int"] = ICE_INT; + keywordMap["long"] = ICE_LONG; + keywordMap["float"] = ICE_FLOAT; + keywordMap["double"] = ICE_DOUBLE; + keywordMap["string"] = ICE_STRING; + keywordMap["Object"] = ICE_OBJECT; + keywordMap["LocalObject"] = ICE_LOCAL_OBJECT; + keywordMap["local"] = ICE_LOCAL; + keywordMap["const"] = ICE_CONST; + keywordMap["false"] = ICE_FALSE; + keywordMap["true"] = ICE_TRUE; + keywordMap["nonmutating"] = ICE_NONMUTATING; + keywordMap["idempotent"] = ICE_IDEMPOTENT; +} + +// +// Check if an identifier is well-formed. +// + +void +checkIdentifier(const string& id) +{ + if(id.find('_') != string::npos) + { + unit->error("illegal underscore in identifier `" + id + "'"); + } + + // + // Weed out identifiers with reserved suffixes. + // + static const string suffixBlacklist[] = { "Helper", "Holder", "Prx", "Ptr" }; + for(size_t i = 0; i < sizeof(suffixBlacklist) / sizeof(*suffixBlacklist); ++i) + { + if(id.find(suffixBlacklist[i], id.size() - suffixBlacklist[i].size()) != string::npos) + { + unit->error("illegal identifier `" + id + "': `" + suffixBlacklist[i] + "' suffix is reserved"); + } + } +} + +// +// Check if an identifier looks like a keyword. +// If the identifier is a keyword, return the +// corresponding keyword token; otherwise, return +// an identifier token. +// + +int +checkKeyword(string& id) +{ + StringTokenMap::const_iterator pos = keywordMap.find(id); + if(pos != keywordMap.end()) + { + if(pos->first != id) + { + string msg; + msg = "illegal identifier: `" + id + "' differs from keyword `"; + msg += pos->first + "' only in capitalization"; + unit->error(msg); + id = pos->first; + } + return pos->second; + } + return ICE_IDENTIFIER; +} + +} diff --git a/cpp/test/Freeze/complex/.gitignore b/cpp/test/Freeze/complex/.gitignore index 24458ea8bfc..c1641d6cf02 100644 --- a/cpp/test/Freeze/complex/.gitignore +++ b/cpp/test/Freeze/complex/.gitignore @@ -6,7 +6,4 @@ Complex.cpp Complex.h ComplexDict.h ComplexDict.cpp -Grammar.cpp -Grammar.h -Scanner.cpp db/* diff --git a/cpp/test/Freeze/complex/Grammar.cpp b/cpp/test/Freeze/complex/Grammar.cpp new file mode 100644 index 00000000000..d80355cfbe4 --- /dev/null +++ b/cpp/test/Freeze/complex/Grammar.cpp @@ -0,0 +1,1261 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Written by Richard Stallman by simplifying the original so called + ``semantic'' parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_NUMBER = 258 + }; +#endif +#define TOK_NUMBER 258 + + + + +/* Copy the first part of user declarations. */ +#line 1 "Grammar.y" + + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include + +#ifdef _MSC_VER +// I get these warnings from some bison versions: +// warning C4102: 'yyoverflowlab' : unreferenced label +# pragma warning( disable : 4102 ) +// warning C4065: switch statement contains 'default' but no 'case' labels +# pragma warning( disable : 4065 ) +#endif + +using namespace std; +using namespace Ice; + +void +yyerror(const char* s) +{ + parser->error(s); +} + + + +/* 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 0 +#endif + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + +/* Copy the second part of user declarations. */ + + +/* Line 214 of yacc.c. */ +#line 126 "Grammar.tab.c" + +#if ! defined (yyoverflow) || YYERROR_VERBOSE + +# ifndef YYFREE +# define YYFREE free +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# endif + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# define YYSTACK_ALLOC alloca +# endif +# else +# if defined (alloca) || defined (_ALLOCA_H) +# define YYSTACK_ALLOC alloca +# else +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# else +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# endif +#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ + + +#if (! defined (yyoverflow) \ + && (! defined (__cplusplus) \ + || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + short yyss; + YYSTYPE yyvs; + }; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined (__GNUC__) && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + register YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (0) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined (__STDC__) || defined (__cplusplus) + typedef signed char yysigned_char; +#else + typedef short yysigned_char; +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 6 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 11 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 8 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 3 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 6 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 12 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 258 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const unsigned char yytranslate[] = +{ + 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, + 5, 6, 7, 4, 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const unsigned char yyprhs[] = +{ + 0, 0, 3, 5, 7, 11, 15 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yysigned_char yyrhs[] = +{ + 9, 0, -1, 10, -1, 3, -1, 10, 4, 10, + -1, 5, 10, 6, -1, 10, 7, 10, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const unsigned char yyrline[] = +{ + 0, 42, 42, 49, 53, 57, 61 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE +/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_NUMBER", "'+'", "'('", "')'", "'*'", + "$accept", "start", "expr", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const unsigned short yytoknum[] = +{ + 0, 256, 257, 258, 43, 40, 41, 42 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const unsigned char yyr1[] = +{ + 0, 8, 9, 10, 10, 10, 10 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const unsigned char yyr2[] = +{ + 0, 2, 1, 1, 3, 3, 3 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const unsigned char yydefact[] = +{ + 0, 3, 0, 0, 2, 0, 1, 0, 0, 5, + 4, 6 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yysigned_char yydefgoto[] = +{ + -1, 3, 4 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -4 +static const yysigned_char yypact[] = +{ + 6, -4, 6, 2, 3, -3, -4, 6, 6, -4, + 3, 3 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yysigned_char yypgoto[] = +{ + -4, -4, -2 +}; + +/* 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. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const unsigned char yytable[] = +{ + 5, 7, 6, 9, 8, 10, 11, 7, 0, 1, + 8, 2 +}; + +static const yysigned_char yycheck[] = +{ + 2, 4, 0, 6, 7, 7, 8, 4, -1, 3, + 7, 5 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const unsigned char yystos[] = +{ + 0, 3, 5, 9, 10, 10, 0, 4, 7, 6, + 10, 10 +}; + +#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) +# define YYSIZE_T __SIZE_TYPE__ +#endif +#if ! defined (YYSIZE_T) && defined (size_t) +# define YYSIZE_T size_t +#endif +#if ! defined (YYSIZE_T) +# if defined (__STDC__) || defined (__cplusplus) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# endif +#endif +#if ! defined (YYSIZE_T) +# define YYSIZE_T unsigned int +#endif + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror ("syntax error: cannot back up");\ + YYERROR; \ + } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +/* YYLLOC_DEFAULT -- Compute the default location (before the actions + are run). */ + +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + ((Current).first_line = (Rhs)[1].first_line, \ + (Current).first_column = (Rhs)[1].first_column, \ + (Current).last_line = (Rhs)[N].last_line, \ + (Current).last_column = (Rhs)[N].last_column) +#endif + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +# define YYDSYMPRINT(Args) \ +do { \ + if (yydebug) \ + yysymprint Args; \ +} while (0) + +# define YYDSYMPRINTF(Title, Token, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yysymprint (stderr, \ + Token, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_stack_print (short *bottom, short *top) +#else +static void +yy_stack_print (bottom, top) + short *bottom; + short *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (/* Nothing. */; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yy_reduce_print (int yyrule) +#else +static void +yy_reduce_print (yyrule) + int yyrule; +#endif +{ + int yyi; + unsigned int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", + yyrule - 1, yylno); + /* Print the symbols being reduced, and their result. */ + for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) + YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); + YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YYDSYMPRINT(Args) +# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 +# undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined (__GLIBC__) && defined (_STRING_H) +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +# if defined (__STDC__) || defined (__cplusplus) +yystrlen (const char *yystr) +# else +yystrlen (yystr) + const char *yystr; +# endif +{ + register const char *yys = yystr; + + while (*yys++ != '\0') + continue; + + return yys - yystr - 1; +} +# endif +# endif + +# ifndef yystpcpy +# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +# if defined (__STDC__) || defined (__cplusplus) +yystpcpy (char *yydest, const char *yysrc) +# else +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +# endif +{ + register char *yyd = yydest; + register const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +#endif /* !YYERROR_VERBOSE */ + + + +#if YYDEBUG +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) +#else +static void +yysymprint (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + if (yytype < YYNTOKENS) + { + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); +# ifdef YYPRINT + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + } + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + switch (yytype) + { + default: + break; + } + YYFPRINTF (yyoutput, ")"); +} + +#endif /* ! YYDEBUG */ +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +#if defined (__STDC__) || defined (__cplusplus) +static void +yydestruct (int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yytype, yyvaluep) + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + /* Pacify ``unused variable'' warnings. */ + (void) yyvaluep; + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM); +# else +int yyparse (); +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +# if defined (__STDC__) || defined (__cplusplus) +int yyparse (void *YYPARSE_PARAM) +# else +int yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +# endif +#else /* ! YYPARSE_PARAM */ +#if defined (__STDC__) || defined (__cplusplus) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + /* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + register int yystate; + register int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + short yyssa[YYINITDEPTH]; + short *yyss = yyssa; + register short *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + register YYSTYPE *yyvsp; + + + +#define YYPOPSTACK (yyvsp--, yyssp--) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* When reducing, the number of symbols on the RHS of the reduced + rule. */ + int yylen; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. + */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; + + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow ("parser stack overflow", + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyoverflowlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyoverflowlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + short *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyoverflowlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YYDSYMPRINTF ("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; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; + + + /* 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: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 43 "Grammar.y" + { + parser->setResult(yyval); +;} + break; + + case 3: +#line 50 "Grammar.y" + { + yyval = yyvsp[0]; +;} + break; + + case 4: +#line 54 "Grammar.y" + { + yyval = new Complex::AddNodeI(yyvsp[-2], yyvsp[0]); +;} + break; + + case 5: +#line 58 "Grammar.y" + { + yyval = yyvsp[-1]; +;} + break; + + case 6: +#line 62 "Grammar.y" + { + yyval = new Complex::MultiplyNodeI(yyvsp[-2], yyvsp[0]); +;} + break; + + + } + +/* Line 1000 of yacc.c. */ +#line 1035 "Grammar.tab.c" + + yyvsp -= yylen; + yyssp -= yylen; + + + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + 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; +#if YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (YYPACT_NINF < yyn && yyn < YYLAST) + { + YYSIZE_T yysize = 0; + int yytype = YYTRANSLATE (yychar); + const char* yyprefix; + char *yymsg; + int yyx; + + /* 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; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 0; + + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); + yycount += 1; + if (yycount == 5) + { + yysize = 0; + break; + } + } + yysize += (sizeof ("syntax error, unexpected ") + + yystrlen (yytname[yytype])); + yymsg = (char *) YYSTACK_ALLOC (yysize); + if (yymsg != 0) + { + char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); + yyp = yystpcpy (yyp, yytname[yytype]); + + if (yycount < 5) + { + yyprefix = ", expecting "; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + yyp = yystpcpy (yyp, yyprefix); + yyp = yystpcpy (yyp, yytname[yyx]); + yyprefix = " or "; + } + } + yyerror (yymsg); + YYSTACK_FREE (yymsg); + } + else + yyerror ("syntax error; also virtual memory exhausted"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror ("syntax error"); + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* If at end of input, pop the error token, + then the rest of the stack, then return failure. */ + if (yychar == YYEOF) + for (;;) + { + YYPOPSTACK; + if (yyssp == yyss) + YYABORT; + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[*yyssp], yyvsp); + } + } + else + { + YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); + yydestruct (yytoken, &yylval); + yychar = YYEMPTY; + + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + +#ifdef __GNUC__ + /* Pacify GCC when the user code never invokes YYERROR and the label + yyerrorlab therefore never appears in user code. */ + if (0) + goto yyerrorlab; +#endif + + yyvsp -= yylen; + yyssp -= yylen; + yystate = *yyssp; + 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 (yyssp == yyss) + YYABORT; + + YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); + yydestruct (yystos[yystate], yyvsp); + YYPOPSTACK; + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + YYDPRINTF ((stderr, "Shifting error token, ")); + + *++yyvsp = yylval; + + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*----------------------------------------------. +| yyoverflowlab -- parser overflow comes here. | +`----------------------------------------------*/ +yyoverflowlab: + yyerror ("parser stack overflow"); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif + return yyresult; +} + + +#line 67 "Grammar.y" + + diff --git a/cpp/test/Freeze/complex/Grammar.h b/cpp/test/Freeze/complex/Grammar.h new file mode 100644 index 00000000000..ff8b73a45bb --- /dev/null +++ b/cpp/test/Freeze/complex/Grammar.h @@ -0,0 +1,50 @@ +/* A Bison parser, made by GNU Bison 1.875c. */ + +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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 2, 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_NUMBER = 258 + }; +#endif +#define TOK_NUMBER 258 + + + + +#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +typedef int YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + + + + + diff --git a/cpp/test/Freeze/complex/Makefile b/cpp/test/Freeze/complex/Makefile index 7f7839a8244..fbe145612a2 100644 --- a/cpp/test/Freeze/complex/Makefile +++ b/cpp/test/Freeze/complex/Makefile @@ -38,8 +38,6 @@ ComplexDict.h ComplexDict.cpp: Complex.ice $(SLICE2FREEZE) $(SLICEPARSERLIB) clean:: -rm -f ComplexDict.h ComplexDict.cpp - -rm -f Grammar.cpp Grammar.h - -rm -f Scanner.cpp -rm -f db/* include .depend diff --git a/cpp/test/Freeze/complex/Makefile.mak b/cpp/test/Freeze/complex/Makefile.mak index b972e88a941..3a1980eacec 100644 --- a/cpp/test/Freeze/complex/Makefile.mak +++ b/cpp/test/Freeze/complex/Makefile.mak @@ -55,8 +55,6 @@ Grammar.cpp Grammar.h: Grammar.y clean:: del /q Complex.cpp Complex.h - del /q Grammar.cpp Grammar.h - del /q Scanner.cpp del /q ComplexDict.h ComplexDict.cpp for %f in (db\*) do if not %f == db\.gitignore del /q %f diff --git a/cpp/test/Freeze/complex/Scanner.cpp b/cpp/test/Freeze/complex/Scanner.cpp new file mode 100644 index 00000000000..3b980281601 --- /dev/null +++ b/cpp/test/Freeze/complex/Scanner.cpp @@ -0,0 +1,1543 @@ +#include +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* 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) + +/* 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 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 ((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 ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + 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; + + /* 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 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* 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". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define yywrap() 1 +#define YY_SKIP_YYWRAP +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 4 +#define YY_END_OF_BUFFER 5 +static yyconst short int yy_accept[11] = + { 0, + 0, 0, 5, 4, 3, 1, 4, 1, 2, 0 + } ; + +static yyconst int yy_ec[256] = + { 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, 2, + 3, 4, 5, 1, 1, 1, 1, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 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, 7, 1, 1, 1, 8, 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, 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 int yy_meta[9] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst short int yy_base[11] = + { 0, + 0, 0, 13, 14, 14, 6, 4, 4, 2, 14 + } ; + +static yyconst short int yy_def[11] = + { 0, + 10, 1, 10, 10, 10, 10, 10, 10, 10, 0 + } ; + +static yyconst short int yy_nxt[23] = + { 0, + 4, 5, 5, 5, 5, 6, 4, 7, 9, 8, + 9, 8, 10, 3, 10, 10, 10, 10, 10, 10, + 10, 10 + } ; + +static yyconst short int yy_chk[23] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 9, 8, + 7, 6, 3, 10, 10, 10, 10, 10, 10, 10, + 10, 10 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* 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 +char *yytext; +#line 1 "Scanner.l" +#define INITIAL 0 +#line 2 "Scanner.l" + +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include +#include +#include +#include + +#if defined(_MSC_VER) && defined(ICE_64) +// +// 'initializing' : conversion from '__int64' to 'int', possible loss of data +// Puts a pointer-difference into an int +// +# pragma warning( 4 : 4244 ) +#endif + +using namespace std; +using namespace Ice; + +#define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) + +#define YY_NEVER_INTERACTIVE 1 +#line 400 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#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 +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#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) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', 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 if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#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 +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* 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 + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp = NULL, *yy_bp = NULL; + register int yy_act; + +#line 39 "Scanner.l" + + +#line 554 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 11 ) + 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_base[yy_current_state] != 14 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 41 "Scanner.l" +{ + *yylvalp = new Complex::NumberNodeI(atoi(yytext)); + return TOK_NUMBER; +} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 46 "Scanner.l" +/* eat whitespace */ + YY_BREAK +case 3: +YY_RULE_SETUP +#line 48 "Scanner.l" +{ return *yytext; } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 50 "Scanner.l" +ECHO; + YY_BREAK +#line 660 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->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. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->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 ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* 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 ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* 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. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = 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 */ + + +/* 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 + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - 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) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->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->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (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. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + 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" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 11 ) + 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 ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + 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 >= 11 ) + 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 == 10); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *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 ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + 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 ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } +#endif /* YY_NO_INPUT */ + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* 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. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 *) yy_flex_alloc( b->yy_buf_size + 2 ); + 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 ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + 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(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + 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) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + 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 ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + 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_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* 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 ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 50 "Scanner.l" + -- cgit v1.2.3 From 8236f92ed7bc5b88d6de54075ee9001139d26016 Mon Sep 17 00:00:00 2001 From: Jose Date: Sat, 10 Jan 2009 03:02:30 +0100 Subject: Partial fix to 3140 - slice2cpp warning: Unknown encoding: C --- cpp/src/Slice/Preprocessor.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cpp/src') diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 4a4c8b17652..263aa37149a 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -125,6 +125,8 @@ Slice::Preprocessor::preprocess(bool keepComments) { args.push_back("-C"); } + args.push_back("-e"); + args.push_back("utf8"); args.push_back(_fileName); const char** argv = new const char*[args.size() + 1]; @@ -227,6 +229,8 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector args = _args; args.push_back("-M"); + args.push_back("-e"); + args.push_back("utf8"); args.push_back(_fileName); const char** argv = new const char*[args.size() + 1]; -- cgit v1.2.3 From 1d94690a0c0f425d06bfc39123da517808c82556 Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Mon, 12 Jan 2009 10:51:17 -0330 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3399 C# generated struct sequence marshaling bogus --- cpp/src/Slice/CsUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cpp/src') diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 2edb6aa8e39..a5d5c78a7e4 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -1119,7 +1119,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { call += "_tmp"; } - call += " == null ? new " + typeS + "() : " + param; + call += "[ix__] == null ? new " + typeS + "() : " + param; if(isStack) { call += "_tmp"; -- cgit v1.2.3 From 86d1e1192e81e9eb684d647238fff7a67ec45fcb Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Mon, 12 Jan 2009 13:24:24 -0330 Subject: Squashed commit of the following: commit b73098371dca786520d9eab2731d1887a60685b1 Author: Matthew Newhook Date: Mon Jan 12 13:22:59 2009 -0330 http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3518 slice2XXX --depend exit status is bogus --- cpp/include/Slice/Preprocessor.h | 2 +- cpp/src/Slice/Preprocessor.cpp | 7 ++++--- cpp/src/slice2cpp/Main.cpp | 5 ++++- cpp/src/slice2freezej/Main.cpp | 5 ++++- cpp/src/slice2java/Main.cpp | 5 ++++- 5 files changed, 17 insertions(+), 7 deletions(-) (limited to 'cpp/src') diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h index f6f5ede2e5d..98a018fbfbe 100644 --- a/cpp/include/Slice/Preprocessor.h +++ b/cpp/include/Slice/Preprocessor.h @@ -40,7 +40,7 @@ public: enum Language { CPlusPlus, Java, CSharp, VisualBasic }; - void printMakefileDependencies(Language, const std::vector&); + bool printMakefileDependencies(Language, const std::vector&); std::string getBaseName(); diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 263aa37149a..b61d43cc5c0 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -216,12 +216,12 @@ Slice::Preprocessor::preprocess(bool keepComments) return _cppHandle; } -void +bool Slice::Preprocessor::printMakefileDependencies(Language lang, const vector& includePaths) { if(!checkInputFile()) { - return; + return false; } // @@ -261,7 +261,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector Date: Mon, 12 Jan 2009 13:24:42 -0330 Subject: Squashed commit of the following: commit 0c7025d761813d2e121e8573ba16c14e5a6a4ea5 Author: Matthew Newhook Date: Mon Jan 12 08:09:36 2009 -0330 http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3396 slice2java fails silently if it cannot create dir --- cpp/include/Slice/JavaUtil.h | 23 ++- cpp/src/Slice/JavaUtil.cpp | 78 +++++++-- cpp/src/slice2java/Gen.cpp | 370 +++++++++++++++++-------------------------- cpp/src/slice2java/Main.cpp | 55 ++++--- 4 files changed, 265 insertions(+), 261 deletions(-) (limited to 'cpp/src') diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h index 21921506775..5d4b3ebd7e0 100644 --- a/cpp/include/Slice/JavaUtil.h +++ b/cpp/include/Slice/JavaUtil.h @@ -16,6 +16,25 @@ namespace Slice { +class SLICE_API FileException : public ::IceUtil::Exception +{ +public: + + FileException(const char*, int, const std::string&); + ~FileException() throw(); + virtual std::string ice_name() const; + virtual void ice_print(std::ostream&) const; + virtual Exception* ice_clone() const; + virtual void ice_throw() const; + + std::string reason() const; + +private: + + static const char* _name; + const std::string _reason; +}; + class SLICE_API JavaOutput : public ::IceUtilInternal::Output { public: @@ -36,7 +55,7 @@ public: // printHeader() and then emits a "package" statement if // necessary. // - bool openClass(const std::string&, const std::string& = std::string()); + void openClass(const std::string&, const std::string& = std::string()); virtual void printHeader(); }; @@ -64,7 +83,7 @@ protected: // Given the fully-scoped Java class name, create any intermediate // package directories and open the class file // - bool open(const std::string&); + void open(const std::string&); ::IceUtilInternal::Output& output() const; diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 783180f60e1..725e5e60268 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -26,6 +26,49 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; +Slice::FileException::FileException(const char* file, int line, const string& r) : + Exception(file, line), + _reason(r) +{ +} + +Slice::FileException::~FileException() throw() +{ +} + +const char* Slice::FileException::_name = "Slice::FileException"; + +string +Slice::FileException::ice_name() const +{ + return _name; +} + +void +Slice::FileException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ": " << _reason; +} + +IceUtil::Exception* +Slice::FileException::ice_clone() const +{ + return new FileException(*this); +} + +void +Slice::FileException::ice_throw() const +{ + throw *this; +} + +string +Slice::FileException::reason() const +{ + return _reason; +} + Slice::JavaOutput::JavaOutput() { } @@ -40,7 +83,7 @@ Slice::JavaOutput::JavaOutput(const char* s) : { } -bool +void Slice::JavaOutput::openClass(const string& cls, const string& prefix) { string package; @@ -81,6 +124,13 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) result = stat(path.c_str(), &st); if(result == 0) { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create package directory `" << path + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } continue; } #ifdef _WIN32 @@ -90,7 +140,9 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) #endif if(result != 0) { - return false; + ostringstream os; + os << "cannot create directory `" << path << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } } while(pos != string::npos); @@ -123,11 +175,13 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) print(package.c_str()); print(";"); } - - return true; } - - return false; + else + { + ostringstream os; + os << "cannot open file `" << path << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } } void @@ -172,22 +226,22 @@ Slice::JavaGenerator::~JavaGenerator() assert(_out == 0); } -bool +void Slice::JavaGenerator::open(const string& absolute) { assert(_out == 0); JavaOutput* out = createOutput(); - if(out->openClass(absolute, _dir)) + try { - _out = out; + out->openClass(absolute, _dir); } - else + catch(const FileException&) { delete out; + throw; } - - return _out != 0; + _out = out; } void diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index d6fe11eea60..ab9cc42aed4 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -1279,11 +1279,7 @@ Slice::Gen::writeChecksumClass(const string& checksumClass, const string& dir, c // Attempt to open the source file for the checksum class. // JavaOutput out; - if(!out.openClass(checksumClass, dir)) - { - cerr << "can't open class `" << checksumClass << "' for writing: " << strerror(errno) << endl; - return; - } + out.openClass(checksumClass, dir); // // Get the class name. @@ -1383,10 +1379,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent) } string absolute = getAbsolute(p, "", "_", opIntfName); - if(!open(absolute)) - { - return; - } + open(absolute); Output& out = output(); @@ -1507,10 +1500,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) return false; } - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -1693,11 +1683,7 @@ Slice::Gen::PackageVisitor::visitModuleStart(const ModulePtr& p) { string markerClass = s.substr(packagePrefix.size()) + "." + fixKwd(p->name()) + "._Marker"; - if(!open(markerClass)) - { - cerr << "can't open class `" << markerClass << "' for writing: " << strerror(errno) << endl; - return false; - } + open(markerClass); Output& out = output(); out << sp << nl << "interface _Marker"; @@ -1733,10 +1719,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p) DataMemberList allDataMembers = p->allDataMembers(); DataMemberList::const_iterator d; - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -1951,10 +1934,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) DataMemberList members = p->dataMembers(); DataMemberList::const_iterator d; - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -2285,10 +2265,7 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) string name = fixKwd(p->name()); string absolute = getAbsolute(p); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -2809,10 +2786,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p) EnumeratorList::const_iterator en; size_t sz = enumerators.size(); - if(!open(absolute)) - { - return; - } + open(absolute); Output& out = output(); @@ -3035,10 +3009,8 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p) string absolute = getAbsolute(p); TypePtr type = p->type(); - if(!open(absolute)) - { - return; - } + open(absolute); + Output& out = output(); out << sp << nl << "public interface " << name; out << sb; @@ -3188,22 +3160,20 @@ Slice::Gen::HolderVisitor::visitClassDefStart(const ClassDefPtr& p) string name = p->name(); string absolute = getAbsolute(p, "", "", "PrxHolder"); - if(open(absolute)) - { - Output& out = output(); - out << sp << nl << "public final class " << name << "PrxHolder"; - out << sb; - out << sp << nl << "public" << nl << name << "PrxHolder()"; - out << sb; - out << eb; - out << sp << nl << "public" << nl << name << "PrxHolder(" << name << "Prx value)"; - out << sb; - out << nl << "this.value = value;"; - out << eb; - out << sp << nl << "public " << name << "Prx value;"; - out << eb; - close(); - } + open(absolute); + Output& out = output(); + out << sp << nl << "public final class " << name << "PrxHolder"; + out << sb; + out << sp << nl << "public" << nl << name << "PrxHolder()"; + out << sb; + out << eb; + out << sp << nl << "public" << nl << name << "PrxHolder(" << name << "Prx value)"; + out << sb; + out << nl << "this.value = value;"; + out << eb; + out << sp << nl << "public " << name << "Prx value;"; + out << eb; + close(); } return false; @@ -3242,68 +3212,66 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p) string name = contained->name(); string absolute = getAbsolute(contained, "", "", "Holder"); - if(open(absolute)) + open(absolute); + Output& out = output(); + string typeS = typeToString(p, TypeModeIn, getPackage(contained)); + out << sp << nl << "public final class " << name << "Holder"; + out << sb; + out << sp << nl << "public" << nl << name << "Holder()"; + out << sb; + out << eb; + out << sp << nl << "public" << nl << name << "Holder(" << typeS << " value)"; + out << sb; + out << nl << "this.value = value;"; + out << eb; + if(!p->isLocal()) { - Output& out = output(); - string typeS = typeToString(p, TypeModeIn, getPackage(contained)); - out << sp << nl << "public final class " << name << "Holder"; - out << sb; - out << sp << nl << "public" << nl << name << "Holder()"; - out << sb; - out << eb; - out << sp << nl << "public" << nl << name << "Holder(" << typeS << " value)"; - out << sb; - out << nl << "this.value = value;"; - out << eb; - if(!p->isLocal()) + BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) { - BuiltinPtr builtin = BuiltinPtr::dynamicCast(p); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p)) + out << sp << nl << "public class Patcher implements IceInternal.Patcher"; + if(_stream) { - out << sp << nl << "public class Patcher implements IceInternal.Patcher"; - if(_stream) - { - out << ", Ice.ReadObjectCallback"; - } - out << sb; - out << nl << "public void"; - out << nl << "patch(Ice.Object v)"; - out << sb; - out << nl << "try"; - out << sb; - out << nl << "value = (" << typeS << ")v;"; - out << eb; - out << nl << "catch(ClassCastException ex)"; - out << sb; - out << nl << "IceInternal.Ex.throwUOE(type(), v.ice_id());"; - out << eb; - out << eb; - - out << sp << nl << "public String" << nl << "type()"; - out << sb; - out << nl << "return \"" << p->typeId() << "\";"; - out << eb; + out << ", Ice.ReadObjectCallback"; + } + out << sb; + out << nl << "public void"; + out << nl << "patch(Ice.Object v)"; + out << sb; + out << nl << "try"; + out << sb; + out << nl << "value = (" << typeS << ")v;"; + out << eb; + out << nl << "catch(ClassCastException ex)"; + out << sb; + out << nl << "IceInternal.Ex.throwUOE(type(), v.ice_id());"; + out << eb; + out << eb; - if(_stream) - { - out << sp << nl << "public void" << nl << "invoke(Ice.Object v)"; - out << sb; - out << nl << "patch(v);"; - out << eb; - } - out << eb; + out << sp << nl << "public String" << nl << "type()"; + out << sb; + out << nl << "return \"" << p->typeId() << "\";"; + out << eb; - out << sp << nl << "public Patcher"; - out << nl << "getPatcher()"; + if(_stream) + { + out << sp << nl << "public void" << nl << "invoke(Ice.Object v)"; out << sb; - out << nl << "return new Patcher();"; + out << nl << "patch(v);"; out << eb; } + out << eb; + + out << sp << nl << "public Patcher"; + out << nl << "getPatcher()"; + out << sb; + out << nl << "return new Patcher();"; + out << eb; } - out << sp << nl << "public " << typeS << " value;"; - out << eb; - close(); } + out << sp << nl << "public " << typeS << " value;"; + out << eb; + close(); } Slice::Gen::HelperVisitor::HelperVisitor(const string& dir, bool stream) : @@ -3328,10 +3296,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p); - if(!open(getAbsolute(p, "", "", "PrxHelper"))) - { - return false; - } + open(getAbsolute(p, "", "", "PrxHelper")); Output& out = output(); @@ -3698,10 +3663,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) // // Class helper. // - if(!open(getAbsolute(p, "", "", "Helper"))) - { - return false; - } + open(getAbsolute(p, "", "", "Helper")); Output& out2 = output(); @@ -3733,10 +3695,7 @@ Slice::Gen::HelperVisitor::visitStructStart(const StructPtr& p) string name = p->name(); string fixedName = fixKwd(name); - if(!open(getAbsolute(p, "", "", "Helper"))) - { - return false; - } + open(getAbsolute(p, "", "", "Helper")); Output& out = output(); @@ -3779,48 +3738,46 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p) string package = getPackage(p); string typeS = typeToString(p, TypeModeIn, package); - if(open(helper)) - { - Output& out = output(); - int iter; + open(helper); + Output& out = output(); + int iter; - out << sp << nl << "public final class " << name << "Helper"; - out << sb; + out << sp << nl << "public final class " << name << "Helper"; + out << sb; - out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << typeS << " __v)"; + out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << typeS << " __v)"; + out << sb; + iter = 0; + writeSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); + out << eb; + + out << sp << nl << "public static " << typeS << nl << "read(IceInternal.BasicStream __is)"; + out << sb; + out << nl << typeS << " __v;"; + iter = 0; + writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + out << nl << "return __v;"; + out << eb; + + if(_stream) + { + out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << typeS << " __v)"; out << sb; iter = 0; - writeSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); + writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); out << eb; - out << sp << nl << "public static " << typeS << nl << "read(IceInternal.BasicStream __is)"; + out << sp << nl << "public static " << typeS << nl << "read(Ice.InputStream __inS)"; out << sb; out << nl << typeS << " __v;"; iter = 0; - writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); out << nl << "return __v;"; out << eb; - - if(_stream) - { - out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << typeS << " __v)"; - out << sb; - iter = 0; - writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); - out << eb; - - out << sp << nl << "public static " << typeS << nl << "read(Ice.InputStream __inS)"; - out << sb; - out << nl << typeS << " __v;"; - iter = 0; - writeStreamSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); - out << nl << "return __v;"; - out << eb; - } - - out << eb; - close(); } + + out << eb; + close(); } void @@ -3844,51 +3801,49 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p) StringList metaData = p->getMetaData(); string formalType = typeToString(p, TypeModeIn, package, StringList(), true); - if(open(helper)) - { - Output& out = output(); - int iter; + open(helper); + Output& out = output(); + int iter; - out << sp << nl << "public final class " << name << "Helper"; - out << sb; + out << sp << nl << "public final class " << name << "Helper"; + out << sb; + + out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << formalType << " __v)"; + out << sb; + iter = 0; + writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); + out << eb; - out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << formalType << " __v)"; + out << sp << nl << "public static " << formalType + << nl << "read(IceInternal.BasicStream __is)"; + out << sb; + out << nl << formalType << " __v;"; + iter = 0; + writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + out << nl << "return __v;"; + out << eb; + + if(_stream) + { + out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << formalType + << " __v)"; out << sb; iter = 0; - writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); + writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); out << eb; out << sp << nl << "public static " << formalType - << nl << "read(IceInternal.BasicStream __is)"; + << nl << "read(Ice.InputStream __inS)"; out << sb; out << nl << formalType << " __v;"; iter = 0; - writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); + writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); out << nl << "return __v;"; out << eb; - - if(_stream) - { - out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << formalType - << " __v)"; - out << sb; - iter = 0; - writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false); - out << eb; - - out << sp << nl << "public static " << formalType - << nl << "read(Ice.InputStream __inS)"; - out << sb; - out << nl << formalType << " __v;"; - iter = 0; - writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false); - out << nl << "return __v;"; - out << eb; - } - - out << eb; - close(); } + + out << eb; + close(); } void @@ -3899,10 +3854,7 @@ Slice::Gen::HelperVisitor::visitEnum(const EnumPtr& p) string name = p->name(); string fixedName = fixKwd(name); - if(!open(getAbsolute(p, "", "", "Helper"))) - { - return; - } + open(getAbsolute(p, "", "", "Helper")); Output& out = output(); @@ -3942,10 +3894,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "", "Prx"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -4076,10 +4025,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "_", "Del"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -4154,10 +4100,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "_", "DelM"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -4358,10 +4301,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "_", "DelD"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -4546,10 +4486,7 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p) ClassList bases = p->bases(); string absolute = getAbsolute(p, "", "_", "Disp"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -4844,10 +4781,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "", "I"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -4905,10 +4839,7 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p) string package = getPackage(p); string absolute = getAbsolute(p, "", "", "I"); - if(!open(absolute)) - { - return false; - } + open(absolute); Output& out = output(); @@ -5005,10 +4936,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) string classNameAMI = "AMI_" + cl->name(); string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name); - if(!open(absoluteAMI)) - { - return; - } + open(absoluteAMI); Output& out = output(); @@ -5235,10 +5163,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) vector paramsAMD = getParamsAsyncCB(p, classPkg); { - if(!open(absoluteAMD)) - { - return; - } + open(absoluteAMD); Output& out = output(); @@ -5252,10 +5177,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) } { - if(!open(absoluteAMDI)) - { - return; - } + open(absoluteAMDI); Output& out = output(); diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index e515b95d5b9..b2fff573e39 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -241,32 +241,41 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], icecpp.getBaseName(), includePaths, output); - if(!gen) + try { - p->destroy(); - return EXIT_FAILURE; - } - gen.generate(p, stream); - if(tie) - { - gen.generateTie(p); - } - if(impl) - { - gen.generateImpl(p); - } - if(implTie) - { - gen.generateImplTie(p); + Gen gen(argv[0], icecpp.getBaseName(), includePaths, output); + if(!gen) + { + p->destroy(); + return EXIT_FAILURE; + } + gen.generate(p, stream); + if(tie) + { + gen.generateTie(p); + } + if(impl) + { + gen.generateImpl(p); + } + if(implTie) + { + gen.generateImplTie(p); + } + if(!checksumClass.empty()) + { + // + // Calculate checksums for the Slice definitions in the unit. + // + ChecksumMap m = createChecksums(p); + copy(m.begin(), m.end(), inserter(checksums, checksums.begin())); + } } - if(!checksumClass.empty()) + catch(const Slice::FileException& ex) { - // - // Calculate checksums for the Slice definitions in the unit. - // - ChecksumMap m = createChecksums(p); - copy(m.begin(), m.end(), inserter(checksums, checksums.begin())); + p->destroy(); + cerr << ex.reason() << endl; + return EXIT_FAILURE; } } p->destroy(); -- cgit v1.2.3 From 06f7a74f1f1a073a57c7a43374db85675b6c293f Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Mon, 12 Jan 2009 14:08:11 -0330 Subject: Fixed bug with slice2freezej. --- cpp/src/slice2freezej/Main.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 728493084e1..9bae291e172 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -370,12 +370,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) } } - - if(!open(dict.name)) - { - cerr << _prog << ": unable to open class " << dict.name << endl; - return false; - } + open(dict.name); Output& out = output(); @@ -1010,11 +1005,7 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) string memberTypeString = typeToString(dataMember->type(), TypeModeIn); - if(!open(index.name)) - { - cerr << _prog << ": unable to open class " << index.name << endl; - return false; - } + open(index.name); Output& out = output(); @@ -1516,6 +1507,12 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } } + catch(const Slice::FileException& ex) + { + u->destroy(); + cerr << ex.reason() << endl; + return EXIT_FAILURE; + } catch(...) { cerr << argv[0] << ": unknown exception" << endl; -- cgit v1.2.3 From de2673ba7e839a39615aba05aa86bc62f6abd246 Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Mon, 12 Jan 2009 14:38:58 -0330 Subject: another fix for 3396. --- cpp/src/Slice/JavaUtil.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cpp/src') diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 725e5e60268..e4ee4d6c392 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -223,6 +223,12 @@ Slice::JavaGenerator::JavaGenerator(const string& dir, Slice::FeatureProfile pro Slice::JavaGenerator::~JavaGenerator() { + // If open throws an exception other generators could be left open + // during the stack unwind. + if(_out != 0) + { + close(); + } assert(_out == 0); } -- cgit v1.2.3 From 928612ada646fb192dc090998d9f62002d0617a7 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 12 Jan 2009 17:45:24 -0500 Subject: Fixed build failure on VC90 --- cpp/src/Slice/JavaUtil.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'cpp/src') diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index e4ee4d6c392..3e790d63f16 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include -- cgit v1.2.3 From d203f151f5504edca8b65a9df1dbadeba80af261 Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 13 Jan 2009 00:45:11 +0100 Subject: Missing include, needed for gcc-4.3.2 --- cpp/src/Slice/JavaUtil.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'cpp/src') diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 3e790d63f16..2a1114aa064 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -13,6 +13,7 @@ #include #include +#include #ifdef _WIN32 #include -- cgit v1.2.3 From efea74327637afce0a7f83b24d8c2f8b1d224f73 Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Tue, 13 Jan 2009 17:58:32 -0330 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3640 - If slice2java errors out generated files are left behind - Added file tracker - Added calls to file tracker when files or directories are created. - All translators cleanup created files if interrupted, or if they fail. - Normalized various error messages. - Fixed bug with slice2cs which would not correctly check if the impl files were created. Squashed commit of the following: commit 0fec143af219d59dcec5b91cb96a79179f73bd0d Author: Matthew Newhook Date: Tue Jan 13 17:57:25 2009 -0330 Fixed FileException for VC6. commit 38b22497c751ad9b2f86af2d44e87a23c0049d9c Merge: df29064... 4421a3d... Author: Matthew Newhook Date: Tue Jan 13 17:55:49 2009 -0330 Merged R3_3_branch. commit df290649637685bfff4f777ccf53f4f04fda71a0 Author: Matthew Newhook Date: Tue Jan 13 17:45:18 2009 -0330 move checksum writing outside loop commit a9bb2356167b1f9259ce2d1f1b43d40b7fd0ce82 Author: Matthew Newhook Date: Tue Jan 13 17:35:00 2009 -0330 added quotes commit a2f3d7a2414d08ebdc290222b8e97d8b203cc9ab Author: Matthew Newhook Date: Tue Jan 13 17:21:27 2009 -0330 can't -> cannot commit c3113e33a3687cae369bf7803e4f1d18c9141762 Author: Matthew Newhook Date: Tue Jan 13 17:10:12 2009 -0330 minor fixes to output. commit 2a17d6e1b6c0e5eed8be79b8353ca3c06572e19c Author: U-WIN-5WBK5GD0FYQ\matthew Date: Tue Jan 13 12:05:46 2009 -0800 windows fixes. commit d8d4f6dc35043fb71b599dac7171fee0c2bb87bf Author: Matthew Newhook Date: Tue Jan 13 15:58:21 2009 -0330 remove debugging. commit f1e4d7a55e13fea4c0b84244fb437bd391fbe538 Author: Matthew Newhook Date: Tue Jan 13 15:53:37 2009 -0330 Added FileTracker. Added file tracking, and cleanup to lots of translators. commit 33dbfb0124509779bd2d95bbac06a02ca9b907ac Author: Matthew Newhook Date: Tue Jan 13 09:42:16 2009 -0330 http://bugzilla/bugzilla/show_bug.cgi?id=3640 If slice2java errors out generated files are left behind --- cpp/include/Slice/FileTracker.h | 62 ++++++ cpp/include/Slice/JavaUtil.h | 19 -- cpp/src/Slice/FileTracker.cpp | 117 +++++++++++ cpp/src/Slice/JavaUtil.cpp | 47 +---- cpp/src/Slice/Makefile | 1 + cpp/src/Slice/Makefile.mak | 1 + cpp/src/Slice/Preprocessor.cpp | 2 +- cpp/src/slice2cpp/Gen.cpp | 54 +++-- cpp/src/slice2cpp/Gen.h | 3 - cpp/src/slice2cpp/Main.cpp | 17 +- cpp/src/slice2cs/Gen.cpp | 28 +-- cpp/src/slice2cs/Gen.h | 3 - cpp/src/slice2cs/Main.cpp | 52 +++-- cpp/src/slice2docbook/Gen.cpp | 15 +- cpp/src/slice2docbook/Gen.h | 4 +- cpp/src/slice2docbook/Main.cpp | 15 +- cpp/src/slice2freeze/Main.cpp | 428 +++++++++++++++++++++------------------- cpp/src/slice2freezej/Main.cpp | 129 +++++++----- cpp/src/slice2html/Gen.cpp | 37 +++- cpp/src/slice2html/Main.cpp | 13 ++ cpp/src/slice2java/Main.cpp | 24 ++- cpp/src/slice2py/Main.cpp | 208 +++++++++---------- cpp/src/slice2rb/Main.cpp | 43 ++-- 23 files changed, 788 insertions(+), 534 deletions(-) create mode 100644 cpp/include/Slice/FileTracker.h create mode 100644 cpp/src/Slice/FileTracker.cpp (limited to 'cpp/src') diff --git a/cpp/include/Slice/FileTracker.h b/cpp/include/Slice/FileTracker.h new file mode 100644 index 00000000000..944774d809b --- /dev/null +++ b/cpp/include/Slice/FileTracker.h @@ -0,0 +1,62 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#ifndef FILE_TRACKER_H +#define FILE_TRACKER_H + +#include +#include + +namespace Slice +{ + +class SLICE_API FileException : public ::IceUtil::Exception +{ +public: + + FileException(const char*, int, const std::string&); + ~FileException() throw(); + virtual std::string ice_name() const; + virtual void ice_print(std::ostream&) const; + virtual ::IceUtil::Exception* ice_clone() const; + virtual void ice_throw() const; + + std::string reason() const; + +private: + + static const char* _name; + const std::string _reason; +}; + +class FileTracker; +typedef IceUtil::Handle FileTrackerPtr; + +class SLICE_API FileTracker : public ::IceUtil::SimpleShared +{ +public: + + FileTracker(); + ~FileTracker(); + + static FileTrackerPtr instance(); + + void addFile(const std::string&); + void addDirectory(const std::string&); + + void cleanup(); + +private: + + std::list > _files; +}; + +} + +#endif diff --git a/cpp/include/Slice/JavaUtil.h b/cpp/include/Slice/JavaUtil.h index 1f00ad906fd..d85ae3cf2bb 100644 --- a/cpp/include/Slice/JavaUtil.h +++ b/cpp/include/Slice/JavaUtil.h @@ -16,25 +16,6 @@ namespace Slice { -class SLICE_API FileException : public ::IceUtil::Exception -{ -public: - - FileException(const char*, int, const std::string&); - ~FileException() throw(); - virtual std::string ice_name() const; - virtual void ice_print(std::ostream&) const; - virtual ::IceUtil::Exception* ice_clone() const; - virtual void ice_throw() const; - - std::string reason() const; - -private: - - static const char* _name; - const std::string _reason; -}; - class SLICE_API JavaOutput : public ::IceUtilInternal::Output { public: diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp new file mode 100644 index 00000000000..438670cf2f8 --- /dev/null +++ b/cpp/src/Slice/FileTracker.cpp @@ -0,0 +1,117 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include + +#ifdef _WIN32 +# include +#endif + +using namespace std; + +Slice::FileException::FileException(const char* file, int line, const string& r) : + Exception(file, line), + _reason(r) +{ +} + +Slice::FileException::~FileException() throw() +{ +} + +const char* Slice::FileException::_name = "Slice::FileException"; + +string +Slice::FileException::ice_name() const +{ + return _name; +} + +void +Slice::FileException::ice_print(ostream& out) const +{ + Exception::ice_print(out); + out << ": " << _reason; +} + +IceUtil::Exception* +Slice::FileException::ice_clone() const +{ + return new FileException(*this); +} + +void +Slice::FileException::ice_throw() const +{ + throw *this; +} + +string +Slice::FileException::reason() const +{ + return _reason; +} + + +static Slice::FileTrackerPtr Instance; + +Slice::FileTracker::FileTracker() +{ +} + +Slice::FileTracker::~FileTracker() +{ +} + +// The file tracker is not supposed to be thread safe. +Slice::FileTrackerPtr +Slice::FileTracker::instance() +{ + if(!Instance) + { + Instance = new FileTracker(); + } + return Instance; +} + +void +Slice::FileTracker::addFile(const string& file) +{ + _files.push_front(make_pair(file, false)); +} + +void +Slice::FileTracker::addDirectory(const string& dir) +{ + _files.push_front(make_pair(dir, true)); +} + +void +Slice::FileTracker::cleanup() +{ + for(list >::const_iterator p = _files.begin(); p != _files.end(); ++p) + { + if(!p->second) + { +#ifdef _WIN32 + _unlink(p->first.c_str()); +#else + unlink(p->first.c_str()); +#endif + } + else + { +#ifdef _WIN32 + _rmdir(p->first.c_str()); +#else + rmdir(p->first.c_str()); +#endif + } + } +} diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 2a1114aa064..7c73227bc55 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -7,7 +7,9 @@ // // ********************************************************************** +#include #include +#include #include #include @@ -28,49 +30,6 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; -Slice::FileException::FileException(const char* file, int line, const string& r) : - Exception(file, line), - _reason(r) -{ -} - -Slice::FileException::~FileException() throw() -{ -} - -const char* Slice::FileException::_name = "Slice::FileException"; - -string -Slice::FileException::ice_name() const -{ - return _name; -} - -void -Slice::FileException::ice_print(ostream& out) const -{ - Exception::ice_print(out); - out << ": " << _reason; -} - -IceUtil::Exception* -Slice::FileException::ice_clone() const -{ - return new FileException(*this); -} - -void -Slice::FileException::ice_throw() const -{ - throw *this; -} - -string -Slice::FileException::reason() const -{ - return _reason; -} - Slice::JavaOutput::JavaOutput() { } @@ -146,6 +105,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) os << "cannot create directory `" << path << "': " << strerror(errno); throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addDirectory(path); } while(pos != string::npos); } @@ -167,6 +127,7 @@ Slice::JavaOutput::openClass(const string& cls, const string& prefix) open(path.c_str()); if(isOpen()) { + FileTracker::instance()->addFile(path); printHeader(); if(!package.empty()) diff --git a/cpp/src/Slice/Makefile b/cpp/src/Slice/Makefile index fb5c0d5268d..7232e2fe64a 100644 --- a/cpp/src/Slice/Makefile +++ b/cpp/src/Slice/Makefile @@ -27,6 +27,7 @@ OBJS = Scanner.o \ DotNetNames.o \ RubyUtil.o \ Util.o \ + FileTracker.o \ MD5.o \ MD5I.o diff --git a/cpp/src/Slice/Makefile.mak b/cpp/src/Slice/Makefile.mak index e9312581b07..ad3e5a89611 100644 --- a/cpp/src/Slice/Makefile.mak +++ b/cpp/src/Slice/Makefile.mak @@ -26,6 +26,7 @@ OBJS = Scanner.obj \ DotNetNames.obj \ RubyUtil.obj \ Util.obj \ + FileTracker.obj \ MD5.obj \ MD5I.obj diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index b61d43cc5c0..dd1260f2fa0 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -517,7 +517,7 @@ Slice::Preprocessor::checkInputFile() ifstream test(_fileName.c_str()); if(!test) { - cerr << _path << ": can't open `" << _fileName << "' for reading" << endl; + cerr << _path << ": cannot open `" << _fileName << "' for reading" << endl; return false; } test.close(); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index a577c67541f..c593e3dcd21 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -7,12 +7,14 @@ // // ********************************************************************** +#include #include #include #include #include #include #include +#include #include #include @@ -34,8 +36,8 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2) return deprecateSymbol; } -Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension, - const string& sourceExtension, const vector& extraHeaders, const string& include, +Slice::Gen::Gen(const string& base, const string& headerExtension, const string& sourceExtension, + const vector& extraHeaders, const string& include, const vector& includePaths, const string& dllExport, const string& dir, bool imp, bool checksum, bool stream, bool ice) : _base(base), @@ -74,28 +76,34 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte struct stat st; if(stat(fileImplH.c_str(), &st) == 0) { - cerr << name << ": `" << fileImplH << "' already exists - will not overwrite" << endl; - return; + ostringstream os; + os << fileImplH << "' already exists - will not overwrite"; + throw FileException(__FILE__, __LINE__, os.str()); } if(stat(fileImplC.c_str(), &st) == 0) { - cerr << name << ": `" << fileImplC << "' already exists - will not overwrite" << endl; - return; + ostringstream os; + os << fileImplC << "' already exists - will not overwrite"; + throw FileException(__FILE__, __LINE__, os.str()); } implH.open(fileImplH.c_str()); if(!implH) { - cerr << name << ": can't open `" << fileImplH << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileImplH << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileImplH); implC.open(fileImplC.c_str()); if(!implC) { - cerr << name << ": can't open `" << fileImplC << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileImplC << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileImplC); string s = fileImplH; if(_include.size()) @@ -119,16 +127,20 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte H.open(fileH.c_str()); if(!H) { - cerr << name << ": can't open `" << fileH << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileH << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileH); C.open(fileC.c_str()); if(!C) { - cerr << name << ": can't open `" << fileC << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << fileC << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(fileC); printHeader(H); printHeader(C); @@ -158,20 +170,6 @@ Slice::Gen::~Gen() } } -bool -Slice::Gen::operator!() const -{ - if(!H || !C) - { - return true; - } - if(_impl && (!implH || !implC)) - { - return true; - } - return false; -} - void Slice::Gen::generate(const UnitPtr& p) { diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index c91b3ed34c7..e3c1c9afc01 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -21,7 +21,6 @@ class Gen : private ::IceUtil::noncopyable public: Gen(const std::string&, - const std::string&, const std::string&, const std::string&, const std::vector&, @@ -35,8 +34,6 @@ public: bool); ~Gen(); - bool operator!() const; // Returns true if there was a constructor error - void generate(const UnitPtr&); void closeOutput(); diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 0f053917b0b..4ca202872c7 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include using namespace std; @@ -216,14 +217,21 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include, - includePaths, dllExport, output, impl, checksum, stream, ice); - if(!gen) + try { + Gen gen(icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include, + includePaths, dllExport, output, impl, checksum, stream, ice); + gen.generate(u); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - gen.generate(u); } u->destroy(); @@ -235,6 +243,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index def7ed38beb..633ba2d7ac9 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace std; using namespace Slice; @@ -1053,7 +1054,7 @@ Slice::CsVisitor::writeValue(const TypePtr& type) } -Slice::Gen::Gen(const string& name, const string& base, const vector& includePaths, const string& dir, +Slice::Gen::Gen(const string& base, const vector& includePaths, const string& dir, bool impl, bool implTie, bool stream) : _includePaths(includePaths), _stream(stream) @@ -1076,9 +1077,11 @@ Slice::Gen::Gen(const string& name, const string& base, const vector& in _out.open(file.c_str()); if(!_out) { - cerr << name << ": can't open `" << file << "' for writing" << endl; - return; + ostringstream os; + os << "cannot open `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(file); printHeader(); _out << nl << "// Generated from file `" << fileBase << ".ice'"; @@ -1105,16 +1108,20 @@ Slice::Gen::Gen(const string& name, const string& base, const vector& in struct stat st; if(stat(fileImpl.c_str(), &st) == 0) { - cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl; - return; + ostringstream os; + os << fileImpl << "' already exists - will not overwrite"; + throw FileException(__FILE__, __LINE__, os.str()); } _impl.open(fileImpl.c_str()); if(!_impl) { - cerr << name << ": can't open `" << fileImpl << "' for writing" << endl; - return; + ostringstream os; + os << ": cannot open `" << fileImpl << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + + FileTracker::instance()->addFile(fileImpl); } } @@ -1130,16 +1137,9 @@ Slice::Gen::~Gen() } } -bool -Slice::Gen::operator!() const -{ - return !_out; -} - void Slice::Gen::generate(const UnitPtr& p) { - CsGenerator::validateMetaData(p); UnitVisitor unitVisitor(_out, _stream); diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index 265e1ab910d..dc9d655570e 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -47,7 +47,6 @@ class Gen : private ::IceUtil::noncopyable public: Gen(const std::string&, - const std::string&, const std::vector&, const std::string&, bool, @@ -55,8 +54,6 @@ public: bool); ~Gen(); - bool operator!() const; // Returns true if there was a constructor error - void generate(const UnitPtr&); void generateTie(const UnitPtr&); void generateImpl(const UnitPtr&); diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 2ed3177a683..abdc24c23db 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include using namespace std; @@ -164,7 +165,10 @@ main(int argc, char* argv[]) if(depend) { Preprocessor icecpp(argv[0], *i, cppArgs); - icecpp.printMakefileDependencies(Preprocessor::CSharp, includePaths); + if(!icecpp.printMakefileDependencies(Preprocessor::CSharp, includePaths)) + { + return EXIT_FAILURE; + } } else { @@ -207,28 +211,35 @@ main(int argc, char* argv[]) } else { - Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream); - if(!gen) - { - p->destroy(); - return EXIT_FAILURE; - } - gen.generate(p); - if(tie) + try { - gen.generateTie(p); + Gen gen(icecpp.getBaseName(), includePaths, output, impl, implTie, stream); + gen.generate(p); + if(tie) + { + gen.generateTie(p); + } + if(impl) + { + gen.generateImpl(p); + } + if(implTie) + { + gen.generateImplTie(p); + } + if(checksum) + { + gen.generateChecksums(p); + } } - if(impl) + catch(const Slice::FileException& ex) { - gen.generateImpl(p); - } - if(implTie) - { - gen.generateImplTie(p); - } - if(checksum) - { - gen.generateChecksums(p); + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); + p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; } } @@ -241,6 +252,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp index d40b9e1ee75..322ca9a1147 100644 --- a/cpp/src/slice2docbook/Gen.cpp +++ b/cpp/src/slice2docbook/Gen.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -21,8 +22,7 @@ using namespace Slice; using namespace IceUtil; using namespace IceUtilInternal; -Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool chapter, - bool noIndex, bool sortFields) : +Slice::Gen::Gen(const string& file, bool standAlone, bool chapter, bool noIndex, bool sortFields) : _standAlone(standAlone), _noIndex(noIndex), _sortFields(sortFields) @@ -39,8 +39,9 @@ Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool ch O.open(file.c_str()); if(!O) { - cerr << name << ": can't open `" << file << "' for writing: " << strerror(errno) << endl; - return; + ostringstream os; + os << "cannot open `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } } @@ -48,12 +49,6 @@ Slice::Gen::~Gen() { } -bool -Slice::Gen::operator!() const -{ - return !O; -} - void Slice::Gen::generate(const UnitPtr& p) { diff --git a/cpp/src/slice2docbook/Gen.h b/cpp/src/slice2docbook/Gen.h index 55222938370..97cbe3e1274 100644 --- a/cpp/src/slice2docbook/Gen.h +++ b/cpp/src/slice2docbook/Gen.h @@ -21,11 +21,9 @@ class Gen : private ::IceUtil::noncopyable, public ParserVisitor { public: - Gen(const std::string&, const std::string&, bool, bool, bool, bool); + Gen(const std::string&, bool, bool, bool, bool); virtual ~Gen(); - bool operator!() const; // Returns true if there was a constructor error - void generate(const UnitPtr&); void closeOutput(); diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 9e7add9b40c..25bd52137ac 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include using namespace std; @@ -210,13 +211,20 @@ main(int argc, char* argv[]) if(status == EXIT_SUCCESS && !preprocess) { - Gen gen(argv[0], docbook, standAlone, chapter, noIndex, sortFields); - if(!gen) + try { + Gen gen(docbook, standAlone, chapter, noIndex, sortFields); + gen.generate(p); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - gen.generate(p); } p->destroy(); @@ -226,6 +234,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 16e95c109eb..84f98ac7c27 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -219,25 +220,25 @@ usage(const char* n) // Note: --case-sensitive is intentionally not shown here! } -bool -checkIdentifier(string n, string t, string s) +void +checkIdentifier(string t, string s) { if(s.empty() || (!isalpha(static_cast(s[0])) && s[0] != '_')) { - cerr << n << ": `" << t << "' is not a valid type name" << endl; - return false; + ostringstream os; + os << t << "' is not a valid type name"; + throw os.str(); } for(unsigned int i = 1; i < s.size(); ++i) { if(!isalnum(static_cast(s[i])) && s[i] != '_') { - cerr << n << ": `" << t << "' is not a valid type name" << endl; - return false; + ostringstream os; + os << t << "' is not a valid type name"; + throw os.str(); } } - - return true; } void @@ -924,9 +925,8 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di } } - -bool -writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, const string& dllExport) +void +writeDict(const string& n, const UnitPtr& u, const Dict& dict, Output& H, Output& C, const string& dllExport) { string absolute = dict.name; if(absolute.find("::") == 0) @@ -941,32 +941,28 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c string s = name.substr(0, pos); name.erase(0, pos + 2); - if(!checkIdentifier(n, absolute, s)) - { - return false; - } + checkIdentifier(absolute, s); scope.push_back(s); } - if(!checkIdentifier(n, absolute, name)) - { - return false; - } + checkIdentifier(absolute, name); TypeList keyTypes = u->lookupType(dict.key, false); if(keyTypes.empty()) { - cerr << n << ": `" << dict.key << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.key << "' is not a valid type"; + throw os.str(); } TypePtr keyType = keyTypes.front(); TypeList valueTypes = u->lookupType(dict.value, false); if(valueTypes.empty()) { - cerr << n << ": `" << dict.value << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid type"; + throw os.str(); } TypePtr valueType = valueTypes.front(); @@ -1002,19 +998,21 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c { if(dict.indices.size() > 1) { - cerr << n << ": bad index for dictionary `" << dict.name << "'" << endl; - return false; + ostringstream os; + os << "bad index for dictionary `" << dict.name << "'"; + throw os.str(); } bool containsSequence = false; if(!Dictionary::legalKeyType(valueType, containsSequence)) { - cerr << n << ": `" << dict.value << "' is not a valid index type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid index type"; + throw os.str(); } if(containsSequence) { - cerr << n << ": warning: use of sequences in dictionary keys has been deprecated" << endl; + cerr << n << ": warning: use of sequences in dictionary keys has been deprecated"; } @@ -1028,8 +1026,9 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c if(builtInType == 0 || builtInType->kind() != Builtin::KindString) { - cerr << n << ": VALUE is a `" << dict.value << "', not a string" << endl; - return false; + ostringstream os; + os << "VALUE is a `" << dict.value << "', not a string"; + throw os.str(); } } IndexType iType; @@ -1052,8 +1051,9 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c StructPtr structDecl = StructPtr::dynamicCast(valueType); if(structDecl == 0) { - cerr << n << ": `" << dict.value << "' is neither a class nor a struct." << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is neither a class nor a struct."; + throw os.str(); } dataMembers = structDecl->dataMembers(); } @@ -1072,9 +1072,10 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c if(dataMember == 0) { - cerr << n << ": The value of `" << dict.name - << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "The value of `" << dict.name + << "' has no data member named `" << index.member << "'"; + throw os.str(); } TypePtr dataMemberType = dataMember->type(); @@ -1082,12 +1083,13 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c bool containsSequence = false; if(!Dictionary::legalKeyType(dataMemberType, containsSequence)) { - cerr << n << ": `" << index.member << "' cannot be used as an index" << endl; - return false; + ostringstream os; + os << "`" << index.member << "' cannot be used as an index"; + throw os.str(); } if(containsSequence) { - cerr << n << ": warning: use of sequences in dictionary keys has been deprecated" << endl; + cerr << n << ": warning: use of sequences in dictionary keys has been deprecated"; } @@ -1099,8 +1101,9 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << n << ": `" << index.member << "' is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "' is not a string "; + throw os.str(); } } IndexType iType; @@ -1128,11 +1131,8 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c writeDictWithIndicesC(name, absolute, dict, indexTypes, keyType, dict.keyMetaData, valueType, dict.valueMetaData, C); } - - return true; } - void writeIndexH(const string& memberTypeString, const string& name, Output& H, const string& dllExport) { @@ -1251,8 +1251,8 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member C << eb; } -bool -writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C, const string& dllExport) +void +writeIndex(const string& n, const UnitPtr& u, const Index& index, Output& H, Output& C, const string& dllExport) { string absolute = index.name; if(absolute.find("::") == 0) @@ -1267,32 +1267,28 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C string s = name.substr(0, pos); name.erase(0, pos + 2); - if(!checkIdentifier(n, absolute, s)) - { - return false; - } + checkIdentifier(absolute, s); scope.push_back(s); } - if(!checkIdentifier(n, absolute, name)) - { - return false; - } + checkIdentifier(absolute, name); TypeList types = u->lookupType(index.type, false); if(types.empty()) { - cerr << n << ": `" << index.type << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a valid type"; + throw os.str(); } TypePtr type = types.front(); ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type); if(classDecl == 0) { - cerr << n << ": `" << index.type << "' is not a class" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a class"; + throw os.str(); } DataMemberList dataMembers = classDecl->definition()->allDataMembers(); @@ -1312,8 +1308,9 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C if(dataMember == 0) { - cerr << n << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' has no data member named `" << index.member << "'"; + throw os.str(); } if(index.caseSensitive == false) @@ -1324,8 +1321,9 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type()); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << n << ": `" << index.member << "'is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "'is not a string"; + throw os.str(); } } @@ -1346,7 +1344,140 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C } writeIndexC(type, dataMember->type(), index.member, index.caseSensitive, absolute, name, C); - return true; +} + +void +gen(const string& name, const UnitPtr& u, const vector& includePaths, const vector& extraHeaders, + const vector& dicts, const vector& indices, const string& include, const string& headerExtension, + const string& sourceExtension, string dllExport, const StringList& includes, const vector& args, + const string& output) +{ + string fileH = args[0]; + fileH += "." + headerExtension; + string includeH = fileH; + string fileC = args[0]; + fileC += "." + sourceExtension; + + if(!output.empty()) + { + fileH = output + '/' + fileH; + fileC = output + '/' + fileC; + } + + u->mergeModules(); + u->sort(); + + IceUtilInternal::Output H; + H.open(fileH.c_str()); + if(!H) + { + ostringstream os; + os << "cannot open `" << fileH << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + + FileTracker::instance()->addFile(fileH); + + printHeader(H); + printFreezeTypes(H, dicts, indices); + + IceUtilInternal::Output CPP; + CPP.open(fileC.c_str()); + if(!CPP) + { + ostringstream os; + os << "cannot open `" << fileC << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(fileC); + + printHeader(CPP); + printFreezeTypes(CPP, dicts, indices); + + for(vector::const_iterator i = extraHeaders.begin(); i != extraHeaders.end(); ++i) + { + string hdr = *i; + string guard; + string::size_type pos = hdr.rfind(','); + if(pos != string::npos) + { + hdr = i->substr(0, pos); + guard = i->substr(pos + 1); + } + if(!guard.empty()) + { + CPP << "\n#ifndef " << guard; + CPP << "\n#define " << guard; + } + CPP << "\n#include <"; + if(!include.empty()) + { + CPP << include << '/'; + } + CPP << hdr << '>'; + if(!guard.empty()) + { + CPP << "\n#endif"; + } + } + + string s = fileH; + transform(s.begin(), s.end(), s.begin(), ToIfdef()); + H << "\n#ifndef __" << s << "__"; + H << "\n#define __" << s << "__"; + H << '\n'; + + if(dicts.size() > 0) + { + H << "\n#include "; + } + + if(indices.size() > 0) + { + H << "\n#include "; + } + + { + for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p) + { + H << "\n#include <" << changeInclude(*p, includePaths) << "." + headerExtension + ">"; + } + } + + CPP << "\n#include "; + CPP << "\n#include <"; + if(include.size()) + { + CPP << include << '/'; + } + CPP << includeH << '>'; + + printVersionCheck(H); + printVersionCheck(CPP); + + printDllExportStuff(H, dllExport); + if(dllExport.size()) + { + dllExport += " "; + } + + { + for(vector::const_iterator p = dicts.begin(); p != dicts.end(); ++p) + { + writeDict(name, u, *p, H, CPP, dllExport); + } + + for(vector::const_iterator q = indices.begin(); q != indices.end(); ++q) + { + writeIndex(name, u, *q, H, CPP, dllExport); + } + } + + H << "\n\n#endif\n"; + CPP << '\n'; + + H.close(); + CPP.close(); } int @@ -1420,6 +1551,14 @@ main(int argc, char* argv[]) cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i)); } + // Convert include paths to full paths. + { + for(vector::iterator p = includePaths.begin(); p != includePaths.end(); ++p) + { + *p = fullPath(*p); + } + } + bool preprocess= opts.isSet("E"); string include = opts.optArg("include-dir"); @@ -1775,17 +1914,6 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - string fileH = args[0]; - fileH += "." + headerExtension; - string includeH = fileH; - string fileC = args[0]; - fileC += "." + sourceExtension; - if(!output.empty()) - { - fileH = output + '/' + fileH; - fileC = output + '/' + fileC; - } - UnitPtr u = Unit::createUnit(true, false, ice, caseSensitive); StringList includes; @@ -1849,153 +1977,39 @@ main(int argc, char* argv[]) } } + if(status == EXIT_SUCCESS && !preprocess) { - u->mergeModules(); - u->sort(); - + try { - for(vector::iterator p = includePaths.begin(); p != includePaths.end(); ++p) - { - *p = fullPath(*p); - } + gen(argv[0], u, includePaths, extraHeaders, dicts, indices, include, headerExtension, + sourceExtension, dllExport, includes, args, output); } - - IceUtilInternal::Output H; - H.open(fileH.c_str()); - if(!H) + catch(const string& ex) { - cerr << argv[0] << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl; + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex << endl; return EXIT_FAILURE; } - printHeader(H); - printFreezeTypes(H, dicts, indices); - - IceUtilInternal::Output CPP; - CPP.open(fileC.c_str()); - if(!CPP) + catch(const Slice::FileException& ex) { - cerr << argv[0] << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl; + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - printHeader(CPP); - printFreezeTypes(CPP, dicts, indices); - - for(vector::const_iterator i = extraHeaders.begin(); i != extraHeaders.end(); ++i) - { - string hdr = *i; - string guard; - string::size_type pos = hdr.rfind(','); - if(pos != string::npos) - { - hdr = i->substr(0, pos); - guard = i->substr(pos + 1); - } - if(!guard.empty()) - { - CPP << "\n#ifndef " << guard; - CPP << "\n#define " << guard; - } - CPP << "\n#include <"; - if(!include.empty()) - { - CPP << include << '/'; - } - CPP << hdr << '>'; - if(!guard.empty()) - { - CPP << "\n#endif"; - } - } - - string s = fileH; - transform(s.begin(), s.end(), s.begin(), ToIfdef()); - H << "\n#ifndef __" << s << "__"; - H << "\n#define __" << s << "__"; - H << '\n'; - - if(dicts.size() > 0) - { - H << "\n#include "; - } - - if(indices.size() > 0) - { - H << "\n#include "; - } - - + catch(...) { - for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p) - { - H << "\n#include <" << changeInclude(*p, includePaths) << "." + headerExtension + ">"; - } - } - - CPP << "\n#include "; - CPP << "\n#include <"; - if(include.size()) - { - CPP << include << '/'; - } - CPP << includeH << '>'; - - printVersionCheck(H); - printVersionCheck(CPP); - - printDllExportStuff(H, dllExport); - if(dllExport.size()) - { - dllExport += " "; - } - - { - for(vector::const_iterator p = dicts.begin(); p != dicts.end(); ++p) - { - try - { - if(!writeDict(argv[0], u, *p, H, CPP, dllExport)) - { - u->destroy(); - return EXIT_FAILURE; - } - } - catch(...) - { - cerr << argv[0] << ": unknown exception" << endl; - u->destroy(); - return EXIT_FAILURE; - } - } - - - for(vector::const_iterator q = indices.begin(); q != indices.end(); ++q) - { - try - { - if(!writeIndex(argv[0], u, *q, H, CPP, dllExport)) - { - u->destroy(); - return EXIT_FAILURE; - } - } - catch(...) - { - cerr << argv[0] << ": unknown exception" << endl; - u->destroy(); - return EXIT_FAILURE; - } - } - + cerr << argv[0] << ": unknown exception" << endl; + FileTracker::instance()->cleanup(); + u->destroy(); + return EXIT_FAILURE; } - - H << "\n\n#endif\n"; - CPP << '\n'; - - H.close(); - CPP.close(); } u->destroy(); @@ -2005,10 +2019,10 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } - return status; } diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 9bae291e172..2b89feb5cfc 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #ifdef __BCPLUSPLUS__ @@ -73,15 +74,15 @@ public: FreezeGenerator(const string&, const string&); virtual ~FreezeGenerator(); - bool generate(UnitPtr&, const Dict&); + void generate(UnitPtr&, const Dict&); - bool generate(UnitPtr&, const Index&); + void generate(UnitPtr&, const Index&); private: string varToObject(const TypePtr&, const string&); string objectToVar(const TypePtr&, const string&); - string _prog; + const string _prog; }; FreezeGenerator::FreezeGenerator(const string& prog, const string& dir) @@ -204,7 +205,7 @@ FreezeGenerator::objectToVar(const TypePtr& type, const string& param) return result; } -bool +void FreezeGenerator::generate(UnitPtr& u, const Dict& dict) { static const char* builtinTable[] = @@ -236,16 +237,18 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) TypeList keyTypes = u->lookupType(dict.key, false); if(keyTypes.empty()) { - cerr << _prog << ": `" << dict.key << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.key << "' is not a valid type" << endl; + throw os.str(); } TypePtr keyType = keyTypes.front(); TypeList valueTypes = u->lookupType(dict.value, false); if(valueTypes.empty()) { - cerr << _prog << ": `" << dict.value << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid type" << endl; + throw os.str(); } TypePtr valueType = valueTypes.front(); @@ -263,15 +266,17 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) { if(dict.indices.size() > 1) { - cerr << _prog << ": bad index for dictionary `" << dict.name << "'" << endl; - return false; + ostringstream os; + os << "bad index for dictionary `" << dict.name << "'" << endl; + throw os.str(); } bool containsSequence = false; if(!Dictionary::legalKeyType(valueType, containsSequence)) { - cerr << _prog << ": `" << dict.value << "' is not a valid index type" << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is not a valid index type" << endl; + throw os.str(); } if(containsSequence) { @@ -288,8 +293,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) if(builtInType == 0 || builtInType->kind() != Builtin::KindString) { - cerr << _prog << ": VALUE is a `" << dict.value << "', not a string " << endl; - return false; + ostringstream os; + os << "VALUE is a `" << dict.value << "', not a string " << endl; + throw os.str(); } } indexTypes.push_back(valueType); @@ -311,8 +317,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) StructPtr structDecl = StructPtr::dynamicCast(valueType); if(structDecl == 0) { - cerr << _prog << ": `" << dict.value << "' is neither a class nor a struct." << endl; - return false; + ostringstream os; + os << "`" << dict.value << "' is neither a class nor a struct." << endl; + throw os.str(); } dataMembers = structDecl->dataMembers(); } @@ -331,9 +338,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) if(dataMember == 0) { - cerr << _prog << ": The value of `" << dict.name - << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "The value of `" << dict.name + << "' has no data member named `" << index.member << "'" << endl; + throw os.str(); } TypePtr dataMemberType = dataMember->type(); @@ -341,8 +349,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) bool containsSequence = false; if(!Dictionary::legalKeyType(dataMemberType, containsSequence)) { - cerr << _prog << ": `" << index.member << "' cannot be used as an index" << endl; - return false; + ostringstream os; + os << "`" << index.member << "' cannot be used as an index" << endl; + throw os.str(); } if(containsSequence) { @@ -357,8 +366,9 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << _prog << ": `" << index.member << "' is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "' is not a string " << endl; + throw os.str(); } } indexTypes.push_back(dataMemberType); @@ -934,13 +944,10 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict) out << eb; - close(); - - return true; } -bool +void FreezeGenerator::generate(UnitPtr& u, const Index& index) { string name; @@ -957,16 +964,18 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) TypeList types = u->lookupType(index.type, false); if(types.empty()) { - cerr << _prog << ": `" << index.type << "' is not a valid type" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a valid type" << endl; + throw os.str(); } TypePtr type = types.front(); ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type); if(classDecl == 0) { - cerr << _prog << ": `" << index.type << "' is not a class" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' is not a class" << endl; + throw os.str(); } DataMemberList dataMembers = classDecl->definition()->allDataMembers(); @@ -986,8 +995,9 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) if(dataMember == 0) { - cerr << _prog << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl; - return false; + ostringstream os; + os << "`" << index.type << "' has no data member named `" << index.member << "'" << endl; + throw os.str(); } if(index.caseSensitive == false) @@ -998,8 +1008,9 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type()); if(memberType == 0 || memberType->kind() != Builtin::KindString) { - cerr << _prog << ": `" << index.member << "'is not a string " << endl; - return false; + ostringstream os; + os << "`" << index.member << "'is not a string " << endl; + throw os.str(); } } @@ -1087,11 +1098,8 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index) out << eb; close(); - - return true; } - void usage(const char* n) { @@ -1501,20 +1509,29 @@ main(int argc, char* argv[]) { try { - if(!gen.generate(u, *p)) - { - u->destroy(); - return EXIT_FAILURE; - } + gen.generate(u, *p); + } + catch(const string& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + cerr << argv[0] << ": " << ex << endl; + return EXIT_FAILURE; } catch(const Slice::FileException& ex) { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); cerr << ex.reason() << endl; return EXIT_FAILURE; } catch(...) { + FileTracker::instance()->cleanup(); cerr << argv[0] << ": unknown exception" << endl; u->destroy(); return EXIT_FAILURE; @@ -1525,15 +1542,30 @@ main(int argc, char* argv[]) { try { - if(!gen.generate(u, *q)) - { - u->destroy(); - return EXIT_FAILURE; - } + gen.generate(u, *q); + } + catch(const string& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + cerr << argv[0] << ": " << ex << endl; + return EXIT_FAILURE; + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; } catch(...) { cerr << argv[0] << ": unknown exception" << endl; + FileTracker::instance()->cleanup(); u->destroy(); return EXIT_FAILURE; } @@ -1548,6 +1580,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp index d1a56b6ed32..f02ef04b75f 100644 --- a/cpp/src/slice2html/Gen.cpp +++ b/cpp/src/slice2html/Gen.cpp @@ -7,8 +7,13 @@ // // ********************************************************************** +#if defined(_MSC_VER) && _MSC_VER >= 1400 +# define _CRT_SECURE_NO_DEPRECATE 1 // C4996 '' was declared deprecated +#endif + #include #include +#include #include #include @@ -1244,9 +1249,11 @@ Slice::GeneratorBase::openStream(const string& path) _out.open(path.c_str()); if(!_out.isOpen()) { - string err = "cannot open `" + path + "' for writing"; - throw err; + ostringstream os; + os << "cannot open file `" << path << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(path); } void @@ -1447,18 +1454,28 @@ Slice::GeneratorBase::makeDir(const string& dir) int rc = stat(dir.c_str(), &st); if(rc == 0) { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create package directory `" << dir + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } return; } + #ifdef _WIN32 - rc = mkdir(dir.c_str()); + rc = _mkdir(dir.c_str()); #else rc = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); #endif if(rc != 0) { - string err = "cannot create directory `" + dir + "'"; - throw err; + ostringstream os; + os << "cannot create directory `" << dir << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addDirectory(dir); } string @@ -1467,8 +1484,9 @@ Slice::GeneratorBase::readFile(const string& file) ifstream in(file.c_str()); if(!in) { - string err = "cannot open `" + file + "' for reading"; - throw err; + ostringstream os; + os << "cannot open file `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } ostringstream result; @@ -1540,8 +1558,9 @@ Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2) ifstream in(file.c_str()); if(!in) { - string err = "cannot open `" + file + "' for reading"; - throw err; + ostringstream os; + os << "cannot open file `" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } string line; diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index f1e864b140f..068287ed632 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -238,13 +239,24 @@ main(int argc, char* argv[]) Slice::generate(p, output, header, footer, indexHeader, indexFooter, imageDir, logoURL, searchAction, indexCount, summaryCount); } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); + p->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; + } catch(const string& err) { + FileTracker::instance()->cleanup(); cerr << argv[0] << ": " << err << endl; status = EXIT_FAILURE; } catch(const char* err) { + FileTracker::instance()->cleanup(); cerr << argv[0] << ": " << err << endl; status = EXIT_FAILURE; } @@ -257,6 +269,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index b2fff573e39..bc555d403bb 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #ifdef __BCPLUSPLUS__ @@ -234,7 +235,7 @@ main(int argc, char* argv[]) p->destroy(); return EXIT_FAILURE; } - + if(parseStatus == EXIT_FAILURE) { status = EXIT_FAILURE; @@ -273,8 +274,11 @@ main(int argc, char* argv[]) } catch(const Slice::FileException& ex) { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); p->destroy(); - cerr << ex.reason() << endl; + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } } @@ -287,6 +291,9 @@ main(int argc, char* argv[]) if(_interrupted) { + // If the translator was interrupted, then cleanup any + // created files. + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } @@ -294,7 +301,18 @@ main(int argc, char* argv[]) if(!checksumClass.empty()) { - Gen::writeChecksumClass(checksumClass, output, checksums, java2); + try + { + Gen::writeChecksumClass(checksumClass, output, checksums, java2); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then + // cleanup any created files. + FileTracker::instance()->cleanup(); + cerr << argv[0] << ": " << ex.reason() << endl; + return EXIT_FAILURE; + } } return status; diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 660914e715c..4b522bf9a98 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -72,7 +73,7 @@ class PackageVisitor : public ParserVisitor { public: - PackageVisitor(const string&, const string&, const string&); + PackageVisitor(const string&, const string&); virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); @@ -84,15 +85,14 @@ private: static const char* _moduleTag; static const char* _submoduleTag; - bool createDirectory(const string&); + void createDirectory(const string&); - bool addModule(const string&, const string&); - bool addSubmodule(const string&, const string&); + void addModule(const string&, const string&); + void addSubmodule(const string&, const string&); - bool readInit(const string&, StringList&, StringList&); - bool writeInit(const string&, const StringList&, const StringList&); + void readInit(const string&, StringList&, StringList&); + void writeInit(const string&, const StringList&, const StringList&); - string _name; string _module; StringList _pathStack; }; @@ -100,8 +100,8 @@ private: const char* PackageVisitor::_moduleTag = "# Modules:"; const char* PackageVisitor::_submoduleTag = "# Submodules:"; -PackageVisitor::PackageVisitor(const string& name, const string& module, const string& dir) : - _name(name), _module(module) +PackageVisitor::PackageVisitor(const string& module, const string& dir) : + _module(module) { if(dir.empty()) { @@ -138,27 +138,18 @@ PackageVisitor::visitModuleStart(const ModulePtr& p) } for(vector::iterator q = v.begin(); q != v.end(); ++q) { - if(q != v.begin() && !addSubmodule(path, fixIdent(*q))) + if(q != v.begin()) { - return false; + addSubmodule(path, fixIdent(*q)); } path += "/" + *q; - if(!createDirectory(path)) - { - return false; - } + createDirectory(path); - if(!addModule(path, _module)) - { - return false; - } + addModule(path, _module); } - if(!addSubmodule(path, name)) - { - return false; - } + addSubmodule(path, name); } path += "/" + name; @@ -171,26 +162,20 @@ PackageVisitor::visitModuleStart(const ModulePtr& p) string parentPath = _pathStack.front(); _pathStack.push_front(path); - if(!createDirectory(path)) - { - return false; - } + createDirectory(path); // // If necessary, add this module to the set of imported modules in __init__.py. // - if(!addModule(path, _module)) - { - return false; - } + addModule(path, _module); // // If this is a submodule, then modify the parent's __init__.py to import us. // ModulePtr mod = ModulePtr::dynamicCast(p->container()); - if(mod && !addSubmodule(parentPath, name)) + if(mod) { - return false; + addSubmodule(parentPath, name); } return true; @@ -203,75 +188,72 @@ PackageVisitor::visitModuleEnd(const ModulePtr& p) _pathStack.pop_front(); } -bool +void PackageVisitor::createDirectory(const string& dir) { struct stat st; int result; result = stat(dir.c_str(), &st); - if(result != 0) + if(result == 0) { + if(!(st.st_mode & S_IFDIR)) + { + ostringstream os; + os << "failed to create package directory `" << dir + << "': file already exists and is not a directory"; + throw FileException(__FILE__, __LINE__, os.str()); + } + return; + } #ifdef _WIN32 - result = _mkdir(dir.c_str()); + result = _mkdir(dir.c_str()); #else - result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); + result = mkdir(dir.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); #endif - if(result != 0) - { - cerr << _name << ": unable to create `" << dir << "': " << strerror(errno) << endl; - return false; - } + if(result != 0) + { + ostringstream os; + os << "cannot create directory `" << dir << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } - return true; + FileTracker::instance()->addDirectory(dir); } -bool +void PackageVisitor::addModule(const string& dir, const string& name) { // // Add a module to the set of imported modules in __init__.py. // StringList modules, submodules; - if(readInit(dir, modules, submodules)) + readInit(dir, modules, submodules); + StringList::iterator p = find(modules.begin(), modules.end(), name); + if(p == modules.end()) { - StringList::iterator p = find(modules.begin(), modules.end(), name); - if(p == modules.end()) - { - modules.push_back(name); - return writeInit(dir, modules, submodules); - } - - return true; + modules.push_back(name); + writeInit(dir, modules, submodules); } - - return false; } -bool +void PackageVisitor::addSubmodule(const string& dir, const string& name) { // // Add a submodule to the set of imported modules in __init__.py. // StringList modules, submodules; - if(readInit(dir, modules, submodules)) + readInit(dir, modules, submodules); + StringList::iterator p = find(submodules.begin(), submodules.end(), name); + if(p == submodules.end()) { - StringList::iterator p = find(submodules.begin(), submodules.end(), name); - if(p == submodules.end()) - { - submodules.push_back(name); - return writeInit(dir, modules, submodules); - } - - return true; + submodules.push_back(name); + writeInit(dir, modules, submodules); } - - return false; } -bool +void PackageVisitor::readInit(const string& dir, StringList& modules, StringList& submodules) { string initPath = dir + "/__init__.py"; @@ -282,8 +264,9 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub ifstream in(initPath.c_str()); if(!in) { - cerr << _name << ": unable to open `" << initPath << "': " << strerror(errno) << endl; - return false; + ostringstream os; + os << "cannot open file `" << initPath << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } ReadState state = PreModules; @@ -316,8 +299,9 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(s.size() < 8) { - cerr << _name << ": invalid line `" << s << "' in `" << initPath << "'" << endl; - return false; + ostringstream os; + os << "invalid line `" << s << "' in `" << initPath << "'"; + throw os.str(); } string name = s.substr(7); @@ -334,15 +318,14 @@ PackageVisitor::readInit(const string& dir, StringList& modules, StringList& sub if(state != InSubmodules) { - cerr << _name << ": invalid format in `" << initPath << "'" << endl; - return false; + ostringstream os; + os << "invalid format in `" << initPath << "'" << endl; + throw os.str(); } } - - return true; } -bool +void PackageVisitor::writeInit(const string& dir, const StringList& modules, const StringList& submodules) { string initPath = dir + "/__init__.py"; @@ -350,8 +333,11 @@ PackageVisitor::writeInit(const string& dir, const StringList& modules, const St ofstream os(initPath.c_str()); if(!os) { - return false; + ostringstream os; + os << "cannot open file `" << initPath << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); } + FileTracker::instance()->addFile(initPath); StringList::const_iterator p; @@ -369,8 +355,6 @@ PackageVisitor::writeInit(const string& dir, const StringList& modules, const St { os << "import " << *p << endl; } - - return true; } void @@ -490,6 +474,7 @@ main(int argc, char* argv[]) IceUtil::CtrlCHandler ctrlCHandler; ctrlCHandler.setCallback(interruptedCallback); + for(i = args.begin(); i != args.end(); ++i) { Preprocessor icecpp(argv[0], *i, cppArgs); @@ -551,34 +536,52 @@ main(int argc, char* argv[]) file = output + '/' + file; } - IceUtilInternal::Output out; - out.open(file.c_str()); - if(!out) + try + { + IceUtilInternal::Output out; + out.open(file.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open`" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(file); + + printHeader(out); + out << "\n# Generated from file `" << base << ".ice'\n"; + + // + // Generate the Python mapping. + // + generate(u, all, checksum, includePaths, out); + + out.close(); + + // + // Create or update the Python package hierarchy. + // + if(!noPackage) + { + PackageVisitor visitor(prefix + base + "_ice", output); + u->visit(&visitor, false); + } + } + catch(const Slice::FileException& ex) { - cerr << argv[0] << ": can't open `" << file << "' for writing" << endl; + // If a file could not be created, then cleanup any + // created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - - printHeader(out); - out << "\n# Generated from file `" << base << ".ice'\n"; - - // - // Generate the Python mapping. - // - generate(u, all, checksum, includePaths, out); - - out.close(); - - // - // Create or update the Python package hierarchy. - // - if(!noPackage) + catch(const string& err) { - PackageVisitor visitor(argv[0], prefix + base + "_ice", output); - u->visit(&visitor, false); + FileTracker::instance()->cleanup(); + cerr << argv[0] << ": " << err << endl; + status = EXIT_FAILURE; } - } u->destroy(); @@ -589,6 +592,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 0d6856a2123..092c16f8a35 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -207,24 +208,37 @@ main(int argc, char* argv[]) file = output + '/' + file; } - IceUtilInternal::Output out; - out.open(file.c_str()); - if(!out) + try { - cerr << argv[0] << ": can't open `" << file << "' for writing" << endl; + IceUtilInternal::Output out; + out.open(file.c_str()); + if(!out) + { + ostringstream os; + os << "cannot open`" << file << "': " << strerror(errno); + throw FileException(__FILE__, __LINE__, os.str()); + } + FileTracker::instance()->addFile(file); + + printHeader(out); + out << "\n# Generated from file `" << base << ".ice'\n"; + + // + // Generate the Ruby mapping. + // + generate(u, all, checksum, includePaths, out); + + out.close(); + } + catch(const Slice::FileException& ex) + { + // If a file could not be created, then cleanup + // any created files. + FileTracker::instance()->cleanup(); u->destroy(); + cerr << argv[0] << ": " << ex.reason() << endl; return EXIT_FAILURE; } - - printHeader(out); - out << "\n# Generated from file `" << base << ".ice'\n"; - - // - // Generate the Ruby mapping. - // - generate(u, all, checksum, includePaths, out); - - out.close(); } u->destroy(); @@ -235,6 +249,7 @@ main(int argc, char* argv[]) if(_interrupted) { + FileTracker::instance()->cleanup(); return EXIT_FAILURE; } } -- cgit v1.2.3 From f8a2a5c47bcc31192d618de6833e9663c9feb5ac Mon Sep 17 00:00:00 2001 From: Matthew Newhook Date: Wed, 14 Jan 2009 09:59:23 -0330 Subject: http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=3517 ; translator stdout/stderr. --- CHANGES | 2 ++ cpp/src/Slice/CsUtil.cpp | 8 ++++---- cpp/src/Slice/JavaUtil.cpp | 12 ++++++------ cpp/src/Slice/Parser.cpp | 14 +++++++------- cpp/src/Slice/PythonUtil.cpp | 6 +++--- cpp/src/slice2cpp/Gen.cpp | 8 ++++---- cpp/src/slice2cpp/Main.cpp | 2 +- cpp/src/slice2cs/Main.cpp | 2 +- cpp/src/slice2docbook/Main.cpp | 2 +- cpp/src/slice2freeze/Main.cpp | 2 +- cpp/src/slice2freezej/Main.cpp | 2 +- cpp/src/slice2html/Main.cpp | 2 +- cpp/src/slice2java/Main.cpp | 2 +- cpp/src/slice2py/Main.cpp | 2 +- cpp/src/slice2rb/Main.cpp | 2 +- 15 files changed, 35 insertions(+), 33 deletions(-) (limited to 'cpp/src') diff --git a/CHANGES b/CHANGES index 4b2dc57d40a..3d06162dab6 100644 --- a/CHANGES +++ b/CHANGES @@ -35,6 +35,8 @@ General Changes print an error message if the retry failed and if Ice.RetryIntervals was configured with non-zero time intervals. +- All error output from the slice compilers now goes to stderr. + C++ Changes =========== diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index a5d5c78a7e4..ae8c6e667cc 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -1528,7 +1528,7 @@ Slice::CsGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) static const string attributePrefix = "cs:attribute:"; if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size()) { - cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } } _history.insert(s); @@ -1595,7 +1595,7 @@ Slice::CsGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); if(!cl->isLocal()) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: metdata directive `UserException' applies only to local operations " << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() << "' is not local" << endl; @@ -1720,7 +1720,7 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) } } } - cout << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; + cerr << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; } _history.insert(s); } @@ -1734,7 +1734,7 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont) { continue; } - cout << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; + cerr << file << ":" << cont->line() << ": warning: " << msg << " `" << s << "'" << endl; } _history.insert(s); } diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp index 7c73227bc55..b67f36055a4 100644 --- a/cpp/src/Slice/JavaUtil.cpp +++ b/cpp/src/Slice/JavaUtil.cpp @@ -3426,7 +3426,7 @@ Slice::JavaGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p) if(!ok) { - cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } } _history.insert(s); @@ -3482,7 +3482,7 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) ClassDefPtr cl = ClassDefPtr::dynamicCast(p->container()); if(!cl->isLocal()) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: metadata directive `UserException' applies only to local operations " << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() << "' is not local" << endl; @@ -3498,7 +3498,7 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(q->find("java:type:", 0) == 0) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: invalid metadata for operation" << endl; break; } @@ -3597,7 +3597,7 @@ Slice::JavaGenerator::MetaDataVisitor::getMetaData(const ContainedPtr& cont) continue; } - cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl; + cerr << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl; } _history.insert(s); @@ -3630,7 +3630,7 @@ Slice::JavaGenerator::MetaDataVisitor::validateType(const SyntaxTreeBasePtr& p, assert(b); str = b->typeId(); } - cout << file << ":" << line << ": warning: invalid metadata for " << str << endl; + cerr << file << ":" << line << ": warning: invalid metadata for " << str << endl; } } } @@ -3660,7 +3660,7 @@ Slice::JavaGenerator::MetaDataVisitor::validateGetSet(const SyntaxTreeBasePtr& p assert(b); str = b->typeId(); } - cout << file << ":" << line << ": warning: invalid metadata for " << str << endl; + cerr << file << ":" << line << ": warning: invalid metadata for " << str << endl; } } } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 866a580373a..5d682503ec3 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -4714,7 +4714,7 @@ Slice::Operation::attributes() const } if(i == 2) { - cout << definitionContext()->filename() << ":" << line() + cerr << definitionContext()->filename() << ":" << line() << ": warning: invalid freeze metadata for operation" << endl; } else @@ -4736,7 +4736,7 @@ Slice::Operation::attributes() const { if(result != 0 && (i == int(Supports) || i == int(Never))) { - cout << definitionContext()->filename() << ":" << line() + cerr << definitionContext()->filename() << ":" << line() << ": warning: invalid freeze metadata for operation" << endl; } else @@ -4751,7 +4751,7 @@ Slice::Operation::attributes() const if(i == 4) { - cout << definitionContext()->filename() << ":" << line() + cerr << definitionContext()->filename() << ":" << line() << ": warning: invalid freeze metadata for operation" << endl; // @@ -5170,9 +5170,9 @@ Slice::Unit::error(const char* s) string file = currentFile(); if(!file.empty()) { - cout << file << ':' << _currentLine << ": "; + cerr << file << ':' << _currentLine << ": "; } - cout << s << endl; + cerr << s << endl; _errors++; } @@ -5188,9 +5188,9 @@ Slice::Unit::warning(const char* s) const string file = currentFile(); if(!file.empty()) { - cout << file << ':' << _currentLine << ": "; + cerr << file << ':' << _currentLine << ": "; } - cout << "warning: " << s << endl; + cerr << "warning: " << s << endl; } void diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index 648b7af94df..cb9e024717a 100644 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -2035,7 +2035,7 @@ Slice::Python::MetaDataVisitor::validateGlobal(const DefinitionContextPtr& dc) static const string packagePrefix = "python:package:"; if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size()) { - cout << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } } _history.insert(s); @@ -2067,7 +2067,7 @@ Slice::Python::MetaDataVisitor::validateSequence(const DefinitionContextPtr& dc, } } } - cout << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl; + cerr << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl; } } } @@ -2085,7 +2085,7 @@ Slice::Python::MetaDataVisitor::reject(const ContainedPtr& cont) { DefinitionContextPtr dc = cont->definitionContext(); assert(dc); - cout << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl; + cerr << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl; } } } diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index c593e3dcd21..0c1731b684f 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -5651,7 +5651,7 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p) { continue; } - cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; } _history.insert(s); } @@ -5722,7 +5722,7 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(!cl->isLocal()) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: metadata directive `UserException' applies only to local operations " << "but enclosing " << (cl->isInterface() ? "interface" : "class") << "`" << cl->name() << "' is not local" << endl; @@ -5741,7 +5741,7 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p) { if(q->find("cpp:type:", 0) == 0 || q->find("cpp:array", 0) == 0 || q->find("cpp:range", 0) == 0) { - cout << p->definitionContext()->filename() << ":" << p->line() + cerr << p->definitionContext()->filename() << ":" << p->line() << ": warning: invalid metadata for operation" << endl; break; } @@ -5834,7 +5834,7 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin continue; } - cout << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl; + cerr << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl; } _history.insert(s); } diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 4ca202872c7..7e2ff8b58b1 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -101,7 +101,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index abdc24c23db..595dfe75dc9 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -95,7 +95,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 25bd52137ac..b5616743174 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -92,7 +92,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 84f98ac7c27..cbffb460a3f 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -1523,7 +1523,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 2b89feb5cfc..2ab8c36f86f 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -1183,7 +1183,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index 068287ed632..dad5663fdba 100644 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -101,7 +101,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index bc555d403bb..7439180b8f2 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -101,7 +101,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 4b522bf9a98..7343ea9f812 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -420,7 +420,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 092c16f8a35..d5f21dc3037 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -102,7 +102,7 @@ main(int argc, char* argv[]) if(opts.isSet("version")) { - cout << ICE_STRING_VERSION << endl; + cerr << ICE_STRING_VERSION << endl; return EXIT_SUCCESS; } -- cgit v1.2.3 From 47b7978c8e1a1d5c916dd8da4773fa4627528bec Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Wed, 14 Jan 2009 11:07:30 -0330 Subject: Bug 3140 - Change encoding to en_us.utf8 to work around mcpp bug --- cpp/INSTALL.HP-UX | 2 +- cpp/INSTALL.LINUX | 2 +- cpp/INSTALL.MACOSX | 2 +- cpp/INSTALL.SOLARIS | 2 +- cpp/INSTALL.WINDOWS | 2 +- cpp/src/Slice/Preprocessor.cpp | 4 ++-- distribution/bin/makethirdpartiesmsi.py | 2 +- distribution/src/rpm/ice.spec | 2 +- distribution/src/rpm/mcpp-devel.spec | 11 +++++------ distribution/src/thirdparty/README | 35 --------------------------------- distribution/src/thirdparty/README.txt | 22 +++++---------------- 11 files changed, 19 insertions(+), 67 deletions(-) (limited to 'cpp/src') diff --git a/cpp/INSTALL.HP-UX b/cpp/INSTALL.HP-UX index 401d29cee99..f85d600ab37 100644 --- a/cpp/INSTALL.HP-UX +++ b/cpp/INSTALL.HP-UX @@ -35,7 +35,7 @@ Ice has dependencies on a number of third-party libraries: - expat 1.95.7 or 2.0.0 - OpenSSL 0.9.7 or later (OpenSSL 0.9.8 or later recommended) - bzip2 1.0.x -- mcpp 2.7 with patch +- mcpp 2.7.2 We recommend downloading the Ice third-party source archive from diff --git a/cpp/INSTALL.LINUX b/cpp/INSTALL.LINUX index 9cd820a66a2..defb1fb5a78 100644 --- a/cpp/INSTALL.LINUX +++ b/cpp/INSTALL.LINUX @@ -46,7 +46,7 @@ Ice has dependencies on a number of third-party libraries: - expat 1.95.7 or 2.0.1 - OpenSSL 0.9.7 or later (OpenSSL 0.9.8 or later recommended) - bzip2 1.0.x -- mcpp 2.7 with patch +- mcpp 2.7.2 Some of these packages may have been included in your Linux distribution. For those packages that are not installed or have an diff --git a/cpp/INSTALL.MACOSX b/cpp/INSTALL.MACOSX index 27de49b3a71..557c817ab01 100644 --- a/cpp/INSTALL.MACOSX +++ b/cpp/INSTALL.MACOSX @@ -26,7 +26,7 @@ Ice has dependencies on a number of third-party libraries: - expat 1.95.7 or 2.0.0 - OpenSSL 0.9.7 or later (OpenSSL 0.9.8 or later recommended) - bzip2 1.0.x -- mcpp 2.7 with patch +- mcpp 2.7.2 Some of these packages are included with your system. For those packages that are not installed or have an older version than what diff --git a/cpp/INSTALL.SOLARIS b/cpp/INSTALL.SOLARIS index 8f503fc0e4f..c19cff36000 100644 --- a/cpp/INSTALL.SOLARIS +++ b/cpp/INSTALL.SOLARIS @@ -42,7 +42,7 @@ Ice has dependencies on a number of third-party libraries: - expat 1.95.7 or 2.0.0 - OpenSSL 0.9.7 or later (OpenSSL 0.9.8 or later recommended) - bzip2 1.0.x -- mcpp 2.7 with patch +- mcpp 2.7.2 We recommend downloading the Ice third-party source archive from diff --git a/cpp/INSTALL.WINDOWS b/cpp/INSTALL.WINDOWS index 1812ea41bf0..4011bb917bb 100644 --- a/cpp/INSTALL.WINDOWS +++ b/cpp/INSTALL.WINDOWS @@ -157,7 +157,7 @@ Ice has dependencies on a number of third-party libraries: - expat 2.0 - OpenSSL 0.9.7 or later (OpenSSL 0.9.8 or later recommended) - bzip2 1.0 -- mcpp 2.7 with patch +- mcpp 2.7.2 You do not need to build these packages yourself, as ZeroC supplies a Windows installer for each supported compiler that contains release diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index dd1260f2fa0..6c226c2db72 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -126,7 +126,7 @@ Slice::Preprocessor::preprocess(bool keepComments) args.push_back("-C"); } args.push_back("-e"); - args.push_back("utf8"); + args.push_back("en_us.utf8"); args.push_back(_fileName); const char** argv = new const char*[args.size() + 1]; @@ -230,7 +230,7 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector args = _args; args.push_back("-M"); args.push_back("-e"); - args.push_back("utf8"); + args.push_back("en_us.utf8"); args.push_back(_fileName); const char** argv = new const char*[args.size() + 1]; diff --git a/distribution/bin/makethirdpartiesmsi.py b/distribution/bin/makethirdpartiesmsi.py index 48fe594c44d..e7dfebd1669 100755 --- a/distribution/bin/makethirdpartiesmsi.py +++ b/distribution/bin/makethirdpartiesmsi.py @@ -26,7 +26,7 @@ Bzip2Ver = '1.0.5' STLPortVer = '4.6.2' ExpatVer = '2.0.1' DBVer = '4.6.21' -MCPPVer = '2.7' +MCPPVer = '2.7.2' timeStampingURL = 'http://timestamp.verisign.com/scripts/timstamp.dll' diff --git a/distribution/src/rpm/ice.spec b/distribution/src/rpm/ice.spec index b9400ae6dee..993bc62c936 100644 --- a/distribution/src/rpm/ice.spec +++ b/distribution/src/rpm/ice.spec @@ -58,7 +58,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: openssl-devel >= 0.9.7a BuildRequires: db46-devel >= 4.6.21, db46-java >= 4.6.21 BuildRequires: jpackage-utils -BuildRequires: mcpp-devel >= 2.7 +BuildRequires: mcpp-devel >= 2.7.2 # # We also need a recent version of ant, %{_javadir}/jgoodies-forms-%{formsversion}.jar, diff --git a/distribution/src/rpm/mcpp-devel.spec b/distribution/src/rpm/mcpp-devel.spec index 0ad10ec8091..8f8811badb8 100644 --- a/distribution/src/rpm/mcpp-devel.spec +++ b/distribution/src/rpm/mcpp-devel.spec @@ -4,11 +4,9 @@ Summary: mcpp, a portable C/C++ preprocessor Name: mcpp-devel -Version: 2.7 +Version: 2.7.2 Release: 1ice%{?dist} -Source0: http://prdownloads.sourceforge.net/mcpp/mcpp-2.7.tar.gz -Patch1: mcpp-2.7.patch -Patch2: mcpp-2.7.patch2 +Source0: http://prdownloads.sourceforge.net/mcpp/mcpp-2.7.2.tar.gz URL: http://mcpp.sourceforge.net/ License: BSD Group: System Environment/Libraries @@ -40,8 +38,6 @@ It is probably number one C/C++ preprocessor now available in the world. %prep %setup -q -n mcpp-%{version} -%patch1 -p0 -%patch2 -p0 %build @@ -64,6 +60,9 @@ rm -rf ${RPM_BUILD_ROOT} %changelog +* Wed Jan 14 2009 Dwayne Boone +- mcpp 2.7.2 update + * Wed Apr 30 2008 Bernard Normier - mcpp 2.7 update diff --git a/distribution/src/thirdparty/README b/distribution/src/thirdparty/README index 59b2053dbb3..a6cb4475016 100644 --- a/distribution/src/thirdparty/README +++ b/distribution/src/thirdparty/README @@ -20,29 +20,6 @@ bzip2 http://sources.redhat.com/bzip2 mcpp http://mcpp.sourceforge.net -====================================================================== -Patches -====================================================================== - - -mcpp ----- - -The files mcpp-2.7.patch and mcpp-2.7.patch2 in this archive contain -several important fixes required by Ice. We expect that all these -fixes will be included in mcpp 2.7.1. - -After extracting the mcpp source distribution, change to the top-level -directory and apply the patches as shown below: - - $ cd mcpp-2.7 - $ patch -p0 < ../mcpp-2.7.patch - $ patch -p0 < ../mcpp-2.7.patch2 - -Follow the platform-specific instructions below for configuring and -building mcpp. - - ====================================================================== Instructions for Linux ====================================================================== @@ -66,9 +43,6 @@ support: mcpp ---- -If you have not already applied the patch for mcpp, please read the -"Patches" section above before continuing. - Ice requires the library version of mcpp, so configure mcpp as shown below: @@ -156,9 +130,6 @@ from source. mcpp ---- -If you have not already applied the patch for mcpp, please read the -"Patches" section above before continuing. - Ice requires the library version of mcpp, so configure mcpp as shown below: @@ -191,9 +162,6 @@ support: mcpp ---- -If you have not already applied the patch for mcpp, please read the -"Patches" section above before continuing. - Ice requires the library version of mcpp, so configure mcpp as shown below: @@ -253,9 +221,6 @@ installed in /usr/sfw. mcpp ---- -If you have not already applied the patch for mcpp, please read the -"Patches" section above before continuing. - Ice requires the library version of mcpp, so configure mcpp as shown below: diff --git a/distribution/src/thirdparty/README.txt b/distribution/src/thirdparty/README.txt index a1da455a847..88c8deba61e 100644 --- a/distribution/src/thirdparty/README.txt +++ b/distribution/src/thirdparty/README.txt @@ -54,19 +54,6 @@ top-level directory and apply the patch as shown below: > patch -p0 bzlib.h < ..\bzlib.patch -mcpp ----- - -The file mcpp-2.7.patch in this archive contains several important -fixes required by Ice. We expect that all these fixes will be -included in mcpp 2.7.1. - -After extracting the mcpp source distribution, change to the top-level -directory and apply the patch as shown below: - - > patch -p0 < mcpp-2.7.patch - - ====================================================================== Packages ====================================================================== @@ -147,20 +134,21 @@ This will build the release and debug versions of the bzip2 DLLs. mcpp ---- -If you have not already applied the patch for mcpp, please read the -"Patches" section above before continuing. - Follow these instructions for building mcpp: - Change to the mcpp src directory: - > cd mcpp-2.7\src + > cd mcpp-2.7.2\src - Apply the patch for noconfig.H appropriate for your compiler from the noconfig directory. For example, for VS2005 you would run: > patch -p0 < ..\noconfig\vc2005.dif + and for C++Builder 2007 you would run: + + > patch -p0 < ..\noconfig\bc59.dif + - Microsoft Visual C++: Build the mcpp release library: -- cgit v1.2.3 From 7da5b68416d63f8bb90a1f9d666574d339b6314c Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 14 Jan 2009 20:21:14 +0100 Subject: Fix 3652 - string.h need to be included to use strerror with gcc >= 4.3.2 --- cpp/src/slice2cpp/Gen.cpp | 2 ++ cpp/src/slice2cs/Gen.cpp | 1 + cpp/src/slice2html/Gen.cpp | 2 ++ cpp/src/slice2rb/Main.cpp | 2 ++ 4 files changed, 7 insertions(+) (limited to 'cpp/src') diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 0c1731b684f..d442b2a7586 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -17,7 +17,9 @@ #include #include + #include +#include using namespace std; using namespace Slice; diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index 633ba2d7ac9..b3c236cfa1a 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -22,6 +22,7 @@ #include #include #include +#include using namespace std; using namespace Slice; diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp index f02ef04b75f..65149c2581c 100644 --- a/cpp/src/slice2html/Gen.cpp +++ b/cpp/src/slice2html/Gen.cpp @@ -29,6 +29,8 @@ # include #endif +#include + using namespace std; using namespace Slice; using namespace IceUtil; diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index d5f21dc3037..2cdd6ec4982 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -28,6 +28,8 @@ #include #endif +#include + using namespace std; using namespace Slice; using namespace Slice::Ruby; -- cgit v1.2.3 From 0dca8d4a9d838264e866371cd4447acd7f81737f Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Wed, 14 Jan 2009 16:45:19 -0800 Subject: bug 3266 - fix IceSSL/C++ for custom contexts --- cpp/include/IceSSL/Plugin.h | 5 +- cpp/src/IceSSL/Instance.cpp | 534 ++++++++++++++++++++++---------------------- cpp/src/IceSSL/Instance.h | 1 + 3 files changed, 274 insertions(+), 266 deletions(-) (limited to 'cpp/src') diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h index 6834ad7d101..bd9c3e92580 100644 --- a/cpp/include/IceSSL/Plugin.h +++ b/cpp/include/IceSSL/Plugin.h @@ -457,8 +457,11 @@ public: // invoke initializePlugins on the PluginManager. // // When the application supplies its own OpenSSL context, the - // plug-in skips its normal property-based configuration. + // plug-in ignores configuration properties related to certificates, + // keys, and passwords. // + // Note that the plugin assumes ownership of the given context. + // virtual void setContext(SSL_CTX*) = 0; // diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp index 9c4875f6267..47f40cf1e64 100644 --- a/cpp/src/IceSSL/Instance.cpp +++ b/cpp/src/IceSSL/Instance.cpp @@ -128,6 +128,7 @@ passwordError() IceSSL::Instance::Instance(const CommunicatorPtr& communicator) : _logger(communicator->getLogger()), + _initialized(false), _ctx(0) { __setNoDelete(true); @@ -264,218 +265,96 @@ IceSSL::Instance::~Instance() void IceSSL::Instance::initialize() { - if(_ctx) + if(_initialized) { return; } - _ctx = SSL_CTX_new(SSLv23_method()); - if(!_ctx) - { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: unable to create SSL context:\n" + sslErrors(); - throw ex; - } - try { - // - // Store a pointer to ourself for use in OpenSSL callbacks. - // - SSL_CTX_set_ex_data(_ctx, 0, this); - - // - // This is necessary for successful interop with Java. Without it, a Java - // client would fail to reestablish a connection: the server gets the - // error "session id context uninitialized" and the client receives - // "SSLHandshakeException: Remote host closed connection during handshake". - // - SSL_CTX_set_session_cache_mode(_ctx, SSL_SESS_CACHE_OFF); - - PropertiesPtr properties = communicator()->getProperties(); const string propPrefix = "IceSSL."; - - // - // Check for a default directory. We look in this directory for - // files mentioned in the configuration. - // - { - _defaultDir = properties->getProperty(propPrefix + "DefaultDir"); - } - - // - // Select protocols. - // - { - StringSeq protocols = properties->getPropertyAsList(propPrefix + "Protocols"); - if(!protocols.empty()) - { - parseProtocols(protocols); - } - } + PropertiesPtr properties = communicator()->getProperties(); // // CheckCertName determines whether we compare the name in a peer's // certificate against its hostname. // - { - _checkCertName = properties->getPropertyAsIntWithDefault(propPrefix + "CheckCertName", 0) > 0; - } + _checkCertName = properties->getPropertyAsIntWithDefault(propPrefix + "CheckCertName", 0) > 0; // // VerifyDepthMax establishes the maximum length of a peer's certificate // chain, including the peer's certificate. A value of 0 means there is // no maximum. // - { - _verifyDepthMax = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyDepthMax", 2); - } + _verifyDepthMax = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyDepthMax", 2); // - // Determine whether a certificate is required from the peer. + // Create an SSL context if the application hasn't supplied one. // + if(!_ctx) { - int verifyPeer = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyPeer", 2); - int sslVerifyMode; - switch(verifyPeer) - { - case 0: - sslVerifyMode = SSL_VERIFY_NONE; - break; - case 1: - sslVerifyMode = SSL_VERIFY_PEER; - break; - case 2: - sslVerifyMode = SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT; - break; - default: + _ctx = SSL_CTX_new(SSLv23_method()); + if(!_ctx) { PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: invalid value for " + propPrefix + "VerifyPeer"; + ex.reason = "IceSSL: unable to create SSL context:\n" + sslErrors(); throw ex; } - } - SSL_CTX_set_verify(_ctx, sslVerifyMode, IceSSL_opensslVerifyCallback); - } - // - // If the configuration defines a password, or the application has supplied - // a password prompt object, then register a password callback. Otherwise, - // let OpenSSL use its default behavior. - // - { - // TODO: Support quoted value? - string password = properties->getProperty(propPrefix + "Password"); - if(!password.empty() || _prompt) - { - SSL_CTX_set_default_passwd_cb(_ctx, IceSSL_opensslPasswordCallback); - SSL_CTX_set_default_passwd_cb_userdata(_ctx, this); - _password = password; - } - } - - int passwordRetryMax = properties->getPropertyAsIntWithDefault(propPrefix + "PasswordRetryMax", 3); + // + // Check for a default directory. We look in this directory for + // files mentioned in the configuration. + // + string defaultDir = properties->getProperty(propPrefix + "DefaultDir"); - // - // Establish the location of CA certificates. - // - { - string caFile = properties->getProperty(propPrefix + "CertAuthFile"); - string caDir = properties->getPropertyWithDefault(propPrefix + "CertAuthDir", _defaultDir); - const char* file = 0; - const char* dir = 0; - if(!caFile.empty()) - { - if(!checkPath(caFile, _defaultDir, false)) - { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: CA certificate file not found:\n" + caFile; - throw ex; - } - file = caFile.c_str(); - } - if(!caDir.empty()) + // + // If the configuration defines a password, or the application has supplied + // a password prompt object, then register a password callback. Otherwise, + // let OpenSSL use its default behavior. + // { - if(!checkPath(caDir, _defaultDir, true)) + // TODO: Support quoted value? + string password = properties->getProperty(propPrefix + "Password"); + if(!password.empty() || _prompt) { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: CA certificate directory not found:\n" + caDir; - throw ex; + SSL_CTX_set_default_passwd_cb(_ctx, IceSSL_opensslPasswordCallback); + SSL_CTX_set_default_passwd_cb_userdata(_ctx, this); + _password = password; } - dir = caDir.c_str(); } - if(file || dir) + + int passwordRetryMax = properties->getPropertyAsIntWithDefault(propPrefix + "PasswordRetryMax", 3); + + // + // Establish the location of CA certificates. + // { - // - // The certificate may be stored in an encrypted file, so handle - // password retries. - // - int count = 0; - int err = 0; - while(count < passwordRetryMax) + string caFile = properties->getProperty(propPrefix + "CertAuthFile"); + string caDir = properties->getPropertyWithDefault(propPrefix + "CertAuthDir", defaultDir); + const char* file = 0; + const char* dir = 0; + if(!caFile.empty()) { - ERR_clear_error(); - err = SSL_CTX_load_verify_locations(_ctx, file, dir); - if(err || !passwordError()) + if(!checkPath(caFile, defaultDir, false)) { - break; + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: CA certificate file not found:\n" + caFile; + throw ex; } - ++count; + file = caFile.c_str(); } - if(err == 0) + if(!caDir.empty()) { - string msg = "IceSSL: unable to establish CA certificates"; - if(passwordError()) - { - msg += ":\ninvalid password"; - } - else - { - string err = sslErrors(); - if(!err.empty()) - { - msg += ":\n" + err; - } - } - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = msg; - throw ex; - } - } - } - - // - // Establish the certificate chains and private keys. One RSA certificate and - // one DSA certificate are allowed. - // - { -#ifdef _WIN32 - const string sep = ";"; -#else - const string sep = ":"; -#endif - string certFile = properties->getProperty(propPrefix + "CertFile"); - string keyFile = properties->getProperty(propPrefix + "KeyFile"); - vector::size_type numCerts = 0; - if(!certFile.empty()) - { - vector files; - if(!IceUtilInternal::splitString(certFile, sep, files) || files.size() > 2) - { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: invalid value for " + propPrefix + "CertFile:\n" + certFile; - throw ex; - } - numCerts = files.size(); - for(vector::iterator p = files.begin(); p != files.end(); ++p) - { - string file = *p; - if(!checkPath(file, _defaultDir, false)) + if(!checkPath(caDir, defaultDir, true)) { PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: certificate file not found:\n" + file; + ex.reason = "IceSSL: CA certificate directory not found:\n" + caDir; throw ex; } + dir = caDir.c_str(); + } + if(file || dir) + { // // The certificate may be stored in an encrypted file, so handle // password retries. @@ -485,7 +364,7 @@ IceSSL::Instance::initialize() while(count < passwordRetryMax) { ERR_clear_error(); - err = SSL_CTX_use_certificate_chain_file(_ctx, file.c_str()); + err = SSL_CTX_load_verify_locations(_ctx, file, dir); if(err || !passwordError()) { break; @@ -494,7 +373,7 @@ IceSSL::Instance::initialize() } if(err == 0) { - string msg = "IceSSL: unable to load certificate chain from file " + file; + string msg = "IceSSL: unable to establish CA certificates"; if(passwordError()) { msg += ":\ninvalid password"; @@ -513,159 +392,284 @@ IceSSL::Instance::initialize() } } } - if(keyFile.empty()) - { - keyFile = certFile; // Assume the certificate file also contains the private key. - } - if(!keyFile.empty()) + + // + // Establish the certificate chains and private keys. One RSA certificate and + // one DSA certificate are allowed. + // { - vector files; - if(!IceUtilInternal::splitString(keyFile, sep, files) || files.size() > 2) +#ifdef _WIN32 + const string sep = ";"; +#else + const string sep = ":"; +#endif + string certFile = properties->getProperty(propPrefix + "CertFile"); + string keyFile = properties->getProperty(propPrefix + "KeyFile"); + vector::size_type numCerts = 0; + if(!certFile.empty()) { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: invalid value for " + propPrefix + "KeyFile:\n" + keyFile; - throw ex; + vector files; + if(!IceUtilInternal::splitString(certFile, sep, files) || files.size() > 2) + { + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: invalid value for " + propPrefix + "CertFile:\n" + certFile; + throw ex; + } + numCerts = files.size(); + for(vector::iterator p = files.begin(); p != files.end(); ++p) + { + string file = *p; + if(!checkPath(file, defaultDir, false)) + { + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: certificate file not found:\n" + file; + throw ex; + } + // + // The certificate may be stored in an encrypted file, so handle + // password retries. + // + int count = 0; + int err = 0; + while(count < passwordRetryMax) + { + ERR_clear_error(); + err = SSL_CTX_use_certificate_chain_file(_ctx, file.c_str()); + if(err || !passwordError()) + { + break; + } + ++count; + } + if(err == 0) + { + string msg = "IceSSL: unable to load certificate chain from file " + file; + if(passwordError()) + { + msg += ":\ninvalid password"; + } + else + { + string err = sslErrors(); + if(!err.empty()) + { + msg += ":\n" + err; + } + } + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = msg; + throw ex; + } + } } - if(files.size() != numCerts) + if(keyFile.empty()) { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: " + propPrefix + "KeyFile does not agree with " + propPrefix + "CertFile"; - throw ex; + keyFile = certFile; // Assume the certificate file also contains the private key. } - for(vector::iterator p = files.begin(); p != files.end(); ++p) + if(!keyFile.empty()) { - string file = *p; - if(!checkPath(file, _defaultDir, false)) + vector files; + if(!IceUtilInternal::splitString(keyFile, sep, files) || files.size() > 2) { PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: key file not found:\n" + file; + ex.reason = "IceSSL: invalid value for " + propPrefix + "KeyFile:\n" + keyFile; throw ex; } - // - // The private key may be stored in an encrypted file, so handle - // password retries. - // - int count = 0; - int err = 0; - while(count < passwordRetryMax) + if(files.size() != numCerts) { - ERR_clear_error(); - err = SSL_CTX_use_PrivateKey_file(_ctx, file.c_str(), SSL_FILETYPE_PEM); - if(err || !passwordError()) - { - break; - } - ++count; + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: " + propPrefix + "KeyFile does not agree with " + propPrefix + "CertFile"; + throw ex; } - if(err == 0) + for(vector::iterator p = files.begin(); p != files.end(); ++p) { - string msg = "IceSSL: unable to load private key from file " + file; - if(passwordError()) + string file = *p; + if(!checkPath(file, defaultDir, false)) { - msg += ":\ninvalid password"; + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: key file not found:\n" + file; + throw ex; } - else + // + // The private key may be stored in an encrypted file, so handle + // password retries. + // + int count = 0; + int err = 0; + while(count < passwordRetryMax) { - string err = sslErrors(); - if(!err.empty()) + ERR_clear_error(); + err = SSL_CTX_use_PrivateKey_file(_ctx, file.c_str(), SSL_FILETYPE_PEM); + if(err || !passwordError()) { - msg += ":\n" + err; + break; } + ++count; } + if(err == 0) + { + string msg = "IceSSL: unable to load private key from file " + file; + if(passwordError()) + { + msg += ":\ninvalid password"; + } + else + { + string err = sslErrors(); + if(!err.empty()) + { + msg += ":\n" + err; + } + } + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = msg; + throw ex; + } + } + if(!SSL_CTX_check_private_key(_ctx)) + { PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = msg; + ex.reason = "IceSSL: unable to validate private key(s):\n" + sslErrors(); throw ex; } } - if(!SSL_CTX_check_private_key(_ctx)) + } + + // + // Diffie Hellman configuration. + // + { +#ifndef OPENSSL_NO_DH + _dhParams = new DHParams; + SSL_CTX_set_options(_ctx, SSL_OP_SINGLE_DH_USE); + SSL_CTX_set_tmp_dh_callback(_ctx, IceSSL_opensslDHCallback); +#endif + // + // Properties have the following form: + // + // ...DH.=file + // + const string dhPrefix = propPrefix + "DH."; + PropertyDict d = properties->getPropertiesForPrefix(dhPrefix); + if(!d.empty()) { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: unable to validate private key(s):\n" + sslErrors(); - throw ex; +#ifdef OPENSSL_NO_DH + _logger->warning("IceSSL: OpenSSL is not configured for Diffie Hellman"); +#else + for(PropertyDict::iterator p = d.begin(); p != d.end(); ++p) + { + string s = p->first.substr(dhPrefix.size()); + int keyLength = atoi(s.c_str()); + if(keyLength > 0) + { + string file = p->second; + if(!checkPath(file, defaultDir, false)) + { + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: DH parameter file not found:\n" + file; + throw ex; + } + if(!_dhParams->add(keyLength, file)) + { + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: unable to read DH parameter file " + file; + throw ex; + } + } + } +#endif } } } + // + // Store a pointer to ourself for use in OpenSSL callbacks. + // + SSL_CTX_set_ex_data(_ctx, 0, this); + + // + // This is necessary for successful interop with Java. Without it, a Java + // client would fail to reestablish a connection: the server gets the + // error "session id context uninitialized" and the client receives + // "SSLHandshakeException: Remote host closed connection during handshake". + // + SSL_CTX_set_session_cache_mode(_ctx, SSL_SESS_CACHE_OFF); + + // + // Select protocols. + // + StringSeq protocols = properties->getPropertyAsList(propPrefix + "Protocols"); + if(!protocols.empty()) + { + parseProtocols(protocols); + } + // // Establish the cipher list. // + string ciphers = properties->getProperty(propPrefix + "Ciphers"); + if(!ciphers.empty()) { - string ciphers = properties->getProperty(propPrefix + "Ciphers"); - if(!ciphers.empty()) + if(!SSL_CTX_set_cipher_list(_ctx, ciphers.c_str())) { - if(!SSL_CTX_set_cipher_list(_ctx, ciphers.c_str())) - { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: unable to set ciphers using `" + ciphers + "':\n" + sslErrors(); - throw ex; - } + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: unable to set ciphers using `" + ciphers + "':\n" + sslErrors(); + throw ex; } } // - // Diffie Hellman configuration. + // Determine whether a certificate is required from the peer. // { -#ifndef OPENSSL_NO_DH - _dhParams = new DHParams; - SSL_CTX_set_options(_ctx, SSL_OP_SINGLE_DH_USE); - SSL_CTX_set_tmp_dh_callback(_ctx, IceSSL_opensslDHCallback); -#endif - // - // Properties have the following form: - // - // ...DH.=file - // - const string dhPrefix = propPrefix + "DH."; - PropertyDict d = properties->getPropertiesForPrefix(dhPrefix); - if(!d.empty()) + int verifyPeer = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyPeer", 2); + int sslVerifyMode; + switch(verifyPeer) { -#ifdef OPENSSL_NO_DH - _logger->warning("IceSSL: OpenSSL is not configured for Diffie Hellman"); -#else - for(PropertyDict::iterator p = d.begin(); p != d.end(); ++p) - { - string s = p->first.substr(dhPrefix.size()); - int keyLength = atoi(s.c_str()); - if(keyLength > 0) - { - string file = p->second; - if(!checkPath(file, _defaultDir, false)) - { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: DH parameter file not found:\n" + file; - throw ex; - } - if(!_dhParams->add(keyLength, file)) - { - PluginInitializationException ex(__FILE__, __LINE__); - ex.reason = "IceSSL: unable to read DH parameter file " + file; - throw ex; - } - } - } -#endif + case 0: + sslVerifyMode = SSL_VERIFY_NONE; + break; + case 1: + sslVerifyMode = SSL_VERIFY_PEER; + break; + case 2: + sslVerifyMode = SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT; + break; + default: + { + PluginInitializationException ex(__FILE__, __LINE__); + ex.reason = "IceSSL: invalid value for " + propPrefix + "VerifyPeer"; + throw ex; } + } + SSL_CTX_set_verify(_ctx, sslVerifyMode, IceSSL_opensslVerifyCallback); } } catch(...) { + // + // We free the SSL context regardless of whether the plugin created it + // or the application supplied it. + // SSL_CTX_free(_ctx); _ctx = 0; throw; } + + _initialized = true; } void IceSSL::Instance::context(SSL_CTX* context) { - if(_ctx) + if(_initialized) { PluginInitializationException ex(__FILE__, __LINE__); ex.reason = "IceSSL: plug-in is already initialized"; throw ex; } + assert(!_ctx); _ctx = context; } diff --git a/cpp/src/IceSSL/Instance.h b/cpp/src/IceSSL/Instance.h index f0b4fb3ed5f..2f89f82a6b1 100644 --- a/cpp/src/IceSSL/Instance.h +++ b/cpp/src/IceSSL/Instance.h @@ -70,6 +70,7 @@ private: IceInternal::ProtocolPluginFacadePtr _facade; int _securityTraceLevel; std::string _securityTraceCategory; + bool _initialized; SSL_CTX* _ctx; std::string _defaultDir; bool _checkCertName; -- cgit v1.2.3 From a10f33af6ee6298b4a7412a3819cc4818f086fa4 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Thu, 15 Jan 2009 16:02:54 +0100 Subject: - Fixed errorDetection test - Fixed bug 3504, added locator request queue. --- CHANGES | 4 + cpp/src/Ice/LocatorInfo.cpp | 446 +++++++++++++----- cpp/src/Ice/LocatorInfo.h | 51 +++ cpp/test/Ice/location/AllTests.cpp | 50 ++ cpp/test/Ice/location/Test.ice | 2 +- .../Slice/errorDetection/IllegalIdentifier.ice | 42 +- cpp/test/Slice/errorDetection/run.py | 2 +- cs/src/Ice/LocatorInfo.cs | 505 ++++++++++++++++----- cs/test/Ice/location/AllTests.cs | 49 ++ cs/test/Ice/location/Test.ice | 2 +- java/src/IceInternal/LocatorInfo.java | 465 +++++++++++++++---- java/test/Ice/location/AllTests.java | 48 ++ java/test/Ice/location/Test.ice | 2 +- 13 files changed, 1323 insertions(+), 345 deletions(-) (limited to 'cpp/src') diff --git a/CHANGES b/CHANGES index 3d06162dab6..5cd3f8cd2e1 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,10 @@ Changes since version 3.3.0 General Changes =============== +- Optimized the Ice client runtime to minimize locator requests when + multiple concurrent or AMI requests need to resolve the endpoints of + a same well-known object, object adapter or replica group. + - Fixed a bug in IceGrid that would cause it to generate incorrect config files for servers whose ice-version was set to a version previous to Ice 3.3.0. diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index 12d87e3dcab..0113f80a868 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -26,6 +26,174 @@ IceUtil::Shared* IceInternal::upCast(LocatorManager* p) { return p; } IceUtil::Shared* IceInternal::upCast(LocatorInfo* p) { return p; } IceUtil::Shared* IceInternal::upCast(LocatorTable* p) { return p; } +namespace +{ + +class ObjectRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findObjectById +{ +public: + + ObjectRequest(const LocatorInfoPtr& locatorInfo, const Ice::Identity& id) : Request(locatorInfo), _id(id) + { + } + + virtual void ice_response(const Ice::ObjectPrx& proxy) + { + _locatorInfo->removeObjectRequest(_id); + response(proxy); + } + + virtual void ice_exception(const Ice::Exception& ex) + { + _locatorInfo->removeObjectRequest(_id); + exception(ex); + } + + virtual void send() + { + _locatorInfo->getLocator()->findObjectById_async(this, _id); + } + +private: + + const Ice::Identity _id; +}; + +class AdapterRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findAdapterById +{ +public: + + AdapterRequest(const LocatorInfoPtr& locatorInfo, const string& id) : Request(locatorInfo), _id(id) + { + } + + virtual void ice_response(const Ice::ObjectPrx& proxy) + { + _locatorInfo->removeAdapterRequest(_id); + response(proxy); + } + + virtual void ice_exception(const Ice::Exception& ex) + { + _locatorInfo->removeAdapterRequest(_id); + exception(ex); + } + + virtual void send() + { + _locatorInfo->getLocator()->findAdapterById_async(this, _id); + } + +private: + + const string _id; +}; + +class ObjectRequestCallback : public LocatorInfo::RequestCallback +{ +public: + + virtual void + response(const LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& object) + { + locatorInfo->getWellKnownObjectEndpoints(_reference, object, _ttl, false, _callback); + } + + virtual void + exception(const LocatorInfoPtr& locatorInfo, const Ice::Exception& ex) + { + if(dynamic_cast(&ex)) + { + try + { + bool cached; + vector endpoints = locatorInfo->getEndpoints(_reference, _ttl, cached); + _callback->setEndpoints(endpoints, cached); + } + catch(const Ice::LocalException& e) + { + _callback->setException(e); + } + } + else + { + locatorInfo->getEndpointsException(_reference, ex, _callback); + } + } + + ObjectRequestCallback(const ReferencePtr& ref, int ttl, const LocatorInfo::GetEndpointsCallbackPtr& cb) : + _reference(ref), _ttl(ttl), _callback(cb) + { + } + +private: + + const ReferencePtr _reference; + int _ttl; + const LocatorInfo::GetEndpointsCallbackPtr _callback; +}; + +class AdapterRequestCallback : public LocatorInfo::RequestCallback +{ +public: + + virtual void + response(const LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& object) + { + vector endpoints; + if(object) + { + endpoints = object->__reference()->getEndpoints(); + if(!endpoints.empty()) + { + locatorInfo->getTable()->addAdapterEndpoints(_reference->getAdapterId(), endpoints); + } + } + + if(_reference->getInstance()->traceLevels()->location >= 1) + { + locatorInfo->getEndpointsTrace(_reference, endpoints, false); + } + + _callback->setEndpoints(endpoints, false); + } + + virtual void + exception(const LocatorInfoPtr& locatorInfo, const Ice::Exception& ex) + { + if(dynamic_cast(&ex)) + { + try + { + bool cached; + vector endpoints = locatorInfo->getEndpoints(_reference, _ttl, cached); + _callback->setEndpoints(endpoints, cached); + } + catch(const Ice::LocalException& e) + { + _callback->setException(e); + } + } + else + { + locatorInfo->getEndpointsException(_reference, ex, _callback); + } + } + + AdapterRequestCallback(const ReferencePtr& ref, int ttl, const LocatorInfo::GetEndpointsCallbackPtr& callback) : + _reference(ref), _ttl(ttl), _callback(callback) + { + } + +private: + + const ReferencePtr _reference; + const int _ttl; + const LocatorInfo::GetEndpointsCallbackPtr _callback; +}; + +} + IceInternal::LocatorManager::LocatorManager() : _tableHint(_table.end()) { @@ -238,6 +406,111 @@ IceInternal::LocatorTable::checkTTL(const IceUtil::Time& time, int ttl) const } } +void +IceInternal::LocatorInfo::Request::addCallback(const RequestCallbackPtr& callback) +{ + IceUtil::Monitor::Lock sync(_monitor); + if(_response) + { + callback->response(_locatorInfo, _proxy); + return; + } + else if(_exception.get()) + { + callback->exception(_locatorInfo, *_exception.get()); + return; + } + + _callbacks.push_back(callback); + + if(!_sent) + { + _sent = true; + try + { + send(); + } + catch(const Ice::Exception& ex) + { + sync.release(); + exception(ex); + sync.acquire(); + } + } +} + +Ice::ObjectPrx +IceInternal::LocatorInfo::Request::getProxy() +{ + IceUtil::Monitor::Lock sync(_monitor); + if(_response) + { + return _proxy; + } + else if(_exception.get()) + { + _exception->ice_throw(); + return 0; // Keep the compiler happy. + } + + if(!_sent) + { + _sent = true; + try + { + send(); + } + catch(const Ice::Exception& ex) + { + sync.release(); + exception(ex); + sync.acquire(); + } + } + + while(!_response && !_exception.get()) + { + _monitor.wait(); + } + + if(_exception.get()) + { + _exception->ice_throw(); + } + assert(_response); + return _proxy; +} + +IceInternal::LocatorInfo::Request::Request(const LocatorInfoPtr& locatorInfo) : + _locatorInfo(locatorInfo), _sent(false), _response(false) +{ +} + +void +IceInternal::LocatorInfo::Request::response(const Ice::ObjectPrx& proxy) +{ + IceUtil::Monitor::Lock sync(_monitor); + _response = true; + _proxy = proxy; + for(vector::const_iterator p = _callbacks.begin(); p != _callbacks.end(); ++p) + { + (*p)->response(_locatorInfo, proxy); + } + _monitor.notifyAll(); +} + +void +IceInternal::LocatorInfo::Request::exception(const Ice::Exception& ex) +{ + IceUtil::Monitor::Lock sync(_monitor); + _exception.reset(ex.ice_clone()); + for(vector::const_iterator p = _callbacks.begin(); p != _callbacks.end(); ++p) + { + (*p)->exception(_locatorInfo, ex); + } + _monitor.notifyAll(); +} + IceInternal::LocatorInfo::LocatorInfo(const LocatorPrx& locator, const LocatorTablePtr& table) : _locator(locator), _table(table) @@ -323,7 +596,8 @@ IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, bool& c out << "adapter = " << ref->getAdapterId(); } - object = _locator->findAdapterById(ref->getAdapterId()); + RequestPtr request = getAdapterRequest(ref->getAdapterId()); + object = request->getProxy(); if(object) { endpoints = object->__reference()->getEndpoints(); @@ -345,7 +619,8 @@ IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, bool& c } objectCached = false; - object = _locator->findObjectById(ref->getIdentity()); + RequestPtr request = getObjectRequest(ref->getIdentity()); + object = request->getProxy(); } bool endpointsCached = true; @@ -384,73 +659,6 @@ IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, bool& c return endpoints; } -namespace IceInternal -{ - -class findAdapterByIdCallback : public AMI_Locator_findAdapterById -{ -public: - - virtual void - ice_response(const Ice::ObjectPrx& object) - { - vector endpoints; - if(object) - { - endpoints = object->__reference()->getEndpoints(); - if(!endpoints.empty()) - { - _table->addAdapterEndpoints(_reference->getAdapterId(), endpoints); - } - } - - if(_reference->getInstance()->traceLevels()->location >= 1) - { - _locatorInfo->getEndpointsTrace(_reference, endpoints, false); - } - - _callback->setEndpoints(endpoints, false); - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - if(dynamic_cast(&ex)) - { - try - { - bool cached; - vector endpoints = _locatorInfo->getEndpoints(_reference, _ttl, cached); - _callback->setEndpoints(endpoints, cached); - } - catch(const Ice::LocalException& e) - { - _callback->setException(e); - } - } - else - { - _locatorInfo->getEndpointsException(_reference, ex, _callback); - } - } - - findAdapterByIdCallback(const LocatorInfoPtr& locatorInfo, const LocatorTablePtr& table, - const ReferencePtr& reference, int ttl, const LocatorInfo::GetEndpointsCallbackPtr& callback) : - _locatorInfo(locatorInfo), _table(table), _reference(reference), _ttl(ttl), _callback(callback) - { - } - -private: - - const LocatorInfoPtr _locatorInfo; - const LocatorTablePtr _table; - const ReferencePtr _reference; - const int _ttl; - const LocatorInfo::GetEndpointsCallbackPtr _callback; -}; - -}; - void IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, const GetEndpointsCallbackPtr& callback) { @@ -474,8 +682,8 @@ IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, const G // Search the adapter in the location service if we didn't // find it in the cache. // - _locator->findAdapterById_async( - new IceInternal::findAdapterByIdCallback(this, _table, ref, ttl, callback), adapterId); + RequestPtr request = getAdapterRequest(adapterId); + request->addCallback(new AdapterRequestCallback(ref, ttl, callback)); return; } else @@ -499,53 +707,8 @@ IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, const G out << "searching for object by id" << "\nobject = " << instance->identityToString(ref->getIdentity()); } - class Callback : public Ice::AMI_Locator_findObjectById - { - public: - - virtual void - ice_response(const Ice::ObjectPrx& object) - { - _locatorInfo->getWellKnownObjectEndpoints(_reference, object, _ttl, false, _callback); - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - if(dynamic_cast(&ex)) - { - try - { - bool cached; - vector endpoints = _locatorInfo->getEndpoints(_reference, _ttl, cached); - _callback->setEndpoints(endpoints, cached); - } - catch(const Ice::LocalException& e) - { - _callback->setException(e); - } - } - else - { - _locatorInfo->getEndpointsException(_reference, ex, _callback); - } - } - - Callback(const LocatorInfoPtr& locatorInfo, const ReferencePtr& reference, int ttl, - const GetEndpointsCallbackPtr& callback) : - _locatorInfo(locatorInfo), _reference(reference), _ttl(ttl), _callback(callback) - { - } - - private: - - const LocatorInfoPtr _locatorInfo; - const ReferencePtr _reference; - int _ttl; - const GetEndpointsCallbackPtr _callback; - }; - - _locator->findObjectById_async(new Callback(this, ref, ttl, callback), identity); + RequestPtr request = getObjectRequest(identity); + request->addCallback(new ObjectRequestCallback(ref, ttl, callback)); return; } else @@ -828,3 +991,50 @@ IceInternal::LocatorInfo::getEndpointsTrace(const ReferencePtr& ref, const vecto } } } + +IceInternal::LocatorInfo::RequestPtr +IceInternal::LocatorInfo::getAdapterRequest(const string& id) +{ + IceUtil::Mutex::Lock sync(*this); + map::const_iterator p = _adapterRequests.find(id); + if(p != _adapterRequests.end()) + { + return p->second; + } + + RequestPtr request = new AdapterRequest(this, id); + _adapterRequests.insert(make_pair(id, request)); + return request; +} + +void +IceInternal::LocatorInfo::removeAdapterRequest(const string& id) +{ + IceUtil::Mutex::Lock sync(*this); + assert(_adapterRequests.find(id) != _adapterRequests.end()); + _adapterRequests.erase(id); +} + +IceInternal::LocatorInfo::RequestPtr +IceInternal::LocatorInfo::getObjectRequest(const Ice::Identity& id) +{ + IceUtil::Mutex::Lock sync(*this); + map::const_iterator p = _objectRequests.find(id); + if(p != _objectRequests.end()) + { + return p->second; + } + + RequestPtr request = new ObjectRequest(this, id); + _objectRequests.insert(make_pair(id, request)); + return request; +} + +void +IceInternal::LocatorInfo::removeObjectRequest(const Ice::Identity& id) +{ + IceUtil::Mutex::Lock sync(*this); + assert(_objectRequests.find(id) != _objectRequests.end()); + _objectRequests.erase(id); +} + diff --git a/cpp/src/Ice/LocatorInfo.h b/cpp/src/Ice/LocatorInfo.h index ad8db69fe27..a4fe455a942 100644 --- a/cpp/src/Ice/LocatorInfo.h +++ b/cpp/src/Ice/LocatorInfo.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -71,6 +72,44 @@ class LocatorInfo : public IceUtil::Shared, public IceUtil::Mutex { public: + class RequestCallback : virtual public IceUtil::Shared + { + public: + + virtual void response(const LocatorInfoPtr&, const Ice::ObjectPrx&) = 0; + virtual void exception(const LocatorInfoPtr&, const Ice::Exception&) = 0; + }; + typedef IceUtil::Handle RequestCallbackPtr; + + class Request : virtual public IceUtil::Shared + { + public: + + void addCallback(const RequestCallbackPtr&); + Ice::ObjectPrx getProxy(); + + protected: + + Request(const LocatorInfoPtr&); + + void response(const Ice::ObjectPrx&); + void exception(const Ice::Exception&); + + virtual void send() = 0; + + const LocatorInfoPtr _locatorInfo; + + private: + + IceUtil::Monitor _monitor; + std::vector _callbacks; + bool _sent; + bool _response; + Ice::ObjectPrx _proxy; + std::auto_ptr _exception; + }; + typedef IceUtil::Handle RequestPtr; + class GetEndpointsCallback : virtual public IceUtil::Shared { public: @@ -105,13 +144,25 @@ public: void getEndpointsException(const ReferencePtr&, const Ice::Exception&, const GetEndpointsCallbackPtr&); void getEndpointsTrace(const ReferencePtr&, const std::vector&, bool); + const LocatorTablePtr& getTable() { return _table; } + + RequestPtr getAdapterRequest(const std::string&); + void removeAdapterRequest(const std::string&); + + RequestPtr getObjectRequest(const Ice::Identity&); + void removeObjectRequest(const Ice::Identity&); + private: + void trace(const std::string&, const ReferencePtr&, const std::vector&); const Ice::LocatorPrx _locator; Ice::LocatorRegistryPrx _locatorRegistry; const LocatorTablePtr _table; + + std::map _adapterRequests; + std::map _objectRequests; }; } diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index 46b02be526b..77b8a09ec3a 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -288,6 +288,7 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) cout << "ok" << endl; cout << "testing proxy from server... " << flush; + obj = TestIntfPrx::checkedCast(communicator->stringToProxy("test@TestAdapter")); HelloPrx hello = obj->getHello(); test(hello->ice_getAdapterId() == "TestAdapter"); hello->sayHello(); @@ -296,7 +297,56 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) hello->sayHello(); cout << "ok" << endl; + cout << "testing locator request queuing... " << flush; + hello = obj->getReplicatedHello()->ice_locatorCacheTimeout(0)->ice_connectionCached(false); + count = locator->getRequestCount(); + hello->ice_ping(); + test(++count == locator->getRequestCount()); + for(int i = 0; i < 1000; i++) + { + class AMICallback : public Test::AMI_Hello_sayHello + { + public: + virtual void + ice_exception(const Ice::Exception&) + { + test(false); + } + + virtual void + ice_response() + { + } + }; + hello->sayHello_async(new AMICallback()); + } + test(locator->getRequestCount() > count && locator->getRequestCount() < count + 100); + count = locator->getRequestCount(); + hello = hello->ice_adapterId("unknown"); + for(int i = 0; i < 1000; i++) + { + class AMICallback : public Test::AMI_Hello_sayHello + { + public: + virtual void + ice_exception(const Ice::Exception& ex) + { + test(dynamic_cast(&ex)); + } + + virtual void + ice_response() + { + test(false); + } + }; + hello->sayHello_async(new AMICallback()); + } + test(locator->getRequestCount() > count && locator->getRequestCount() < count + 100); + cout << "ok" << endl; + cout << "testing proxy from server after shutdown... " << flush; + hello = obj->getReplicatedHello(); obj->shutdown(); manager->startServer(); hello->sayHello(); diff --git a/cpp/test/Ice/location/Test.ice b/cpp/test/Ice/location/Test.ice index f53b85e18aa..95702e5cd4d 100644 --- a/cpp/test/Ice/location/Test.ice +++ b/cpp/test/Ice/location/Test.ice @@ -39,7 +39,7 @@ interface ServerManager interface Hello { - void sayHello(); + ["ami"] void sayHello(); }; interface TestIntf diff --git a/cpp/test/Slice/errorDetection/IllegalIdentifier.ice b/cpp/test/Slice/errorDetection/IllegalIdentifier.ice index 2da89686467..d50ddb4afe1 100644 --- a/cpp/test/Slice/errorDetection/IllegalIdentifier.ice +++ b/cpp/test/Slice/errorDetection/IllegalIdentifier.ice @@ -1,21 +1,21 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. -// -// This copy of Ice is licensed to you under the terms described in the -// ICE_LICENSE file included in this distribution. -// -// ********************************************************************** - - -// -// Check that 'œ' is properly rejected in idenifiers -// - -module Test -{ - interface Œuvre - { - void cœur(); - }; -}; +// ********************************************************************** +// +// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + + +// +// Check that 'œ' is properly rejected in idenifiers +// + +module Test +{ + interface Œuvre + { + void cœur(); + }; +}; diff --git a/cpp/test/Slice/errorDetection/run.py b/cpp/test/Slice/errorDetection/run.py index 769754c0b84..b10af237310 100755 --- a/cpp/test/Slice/errorDetection/run.py +++ b/cpp/test/Slice/errorDetection/run.py @@ -39,7 +39,7 @@ for file in files: else: command = slice2cpp + " -I. " + os.path.join(os.getcwd(), file); stdin, stdout, stderr = os.popen3(command) - lines1 = stdout.readlines() + lines1 = stderr.readlines() lines2 = open(os.path.join(os.getcwd(), regex1.sub(".err", file)), "r").readlines() if len(lines1) != len(lines2): print "failed!" diff --git a/cs/src/Ice/LocatorInfo.cs b/cs/src/Ice/LocatorInfo.cs index c1e118706d8..e7588353c3e 100644 --- a/cs/src/Ice/LocatorInfo.cs +++ b/cs/src/Ice/LocatorInfo.cs @@ -8,12 +8,338 @@ // ********************************************************************** using System.Collections; +using System.Collections.Generic; using System.Diagnostics; +using System.Threading; namespace IceInternal { public sealed class LocatorInfo { + private interface RequestCallback + { + void response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy); + void exception(LocatorInfo locatorInfo, Ice.Exception ex); + } + + private abstract class Request + { + public void + addCallback(RequestCallback callback) + { + lock(this) + { + if(_response) + { + callback.response(_locatorInfo, _proxy); + return; + } + else if(_exception != null) + { + callback.exception(_locatorInfo, _exception); + return; + } + + _callbacks.Add(callback); + + if(!_sent) + { + _sent = true; + try + { + send(); + } + catch(Ice.Exception ex) + { + exception(ex); + } + } + } + } + + public Ice.ObjectPrx + getProxy() + { + lock(this) + { + if(_response) + { + return _proxy; + } + else if(_exception != null) + { + throw _exception; + } + + if(!_sent) + { + _sent = true; + try + { + send(); + } + catch(Ice.Exception ex) + { + exception(ex); + } + } + + while(!_response && _exception == null) + { + Monitor.Wait(this); + } + + if(_exception != null) + { + throw _exception; + } + Debug.Assert(_response); + return _proxy; + } + } + + protected + Request(LocatorInfo locatorInfo) + { + _locatorInfo = locatorInfo; + _sent = false; + _response = false; + } + + public void + response(Ice.ObjectPrx proxy) + { + lock(this) + { + _response = true; + _proxy = proxy; + foreach(RequestCallback c in _callbacks) + { + c.response(_locatorInfo, proxy); + } + Monitor.PulseAll(this); + } + } + + public void + exception(Ice.Exception ex) + { + lock(this) + { + _exception = ex; + foreach(RequestCallback c in _callbacks) + { + c.exception(_locatorInfo, ex); + } + Monitor.PulseAll(this); + } + } + + protected abstract void send(); + + protected readonly LocatorInfo _locatorInfo; + + private List _callbacks = new List(); + private bool _sent; + private bool _response; + private Ice.ObjectPrx _proxy; + private Ice.Exception _exception; + } + + private class ObjectRequest : Request + { + private class AMICallback : Ice.AMI_Locator_findObjectById + { + public AMICallback(Request request, LocatorInfo locatorInfo, Ice.Identity id) + { + _request = request; + _locatorInfo = locatorInfo; + _id = id; + } + + override public void + ice_response(Ice.ObjectPrx proxy) + { + _locatorInfo.removeObjectRequest(_id); + _request.response(proxy); + } + + override public void + ice_exception(Ice.Exception ex) + { + _locatorInfo.removeObjectRequest(_id); + _request.exception(ex); + } + + private readonly Request _request; + private readonly LocatorInfo _locatorInfo; + private readonly Ice.Identity _id; + } + + public ObjectRequest(LocatorInfo locatorInfo, Ice.Identity id) : base(locatorInfo) + { + _id = id; + } + + override protected void + send() + { + _locatorInfo.getLocator().findObjectById_async(new AMICallback(this, _locatorInfo, _id), _id); + } + + private readonly Ice.Identity _id; + } + + private class AdapterRequest : Request + { + private class AMICallback : Ice.AMI_Locator_findAdapterById + { + public AMICallback(Request request, LocatorInfo locatorInfo, string id) + { + _request = request; + _locatorInfo = locatorInfo; + _id = id; + } + + override public void + ice_response(Ice.ObjectPrx proxy) + { + _locatorInfo.removeAdapterRequest(_id); + _request.response(proxy); + } + + override public void + ice_exception(Ice.Exception ex) + { + _locatorInfo.removeAdapterRequest(_id); + _request.exception(ex); + } + + private readonly Request _request; + private readonly LocatorInfo _locatorInfo; + private readonly string _id; + } + + public AdapterRequest(LocatorInfo locatorInfo, string id) : base(locatorInfo) + { + _id = id; + } + + override protected void + send() + { + _locatorInfo.getLocator().findAdapterById_async(new AMICallback(this, _locatorInfo, _id), _id); + } + + private readonly string _id; + } + + private class ObjectRequestCallback : RequestCallback + { + public void + response(LocatorInfo locatorInfo, Ice.ObjectPrx obj) + { + locatorInfo.getWellKnownObjectEndpoints(_reference, obj, _ttl, false, _callback); + } + + public void + exception(LocatorInfo locatorInfo, Ice.Exception ex) + { + if(ex is Ice.CollocationOptimizationException) + { + try + { + bool cached; + _callback.setEndpoints(locatorInfo.getEndpoints(_reference, _ttl, out cached), cached); + } + catch(Ice.LocalException e) + { + _callback.setException(e); + } + } + else + { + locatorInfo.getEndpointsException(_reference, ex, _callback); + } + } + + public + ObjectRequestCallback(Reference @ref, int ttl, GetEndpointsCallback cb) + { + _reference = @ref; + _ttl = ttl; + _callback = cb; + } + + private readonly Reference _reference; + private readonly int _ttl; + private readonly GetEndpointsCallback _callback; + } + + private class AdapterRequestCallback : RequestCallback + { + public void + response(LocatorInfo locatorInfo, Ice.ObjectPrx obj) + { + EndpointI[] endpoints = null; + if(obj != null) + { + endpoints = ((Ice.ObjectPrxHelperBase)obj).reference__().getEndpoints(); + if(endpoints.Length > 0) + { + locatorInfo.getTable().addAdapterEndpoints(_reference.getAdapterId(), endpoints); + } + } + + if(_reference.getInstance().traceLevels().location >= 1) + { + locatorInfo.getEndpointsTrace(_reference, endpoints, false); + } + + if(endpoints == null) + { + _callback.setEndpoints(new EndpointI[0], false); + } + else + { + _callback.setEndpoints(endpoints, false); + } + } + + public void + exception(LocatorInfo locatorInfo, Ice.Exception ex) + { + if(ex is Ice.CollocationOptimizationException) + { + try + { + bool cached; + _callback.setEndpoints(locatorInfo.getEndpoints(_reference, _ttl, out cached), cached); + } + catch(Ice.LocalException e) + { + _callback.setException(e); + } + } + else + { + locatorInfo.getEndpointsException(_reference, ex, _callback); + } + } + + public + AdapterRequestCallback(Reference @ref, int ttl, GetEndpointsCallback callback) + { + _reference = @ref; + _ttl = ttl; + _callback = callback; + } + + private readonly Reference _reference; + private readonly int _ttl; + private readonly GetEndpointsCallback _callback; + } + public interface GetEndpointsCallback { void setEndpoints(EndpointI[] endpoints, bool cached); @@ -109,7 +435,8 @@ namespace IceInternal // Search the adapter in the location service if we didn't // find it in the cache. // - obj = _locator.findAdapterById(adapterId); + Request request = getAdapterRequest(adapterId); + obj = request.getProxy(); if(obj != null) { endpoints = ((Ice.ObjectPrxHelperBase)obj).reference__().getEndpoints(); @@ -138,7 +465,8 @@ namespace IceInternal @ref.getInstance().traceLevels().locationCat, s.ToString()); } - obj = _locator.findObjectById(identity); + Request request = getObjectRequest(identity); + obj = request.getProxy(); } bool endpointsCached = true; @@ -177,110 +505,6 @@ namespace IceInternal return endpoints == null ? new EndpointI[0] : endpoints; } - private class AdapterCallback : Ice.AMI_Locator_findAdapterById - { - internal AdapterCallback(LocatorInfo info, Reference @ref, int ttl, GetEndpointsCallback callback) - { - _info = info; - _ref = @ref; - _ttl = ttl; - _callback = callback; - } - - public override void ice_response(Ice.ObjectPrx obj) - { - EndpointI[] endpoints = null; - if(obj != null) - { - endpoints = ((Ice.ObjectPrxHelperBase)obj).reference__().getEndpoints(); - if(endpoints.Length > 0) - { - _info._table.addAdapterEndpoints(_ref.getAdapterId(), endpoints); - } - } - - if(_ref.getInstance().traceLevels().location >= 1) - { - _info.getEndpointsTrace(_ref, endpoints, false); - } - - if(endpoints == null) - { - _callback.setEndpoints(new EndpointI[0], false); - } - else - { - _callback.setEndpoints(endpoints, false); - } - } - - public override void ice_exception(Ice.Exception ex) - { - if(ex is Ice.CollocationOptimizationException) - { - try - { - bool cached; - _callback.setEndpoints(_info.getEndpoints(_ref, _ttl, out cached), cached); - } - catch(Ice.LocalException e) - { - _callback.setException(e); - } - } - else - { - _info.getEndpointsException(_ref, ex, _callback); - } - } - - private LocatorInfo _info; - private Reference _ref; - private int _ttl; - private GetEndpointsCallback _callback; - } - - private class ObjectCallback : Ice.AMI_Locator_findObjectById - { - internal ObjectCallback(LocatorInfo info, Reference @ref, int ttl, GetEndpointsCallback callback) - { - _info = info; - _ref = @ref; - _ttl = ttl; - _callback = callback; - } - - public override void ice_response(Ice.ObjectPrx obj) - { - _info.getWellKnownObjectEndpoints(_ref, obj, _ttl, false, _callback); - } - - public override void ice_exception(Ice.Exception ex) - { - if(ex is Ice.CollocationOptimizationException) - { - try - { - bool cached; - _callback.setEndpoints(_info.getEndpoints(_ref, _ttl, out cached), cached); - } - catch(Ice.LocalException e) - { - _callback.setException(e); - } - } - else - { - _info.getEndpointsException(_ref, ex, _callback); - } - } - - private LocatorInfo _info; - private Reference _ref; - private int _ttl; - private GetEndpointsCallback _callback; - } - public void getEndpoints(Reference @ref, int ttl, GetEndpointsCallback callback) { Debug.Assert(@ref.isIndirect()); @@ -305,7 +529,8 @@ namespace IceInternal // Search the adapter in the location service if we didn't // find it in the cache. // - _locator.findAdapterById_async(new AdapterCallback(this, @ref, ttl, callback), adapterId); + Request request = getAdapterRequest(adapterId); + request.addCallback(new AdapterRequestCallback(@ref, ttl, callback)); return; } else @@ -331,7 +556,8 @@ namespace IceInternal instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); } - _locator.findObjectById_async(new ObjectCallback(this, @ref, ttl, callback), identity); + Request request = getObjectRequest(identity); + request.addCallback(new ObjectRequestCallback(@ref, ttl, callback)); return; } else @@ -620,9 +846,72 @@ namespace IceInternal } } + private Request + getAdapterRequest(string id) + { + lock(this) + { + Request request; + if(_adapterRequests.TryGetValue(id, out request)) + { + return request; + } + + request = new AdapterRequest(this, id); + _adapterRequests.Add(id, request); + return request; + } + } + + private void + removeAdapterRequest(string id) + { + lock(this) + { + Debug.Assert(_adapterRequests.ContainsKey(id)); + _adapterRequests.Remove(id); + } + } + + private Request + getObjectRequest(Ice.Identity id) + { + lock(this) + { + Request request; + if(_objectRequests.TryGetValue(id, out request)) + { + return request; + } + + request = new ObjectRequest(this, id); + _objectRequests.Add(id, request); + return request; + } + } + + private void + removeObjectRequest(Ice.Identity id) + { + lock(this) + { + Debug.Assert(_objectRequests.ContainsKey(id)); + _objectRequests.Remove(id); + } + } + + private LocatorTable + getTable() + { + return _table; + } + private readonly Ice.LocatorPrx _locator; private Ice.LocatorRegistryPrx _locatorRegistry; private readonly LocatorTable _table; + + private Dictionary _adapterRequests = new Dictionary(); + private Dictionary _objectRequests = new Dictionary(); } public sealed class LocatorManager diff --git a/cs/test/Ice/location/AllTests.cs b/cs/test/Ice/location/AllTests.cs index 9d3cf130cfe..eeaa4945134 100644 --- a/cs/test/Ice/location/AllTests.cs +++ b/cs/test/Ice/location/AllTests.cs @@ -20,6 +20,35 @@ public class AllTests } } + class AMICallbackResponse : Test.AMI_Hello_sayHello + { + override public void + ice_exception(Ice.Exception ex) + { + test(false); + } + + override public void + ice_response() + { + } + } + + class AMICallbackException : Test.AMI_Hello_sayHello + { + override public void + ice_exception(Ice.Exception ex) + { + test(ex is Ice.NotRegisteredException); + } + + override public void + ice_response() + { + test(false); + } + } + public static void allTests(Ice.Communicator communicator) { ServerManagerPrx manager = ServerManagerPrxHelper.checkedCast( @@ -285,6 +314,26 @@ public class AllTests hello.sayHello(); Console.Out.WriteLine("ok"); + Console.Out.Write("testing locator request queuing... "); + Console.Out.Flush(); + hello = (HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false); + count = locator.getRequestCount(); + hello.ice_ping(); + test(++count == locator.getRequestCount()); + for(int i = 0; i < 1000; i++) + { + hello.sayHello_async(new AMICallbackResponse()); + } + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + count = locator.getRequestCount(); + hello = (HelloPrx)hello.ice_adapterId("unknown"); + for(int i = 0; i < 1000; i++) + { + hello.sayHello_async(new AMICallbackException()); + } + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + Console.Out.WriteLine("ok"); + Console.Out.Write("testing object migration... "); Console.Out.Flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); diff --git a/cs/test/Ice/location/Test.ice b/cs/test/Ice/location/Test.ice index b0b084746e3..6aaef0c8bc0 100644 --- a/cs/test/Ice/location/Test.ice +++ b/cs/test/Ice/location/Test.ice @@ -39,7 +39,7 @@ interface ServerManager interface Hello { - void sayHello(); + ["ami"] void sayHello(); }; interface TestIntf diff --git a/java/src/IceInternal/LocatorInfo.java b/java/src/IceInternal/LocatorInfo.java index ffec5d256c7..5e7938a3ce2 100644 --- a/java/src/IceInternal/LocatorInfo.java +++ b/java/src/IceInternal/LocatorInfo.java @@ -11,12 +11,325 @@ package IceInternal; public final class LocatorInfo { + private interface RequestCallback + { + public void response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy); + public void exception(LocatorInfo locatorInfo, Exception ex); + }; + + private abstract class Request + { + synchronized public void + addCallback(RequestCallback callback) + { + if(_response) + { + callback.response(_locatorInfo, _proxy); + return; + } + else if(_exception != null) + { + callback.exception(_locatorInfo, _exception); + return; + } + + _callbacks.add(callback); + + if(!_sent) + { + _sent = true; + try + { + send(); + } + catch(Exception ex) + { + exception(ex); + } + } + } + + synchronized public Ice.ObjectPrx + getProxy() + throws Exception + { + if(_response) + { + return _proxy; + } + else if(_exception != null) + { + throw _exception; + } + + if(!_sent) + { + _sent = true; + try + { + send(); + } + catch(Exception ex) + { + exception(ex); + } + } + + while(!_response && _exception == null) + { + try + { + wait(); + } + catch(java.lang.InterruptedException ex) + { + } + } + + if(_exception != null) + { + throw _exception; + } + assert(_response); + return _proxy; + } + + protected + Request(LocatorInfo locatorInfo) + { + _locatorInfo = locatorInfo; + _sent = false; + _response = false; + } + + synchronized protected void + response(Ice.ObjectPrx proxy) + { + _response = true; + _proxy = proxy; + for(RequestCallback c : _callbacks) + { + c.response(_locatorInfo, proxy); + } + notifyAll(); + } + + synchronized protected void + exception(Exception ex) + { + _exception = ex; + for(RequestCallback c : _callbacks) + { + c.exception(_locatorInfo, ex); + } + notifyAll(); + } + + protected abstract void send(); + + final protected LocatorInfo _locatorInfo; + + private java.util.List _callbacks = new java.util.ArrayList(); + private boolean _sent; + private boolean _response; + private Ice.ObjectPrx _proxy; + private Exception _exception; + }; + interface GetEndpointsCallback { void setEndpoints(EndpointI[] endpoints, boolean cached); void setException(Ice.LocalException ex); } + private class ObjectRequest extends Request + { + public ObjectRequest(LocatorInfo locatorInfo, Ice.Identity id) + { + super(locatorInfo); + _id = id; + } + + protected void + send() + { + _locatorInfo.getLocator().findObjectById_async( + new Ice.AMI_Locator_findObjectById() + { + public void + ice_response(Ice.ObjectPrx proxy) + { + _locatorInfo.removeObjectRequest(_id); + response(proxy); + } + + public void + ice_exception(Ice.UserException ex) + { + _locatorInfo.removeObjectRequest(_id); + exception(ex); + } + + public void + ice_exception(Ice.LocalException ex) + { + _locatorInfo.removeObjectRequest(_id); + exception(ex); + } + }, + _id); + } + + private final Ice.Identity _id; + }; + + private class AdapterRequest extends Request + { + public AdapterRequest(LocatorInfo locatorInfo, String id) + { + super(locatorInfo); + _id = id; + } + + protected void + send() + { + _locatorInfo.getLocator().findAdapterById_async( + new Ice.AMI_Locator_findAdapterById() + { + public void + ice_response(Ice.ObjectPrx proxy) + { + _locatorInfo.removeAdapterRequest(_id); + response(proxy); + } + + public void + ice_exception(Ice.UserException ex) + { + _locatorInfo.removeAdapterRequest(_id); + exception(ex); + } + + public void + ice_exception(Ice.LocalException ex) + { + _locatorInfo.removeAdapterRequest(_id); + exception(ex); + } + }, + _id); + } + + private final String _id; + }; + + private class ObjectRequestCallback implements RequestCallback + { + public void + response(LocatorInfo locatorInfo, Ice.ObjectPrx object) + { + locatorInfo.getWellKnownObjectEndpoints(_reference, object, _ttl, false, _callback); + } + + public void + exception(LocatorInfo locatorInfo, Exception ex) + { + if(ex instanceof Ice.CollocationOptimizationException) + { + try + { + Ice.BooleanHolder cached = new Ice.BooleanHolder(); + _callback.setEndpoints(locatorInfo.getEndpoints(_reference, _ttl, cached), cached.value); + } + catch(Ice.LocalException e) + { + _callback.setException(e); + } + } + else + { + locatorInfo.getEndpointsException(_reference, ex, _callback); + } + } + + public + ObjectRequestCallback(Reference ref, int ttl, GetEndpointsCallback cb) + { + _reference = ref; + _ttl = ttl; + _callback = cb; + } + + private final Reference _reference; + private final int _ttl; + private final GetEndpointsCallback _callback; + }; + + private class AdapterRequestCallback implements RequestCallback + { + public void + response(LocatorInfo locatorInfo, Ice.ObjectPrx object) + { + EndpointI[] endpoints = null; + if(object != null) + { + endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints(); + if(endpoints.length > 0) + { + locatorInfo.getTable().addAdapterEndpoints(_reference.getAdapterId(), endpoints); + } + } + + if(_reference.getInstance().traceLevels().location >= 1) + { + locatorInfo.getEndpointsTrace(_reference, endpoints, false); + } + + if(endpoints == null) + { + _callback.setEndpoints(new EndpointI[0], false); + } + else + { + _callback.setEndpoints(endpoints, false); + } + } + + public void + exception(LocatorInfo locatorInfo, Exception ex) + { + if(ex instanceof Ice.CollocationOptimizationException) + { + try + { + Ice.BooleanHolder cached = new Ice.BooleanHolder(); + _callback.setEndpoints(getEndpoints(_reference, _ttl, cached), cached.value); + } + catch(Ice.LocalException e) + { + _callback.setException(e); + } + } + else + { + getEndpointsException(_reference, ex, _callback); + } + } + + public + AdapterRequestCallback(Reference ref, int ttl, GetEndpointsCallback callback) + { + _reference = ref; + _ttl = ttl; + _callback = callback; + } + + private final Reference _reference; + private final int _ttl; + private final GetEndpointsCallback _callback; + }; + LocatorInfo(Ice.LocatorPrx locator, LocatorTable table) { _locator = locator; @@ -104,7 +417,8 @@ public final class LocatorInfo // Search the adapter in the location service if we didn't // find it in the cache. // - object = _locator.findAdapterById(adapterId); + Request request = getAdapterRequest(adapterId); + object = request.getProxy(); if(object != null) { endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints(); @@ -133,7 +447,8 @@ public final class LocatorInfo ref.getInstance().traceLevels().locationCat, s.toString()); } - object = _locator.findObjectById(identity); + Request request = getObjectRequest(identity); + object = request.getProxy(); } boolean endpointsCached = true; @@ -197,63 +512,8 @@ public final class LocatorInfo // Search the adapter in the location service if we didn't // find it in the cache. // - _locator.findAdapterById_async(new Ice.AMI_Locator_findAdapterById() - { - public void - ice_response(Ice.ObjectPrx object) - { - EndpointI[] endpoints = null; - if(object != null) - { - endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints(); - if(endpoints.length > 0) - { - _table.addAdapterEndpoints(adapterId, endpoints); - } - } - - if(instance.traceLevels().location >= 1) - { - getEndpointsTrace(ref, endpoints, false); - } - - if(endpoints == null) - { - callback.setEndpoints(new EndpointI[0], false); - } - else - { - callback.setEndpoints(endpoints, false); - } - } - - public void - ice_exception(Ice.UserException ex) - { - getEndpointsException(ref, ex, callback); - } - - public void - ice_exception(Ice.LocalException ex) - { - if(ex instanceof Ice.CollocationOptimizationException) - { - try - { - Ice.BooleanHolder cached = new Ice.BooleanHolder(); - callback.setEndpoints(getEndpoints(ref, ttl, cached), cached.value); - } - catch(Ice.LocalException e) - { - callback.setException(e); - } - } - else - { - getEndpointsException(ref, ex, callback); - } - } - }, adapterId); + Request request = getAdapterRequest(adapterId); + request.addCallback(new AdapterRequestCallback(ref, ttl, callback)); return; } else @@ -278,42 +538,9 @@ public final class LocatorInfo s.append("object = " + instance.identityToString(identity)); instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.toString()); } - - _locator.findObjectById_async(new Ice.AMI_Locator_findObjectById() - { - public void - ice_response(Ice.ObjectPrx object) - { - getWellKnownObjectEndpoints(ref, object, ttl, false, callback); - } - - public void - ice_exception(Ice.UserException ex) - { - getEndpointsException(ref, ex, callback); - } - public void - ice_exception(Ice.LocalException ex) - { - if(ex instanceof Ice.CollocationOptimizationException) - { - try - { - Ice.BooleanHolder cached = new Ice.BooleanHolder(); - callback.setEndpoints(getEndpoints(ref, ttl, cached), cached.value); - } - catch(Ice.LocalException e) - { - callback.setException(e); - } - } - else - { - getEndpointsException(ref, ex, callback); - } - } - }, identity); + Request request = getObjectRequest(identity); + request.addCallback(new ObjectRequestCallback(ref, ttl, callback)); return; } else @@ -600,7 +827,57 @@ public final class LocatorInfo } } + synchronized private Request + getAdapterRequest(String id) + { + Request request = _adapterRequests.get(id); + if(request != null) + { + return request; + } + + request = new AdapterRequest(this, id); + _adapterRequests.put(id, request); + return request; + } + + synchronized private void + removeAdapterRequest(String id) + { + assert(_adapterRequests.get(id) != null); + _adapterRequests.remove(id); + } + + synchronized private Request + getObjectRequest(Ice.Identity id) + { + Request request = _objectRequests.get(id); + if(request != null) + { + return request; + } + + request = new ObjectRequest(this, id); + _objectRequests.put(id, request); + return request; + } + + synchronized private void + removeObjectRequest(Ice.Identity id) + { + assert(_objectRequests.get(id) != null); + _objectRequests.remove(id); + } + + LocatorTable getTable() + { + return _table; + } + private final Ice.LocatorPrx _locator; private Ice.LocatorRegistryPrx _locatorRegistry; private final LocatorTable _table; + + private java.util.Map _adapterRequests = new java.util.HashMap(); + private java.util.Map _objectRequests = new java.util.HashMap(); } diff --git a/java/test/Ice/location/AllTests.java b/java/test/Ice/location/AllTests.java index 8e24f4aeea4..9ee36e75e0c 100644 --- a/java/test/Ice/location/AllTests.java +++ b/java/test/Ice/location/AllTests.java @@ -292,8 +292,56 @@ public class AllTests hello.sayHello(); System.out.println("ok"); + System.out.print("testing locator request queuing... "); + System.out.flush(); + hello = (HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false); + count = locator.getRequestCount(); + hello.ice_ping(); + test(++count == locator.getRequestCount()); + for(int i = 0; i < 1000; i++) + { + class AMICallback extends Test.AMI_Hello_sayHello + { + public void + ice_exception(Ice.LocalException ex) + { + test(false); + } + + public void + ice_response() + { + } + }; + hello.sayHello_async(new AMICallback()); + } + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + count = locator.getRequestCount(); + hello = (HelloPrx)hello.ice_adapterId("unknown"); + for(int i = 0; i < 1000; i++) + { + class AMICallback extends Test.AMI_Hello_sayHello + { + public void + ice_exception(Ice.LocalException ex) + { + test(ex instanceof Ice.NotRegisteredException); + } + + public void + ice_response() + { + test(false); + } + }; + hello.sayHello_async(new AMICallback()); + } + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + System.out.println("ok"); + System.out.print("testing proxy from server after shutdown... "); System.out.flush(); + hello = obj.getReplicatedHello(); obj.shutdown(); manager.startServer(); hello.sayHello(); diff --git a/java/test/Ice/location/Test.ice b/java/test/Ice/location/Test.ice index cff30b744e2..4291d0a7f81 100644 --- a/java/test/Ice/location/Test.ice +++ b/java/test/Ice/location/Test.ice @@ -39,7 +39,7 @@ interface ServerManager interface Hello { - void sayHello(); + ["ami"] void sayHello(); }; interface TestIntf -- cgit v1.2.3 From 497c78326d8fd4088a0f4908ec581b718f65d73c Mon Sep 17 00:00:00 2001 From: Mark Spruiell Date: Fri, 16 Jan 2009 10:51:04 -0800 Subject: bug 2545 - transformdb error handling --- cpp/src/FreezeScript/transformdb.cpp | 74 +++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 13 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp index 6b8f3cc3536..432cf673029 100644 --- a/cpp/src/FreezeScript/transformdb.cpp +++ b/cpp/src/FreezeScript/transformdb.cpp @@ -707,6 +707,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) DbEnv dbEnv(0); DbEnv dbEnvNew(0); Freeze::TransactionPtr txNew = 0; + Freeze::ConnectionPtr connectionNew = 0; vector dbs; int status = EXIT_SUCCESS; try @@ -756,7 +757,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) // // Open the catalog of the new environment, and start a transaction. // - Freeze::ConnectionPtr connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew); + connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew); txNew = connectionNew->beginTransaction(); DbTxn* txnNew = Freeze::getTxn(txNew); @@ -789,6 +790,12 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) if(txNew != 0) { txNew->rollback(); + txNew = 0; + } + if(connectionNew) + { + connectionNew->close(); + connectionNew = 0; } for(vector::iterator p = dbs.begin(); p != dbs.end(); ++p) { @@ -796,8 +803,20 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) db->close(0); delete db; } - dbEnv.close(0); - dbEnvNew.close(0); + try + { + dbEnv.close(0); + } + catch(const DbException&) + { + } + try + { + dbEnvNew.close(0); + } + catch(const DbException&) + { + } } catch(const DbException& ex) { @@ -822,13 +841,13 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) // Checkpoint to migrate changes from the log to the database(s). // dbEnvNew.txn_checkpoint(0, 0, DB_FORCE); + } - for(vector::iterator p = dbs.begin(); p != dbs.end(); ++p) - { - Db* db = *p; - db->close(0); - delete db; - } + for(vector::iterator p = dbs.begin(); p != dbs.end(); ++p) + { + Db* db = *p; + db->close(0); + delete db; } } catch(const DbException& ex) @@ -840,8 +859,27 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator) // Clear the transaction before closing the database environment. txNew = 0; - dbEnv.close(0); - dbEnvNew.close(0); + if(connectionNew) + { + connectionNew->close(); + connectionNew = 0; + } + + try + { + dbEnv.close(0); + } + catch(const DbException&) + { + } + + try + { + dbEnvNew.close(0); + } + catch(const DbException&) + { + } return status; } @@ -864,12 +902,22 @@ main(int argc, char* argv[]) { cerr << endl; } - return EXIT_FAILURE; + status = EXIT_FAILURE; } catch(const IceUtil::Exception& ex) { cerr << argv[0] << ": " << ex << endl; - return EXIT_FAILURE; + status = EXIT_FAILURE; + } + catch(const std::exception& ex) + { + cerr << argv[0] << ": " << ex.what() << endl; + status = EXIT_FAILURE; + } + catch(...) + { + cerr << argv[0] << ": unknown exception" << endl; + status = EXIT_FAILURE; } if(communicator) -- cgit v1.2.3 From 835547130d5644346a3303deee7ed52511ce2a6f Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Thu, 22 Jan 2009 10:20:46 +0100 Subject: More fixes for bug3504 and fixed bug3506 --- CHANGES | 13 + config/PropertyNames.xml | 1 + cpp/src/Ice/Instance.cpp | 2 +- cpp/src/Ice/LocatorInfo.cpp | 766 +++++++++----------- cpp/src/Ice/LocatorInfo.h | 95 +-- cpp/src/Ice/PropertyNames.cpp | 3 +- cpp/src/Ice/PropertyNames.h | 2 +- cpp/src/Ice/ProxyFactory.cpp | 6 +- cpp/test/Ice/location/AllTests.cpp | 209 +++++- cpp/test/Ice/location/ServerLocator.cpp | 21 +- cpp/test/Ice/location/TestI.cpp | 1 + cs/src/Ice/Instance.cs | 2 +- cs/src/Ice/LocatorInfo.cs | 822 +++++++++------------ cs/src/Ice/PropertyNames.cs | 3 +- cs/src/Ice/ProxyFactory.cs | 6 +- cs/test/Ice/location/AllTests.cs | 277 ++++++- cs/test/Ice/location/ServerLocatorRegistry.cs | 21 +- cs/test/Ice/location/ServerManagerI.cs | 1 + java/src/IceInternal/Instance.java | 2 +- java/src/IceInternal/LocatorInfo.java | 843 ++++++++++------------ java/src/IceInternal/LocatorManager.java | 7 +- java/src/IceInternal/LocatorTable.java | 44 +- java/src/IceInternal/PropertyNames.java | 3 +- java/src/IceInternal/ProxyFactory.java | 6 +- java/test/Ice/location/AllTests.java | 297 +++++++- java/test/Ice/location/ServerLocatorRegistry.java | 21 +- java/test/Ice/location/ServerManagerI.java | 3 +- py/test/Ice/location/Server.py | 27 +- py/test/Ice/location/Test.ice | 10 + 29 files changed, 2037 insertions(+), 1477 deletions(-) (limited to 'cpp/src') diff --git a/CHANGES b/CHANGES index 7ce9f6bc03f..ae0b8ca51fb 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,19 @@ Changes since version 3.3.0 General Changes =============== +- Added support for updating locator cache endpoints in the background + if the new Ice.BackgroundLocatorCacheUpdates property is set to 1. + + Locator cache updates are triggered if the proxy locator cache + timeout is configured and the cached endpoints are older than the + configured timeout. + + By default, locator cache updates are performed before making an + invocation, delaying the invocation until the new endpoints are + retrieved from the locator. With this feature enabled, the locator + cache updates are performed in the background and the invocation + that triggered the update uses the previously cached endpoints. + - Optimized the Ice client run time to minimize locator requests when multiple concurrent or AMI requests need to resolve the endpoints of the same well-known object, object adapter, or replica group. diff --git a/config/PropertyNames.xml b/config/PropertyNames.xml index 88b26622816..72556e5bf06 100644 --- a/config/PropertyNames.xml +++ b/config/PropertyNames.xml @@ -299,6 +299,7 @@ generated from the section label. + diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 8c7ad3ed4e8..34133c7d42d 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -966,7 +966,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi _routerManager = new RouterManager; - _locatorManager = new LocatorManager; + _locatorManager = new LocatorManager(_initData.properties); _referenceFactory = new ReferenceFactory(this, communicator); diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index 0113f80a868..a2cc09ff1af 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include using namespace std; @@ -33,168 +34,84 @@ class ObjectRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findO { public: - ObjectRequest(const LocatorInfoPtr& locatorInfo, const Ice::Identity& id) : Request(locatorInfo), _id(id) + ObjectRequest(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : Request(locatorInfo, ref) { + assert(ref->isWellKnown()); } virtual void ice_response(const Ice::ObjectPrx& proxy) { - _locatorInfo->removeObjectRequest(_id); response(proxy); } virtual void ice_exception(const Ice::Exception& ex) { - _locatorInfo->removeObjectRequest(_id); exception(ex); } - virtual void send() + virtual void send(bool async) { - _locatorInfo->getLocator()->findObjectById_async(this, _id); + try + { + if(async) + { + _locatorInfo->getLocator()->findObjectById_async(this, _ref->getIdentity()); + } + else + { + ice_response(_locatorInfo->getLocator()->findObjectById(_ref->getIdentity())); + } + } + catch(const Ice::Exception& ex) + { + ice_exception(ex); + } } - -private: - - const Ice::Identity _id; }; class AdapterRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findAdapterById { public: - AdapterRequest(const LocatorInfoPtr& locatorInfo, const string& id) : Request(locatorInfo), _id(id) + AdapterRequest(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : Request(locatorInfo, ref) { + assert(ref->isIndirect() && !ref->isWellKnown()); } virtual void ice_response(const Ice::ObjectPrx& proxy) { - _locatorInfo->removeAdapterRequest(_id); response(proxy); } virtual void ice_exception(const Ice::Exception& ex) { - _locatorInfo->removeAdapterRequest(_id); exception(ex); } - virtual void send() - { - _locatorInfo->getLocator()->findAdapterById_async(this, _id); - } - -private: - - const string _id; -}; - -class ObjectRequestCallback : public LocatorInfo::RequestCallback -{ -public: - - virtual void - response(const LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& object) + virtual void send(bool async) { - locatorInfo->getWellKnownObjectEndpoints(_reference, object, _ttl, false, _callback); - } - - virtual void - exception(const LocatorInfoPtr& locatorInfo, const Ice::Exception& ex) - { - if(dynamic_cast(&ex)) - { - try - { - bool cached; - vector endpoints = locatorInfo->getEndpoints(_reference, _ttl, cached); - _callback->setEndpoints(endpoints, cached); - } - catch(const Ice::LocalException& e) - { - _callback->setException(e); - } - } - else - { - locatorInfo->getEndpointsException(_reference, ex, _callback); - } - } - - ObjectRequestCallback(const ReferencePtr& ref, int ttl, const LocatorInfo::GetEndpointsCallbackPtr& cb) : - _reference(ref), _ttl(ttl), _callback(cb) - { - } - -private: - - const ReferencePtr _reference; - int _ttl; - const LocatorInfo::GetEndpointsCallbackPtr _callback; -}; - -class AdapterRequestCallback : public LocatorInfo::RequestCallback -{ -public: - - virtual void - response(const LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& object) - { - vector endpoints; - if(object) - { - endpoints = object->__reference()->getEndpoints(); - if(!endpoints.empty()) - { - locatorInfo->getTable()->addAdapterEndpoints(_reference->getAdapterId(), endpoints); - } - } - - if(_reference->getInstance()->traceLevels()->location >= 1) - { - locatorInfo->getEndpointsTrace(_reference, endpoints, false); - } - - _callback->setEndpoints(endpoints, false); - } - - virtual void - exception(const LocatorInfoPtr& locatorInfo, const Ice::Exception& ex) - { - if(dynamic_cast(&ex)) + try { - try + if(async) { - bool cached; - vector endpoints = locatorInfo->getEndpoints(_reference, _ttl, cached); - _callback->setEndpoints(endpoints, cached); + _locatorInfo->getLocator()->findAdapterById_async(this, _ref->getAdapterId()); } - catch(const Ice::LocalException& e) + else { - _callback->setException(e); + ice_response(_locatorInfo->getLocator()->findAdapterById(_ref->getAdapterId())); } } - else + catch(const Ice::Exception& ex) { - locatorInfo->getEndpointsException(_reference, ex, _callback); + ice_exception(ex); } } - - AdapterRequestCallback(const ReferencePtr& ref, int ttl, const LocatorInfo::GetEndpointsCallbackPtr& callback) : - _reference(ref), _ttl(ttl), _callback(callback) - { - } - -private: - - const ReferencePtr _reference; - const int _ttl; - const LocatorInfo::GetEndpointsCallbackPtr _callback; }; } -IceInternal::LocatorManager::LocatorManager() : +IceInternal::LocatorManager::LocatorManager(const Ice::PropertiesPtr& properties) : + _background(properties->getPropertyAsInt("Ice.BackgroundLocatorCacheUpdates") > 0), _tableHint(_table.end()) { } @@ -260,7 +177,8 @@ IceInternal::LocatorManager::get(const LocatorPrx& loc) _tableHint = _table.insert(_tableHint, pair(locator, - new LocatorInfo(locator, t->second))); + new LocatorInfo(locator, t->second, + _background))); } else { @@ -295,10 +213,10 @@ IceInternal::LocatorTable::getAdapterEndpoints(const string& adapter, int ttl, v map > >::iterator p = _adapterEndpointsMap.find(adapter); - if(p != _adapterEndpointsMap.end() && checkTTL(p->second.first, ttl)) + if(p != _adapterEndpointsMap.end()) { endpoints = p->second.second; - return true; + return checkTTL(p->second.first, ttl); } return false; } @@ -340,7 +258,7 @@ IceInternal::LocatorTable::removeAdapterEndpoints(const string& adapter) } bool -IceInternal::LocatorTable::getProxy(const Identity& id, int ttl, ObjectPrx& proxy) +IceInternal::LocatorTable::getObjectReference(const Identity& id, int ttl, ReferencePtr& ref) { if(ttl == 0) // No locator cache { @@ -349,47 +267,47 @@ IceInternal::LocatorTable::getProxy(const Identity& id, int ttl, ObjectPrx& prox IceUtil::Mutex::Lock sync(*this); - map >::iterator p = _objectMap.find(id); + map >::iterator p = _objectMap.find(id); - if(p != _objectMap.end() && checkTTL(p->second.first, ttl)) + if(p != _objectMap.end()) { - proxy = p->second.second; - return true; + ref = p->second.second; + return checkTTL(p->second.first, ttl); } return false; } void -IceInternal::LocatorTable::addProxy(const Identity& id, const ObjectPrx& proxy) +IceInternal::LocatorTable::addObjectReference(const Identity& id, const ReferencePtr& ref) { IceUtil::Mutex::Lock sync(*this); - map >::iterator p = _objectMap.find(id); + map >::iterator p = _objectMap.find(id); if(p != _objectMap.end()) { - p->second = make_pair(IceUtil::Time::now(IceUtil::Time::Monotonic), proxy); + p->second = make_pair(IceUtil::Time::now(IceUtil::Time::Monotonic), ref); } else { - _objectMap.insert(make_pair(id, make_pair(IceUtil::Time::now(IceUtil::Time::Monotonic), proxy))); + _objectMap.insert(make_pair(id, make_pair(IceUtil::Time::now(IceUtil::Time::Monotonic), ref))); } } -ObjectPrx -IceInternal::LocatorTable::removeProxy(const Identity& id) +ReferencePtr +IceInternal::LocatorTable::removeObjectReference(const Identity& id) { IceUtil::Mutex::Lock sync(*this); - map >::iterator p = _objectMap.find(id); + map >::iterator p = _objectMap.find(id); if(p == _objectMap.end()) { return 0; } - ObjectPrx proxy = p->second.second; + ReferencePtr ref = p->second.second; _objectMap.erase(p); - return proxy; + return ref; } bool @@ -406,83 +324,157 @@ IceInternal::LocatorTable::checkTTL(const IceUtil::Time& time, int ttl) const } } +void +IceInternal::LocatorInfo::RequestCallback::response(const LocatorInfoPtr& locatorInfo, const Ice::ObjectPrx& proxy) +{ + vector endpoints; + if(proxy) + { + ReferencePtr r = proxy->__reference(); + if(!r->isIndirect()) + { + endpoints = r->getEndpoints(); + } + else if(_ref->isWellKnown() && !r->isWellKnown()) + { + // + // We're resolving the endpoints of a well-known object and the proxy returned + // by the locator is an indirect proxy. We now need to resolve the endpoints + // of this indirect proxy. + // + locatorInfo->getEndpoints(r, _ref, _ttl, _callback); + return; + } + } + + if(_ref->getInstance()->traceLevels()->location >= 1) + { + locatorInfo->getEndpointsTrace(_ref, endpoints, false); + } + if(_callback) + { + _callback->setEndpoints(endpoints, false); + } +} + +void +IceInternal::LocatorInfo::RequestCallback::exception(const LocatorInfoPtr& locatorInfo, const Ice::Exception& exc) +{ + try + { + locatorInfo->getEndpointsException(_ref, exc); // This throws. + } + catch(const Ice::LocalException& ex) + { + if(_callback) + { + _callback->setException(ex); + } + } +} + +IceInternal::LocatorInfo::RequestCallback::RequestCallback(const ReferencePtr& ref, + int ttl, + const GetEndpointsCallbackPtr& cb) : + _ref(ref), _ttl(ttl), _callback(cb) +{ +} + void -IceInternal::LocatorInfo::Request::addCallback(const RequestCallbackPtr& callback) +IceInternal::LocatorInfo::Request::addCallback(const ReferencePtr& ref, + const ReferencePtr& wellKnownRef, + int ttl, + const GetEndpointsCallbackPtr& cb) { IceUtil::Monitor::Lock sync(_monitor); + + RequestCallbackPtr callback = new RequestCallback(ref, ttl, cb); if(_response) { callback->response(_locatorInfo, _proxy); - return; } else if(_exception.get()) { callback->exception(_locatorInfo, *_exception.get()); - return; } - - _callbacks.push_back(callback); - - if(!_sent) + else { - _sent = true; - try + _callbacks.push_back(callback); + if(wellKnownRef) // This request is to resolve the endpoints of a cached well-known object reference { - send(); + _wellKnownRefs.push_back(wellKnownRef); } - catch(const Ice::Exception& ex) + if(!_sent) { + _sent = true; sync.release(); - exception(ex); - sync.acquire(); + send(true); // send() might call exception() from this thread so we need to release the mutex. } } } -Ice::ObjectPrx -IceInternal::LocatorInfo::Request::getProxy() +vector +IceInternal::LocatorInfo::Request::getEndpoints(const ReferencePtr& ref, + const ReferencePtr& wellKnownRef, + int ttl, + bool& cached) { IceUtil::Monitor::Lock sync(_monitor); - if(_response) - { - return _proxy; - } - else if(_exception.get()) - { - _exception->ice_throw(); - return 0; // Keep the compiler happy. - } - - if(!_sent) + if(!_response || _exception.get()) { - _sent = true; - try + if(wellKnownRef) // This request is to resolve the endpoints of a cached well-known object reference { - send(); + _wellKnownRefs.push_back(wellKnownRef); } - catch(const Ice::Exception& ex) + if(!_sent) { + _sent = true; sync.release(); - exception(ex); + send(true); // send() might call exception() from this thread so we need to release the mutex. sync.acquire(); } - } - - while(!_response && !_exception.get()) - { - _monitor.wait(); + + while(!_response && !_exception.get()) + { + _monitor.wait(); + } } if(_exception.get()) { - _exception->ice_throw(); + _locatorInfo->getEndpointsException(ref, *_exception.get()); // This throws. } + assert(_response); - return _proxy; + vector endpoints; + if(_proxy) + { + ReferencePtr r = _proxy->__reference(); + if(!r->isIndirect()) + { + endpoints = r->getEndpoints(); + } + else if(ref->isWellKnown() && !r->isWellKnown()) + { + // + // We're resolving the endpoints of a well-known object and the proxy returned + // by the locator is an indirect proxy. We now need to resolve the endpoints + // of this indirect proxy. + // + return _locatorInfo->getEndpoints(r, ref, ttl, cached); + } + } + + cached = false; + if(_ref->getInstance()->traceLevels()->location >= 1) + { + _locatorInfo->getEndpointsTrace(ref, endpoints, false); + } + return endpoints; } -IceInternal::LocatorInfo::Request::Request(const LocatorInfoPtr& locatorInfo) : - _locatorInfo(locatorInfo), _sent(false), _response(false) +IceInternal::LocatorInfo::Request::Request(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : + _locatorInfo(locatorInfo), _ref(ref), _sent(false), _response(false) { } @@ -490,6 +482,7 @@ void IceInternal::LocatorInfo::Request::response(const Ice::ObjectPrx& proxy) { IceUtil::Monitor::Lock sync(_monitor); + _locatorInfo->finishRequest(_ref, _wellKnownRefs, proxy, false); _response = true; _proxy = proxy; for(vector::const_iterator p = _callbacks.begin(); p != _callbacks.end(); ++p) @@ -502,7 +495,14 @@ IceInternal::LocatorInfo::Request::response(const Ice::ObjectPrx& proxy) void IceInternal::LocatorInfo::Request::exception(const Ice::Exception& ex) { + if(dynamic_cast(&ex)) + { + send(false); // Use synchronous collocation optimized locator request instead. + return; + } + IceUtil::Monitor::Lock sync(_monitor); + _locatorInfo->finishRequest(_ref, _wellKnownRefs, 0, dynamic_cast(&ex)); _exception.reset(ex.ice_clone()); for(vector::const_iterator p = _callbacks.begin(); p != _callbacks.end(); ++p) { @@ -511,9 +511,10 @@ IceInternal::LocatorInfo::Request::exception(const Ice::Exception& ex) _monitor.notifyAll(); } -IceInternal::LocatorInfo::LocatorInfo(const LocatorPrx& locator, const LocatorTablePtr& table) : +IceInternal::LocatorInfo::LocatorInfo(const LocatorPrx& locator, const LocatorTablePtr& table, bool background) : _locator(locator), - _table(table) + _table(table), + _background(background) { assert(_locator); assert(_table); @@ -574,174 +575,116 @@ IceInternal::LocatorInfo::getLocatorRegistry() } vector -IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, bool& cached) +IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, const ReferencePtr& wellKnownRef, int ttl, bool& cached) { assert(ref->isIndirect()); vector endpoints; - ObjectPrx object; - cached = true; - try + if(!ref->isWellKnown()) { - if(!ref->isWellKnown()) + if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints)) { - if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints)) + if(_background && !endpoints.empty()) { - cached = false; - - if(ref->getInstance()->traceLevels()->location >= 1) - { - Trace out(ref->getInstance()->initializationData().logger, - ref->getInstance()->traceLevels()->locationCat); - out << "searching for adapter by id" << "\n"; - out << "adapter = " << ref->getAdapterId(); - } - - RequestPtr request = getAdapterRequest(ref->getAdapterId()); - object = request->getProxy(); - if(object) - { - endpoints = object->__reference()->getEndpoints(); - _table->addAdapterEndpoints(ref->getAdapterId(), endpoints); - } + getAdapterRequest(ref)->addCallback(ref, wellKnownRef, ttl, 0); } - } - else - { - bool objectCached = true; - if(!_table->getProxy(ref->getIdentity(), ttl, object)) + else { - if(ref->getInstance()->traceLevels()->location >= 1) - { - Trace out(ref->getInstance()->initializationData().logger, - ref->getInstance()->traceLevels()->locationCat); - out << "searching for object by id" << "\n"; - out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()); - } - - objectCached = false; - RequestPtr request = getObjectRequest(ref->getIdentity()); - object = request->getProxy(); + return getAdapterRequest(ref)->getEndpoints(ref, wellKnownRef, ttl, cached); } - - bool endpointsCached = true; - if(object) + } + } + else + { + ReferencePtr r; + if(!_table->getObjectReference(ref->getIdentity(), ttl, r)) + { + if(_background && r) { - ReferencePtr r = object->__reference(); - if(!r->isIndirect()) - { - endpointsCached = false; - endpoints = r->getEndpoints(); - } - else if(!r->isWellKnown()) - { - endpoints = getEndpoints(r, ttl, endpointsCached); - } + getObjectRequest(ref)->addCallback(ref, 0, ttl, 0); } - - if(!objectCached && !endpoints.empty()) + else { - _table->addProxy(ref->getIdentity(), object); + return getObjectRequest(ref)->getEndpoints(ref, 0, ttl, cached); } + } - cached = objectCached || endpointsCached; + if(!r->isIndirect()) + { + endpoints = r->getEndpoints(); + } + else if(!r->isWellKnown()) + { + return getEndpoints(r, ref, ttl, cached); } - } - catch(const Ice::Exception& ex) - { - getEndpointsException(ref, ex); } + assert(!endpoints.empty()); + cached = true; if(ref->getInstance()->traceLevels()->location >= 1) { - getEndpointsTrace(ref, endpoints, cached); + getEndpointsTrace(ref, endpoints, true); } - return endpoints; } void -IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, int ttl, const GetEndpointsCallbackPtr& callback) +IceInternal::LocatorInfo::getEndpoints(const ReferencePtr& ref, + const ReferencePtr& wellKnownRef, + int ttl, + const GetEndpointsCallbackPtr& callback) { assert(ref->isIndirect()); - - string adapterId = ref->getAdapterId(); - Ice::Identity identity = ref->getIdentity(); - InstancePtr instance = ref->getInstance(); - if(!adapterId.empty()) + vector endpoints; + if(!ref->isWellKnown()) { - vector endpoints; - if(!_table->getAdapterEndpoints(adapterId, ttl, endpoints)) + if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints)) { - if(instance->traceLevels()->location >= 1) + if(_background && !endpoints.empty()) { - Trace out(instance->initializationData().logger, instance->traceLevels()->locationCat); - out << "searching for adapter by id" << "\nadapter = " << adapterId; + getAdapterRequest(ref)->addCallback(ref, wellKnownRef, ttl, 0); } - - // - // Search the adapter in the location service if we didn't - // find it in the cache. - // - RequestPtr request = getAdapterRequest(adapterId); - request->addCallback(new AdapterRequestCallback(ref, ttl, callback)); - return; - } - else - { - if(instance->traceLevels()->location >= 1) + else { - getEndpointsTrace(ref, endpoints, true); + getAdapterRequest(ref)->addCallback(ref, wellKnownRef, ttl, callback); + return; } - callback->setEndpoints(endpoints, true); - return; } } else { - Ice::ObjectPrx object; - if(!_table->getProxy(identity, ttl, object)) + ReferencePtr r; + if(!_table->getObjectReference(ref->getIdentity(), ttl, r)) { - if(instance->traceLevels()->location >= 1) + if(_background && r) + { + getObjectRequest(ref)->addCallback(ref, 0, ttl, 0); + } + else { - Trace out(instance->initializationData().logger, instance->traceLevels()->locationCat); - out << "searching for object by id" << "\nobject = " << instance->identityToString(ref->getIdentity()); + getObjectRequest(ref)->addCallback(ref, 0, ttl, callback); + return; } + } - RequestPtr request = getObjectRequest(identity); - request->addCallback(new ObjectRequestCallback(ref, ttl, callback)); - return; + if(!r->isIndirect()) + { + endpoints = r->getEndpoints(); } - else + else if(!r->isWellKnown()) { - getWellKnownObjectEndpoints(ref, object, ttl, true, callback); + getEndpoints(r, ref, ttl, callback); return; } } -} -void -IceInternal::LocatorInfo::clearObjectCache(const ReferencePtr& ref) -{ - assert(ref->isIndirect()); - - if(ref->isWellKnown()) + assert(!endpoints.empty()); + if(ref->getInstance()->traceLevels()->location >= 1) { - ObjectPrx object = _table->removeProxy(ref->getIdentity()); - if(object) - { - ReferencePtr r = object->__reference(); - if(!r->isIndirect()) - { - if(ref->getInstance()->traceLevels()->location >= 2) - { - trace("removed endpoints from locator table", ref, r->getEndpoints()); - } - } - else if(!r->isWellKnown()) - { - clearCache(r); - } - } + getEndpointsTrace(ref, endpoints, true); + } + if(callback) + { + callback->setEndpoints(endpoints, true); } } @@ -761,10 +704,9 @@ IceInternal::LocatorInfo::clearCache(const ReferencePtr& ref) } else { - ObjectPrx object = _table->removeProxy(ref->getIdentity()); - if(object) + ReferencePtr r = _table->removeObjectReference(ref->getIdentity()); + if(r) { - ReferencePtr r = object->__reference(); if(!r->isIndirect()) { if(ref->getInstance()->traceLevels()->location >= 2) @@ -780,29 +722,6 @@ IceInternal::LocatorInfo::clearCache(const ReferencePtr& ref) } } -void -IceInternal::LocatorInfo::trace(const string& msg, const ReferencePtr& ref, const vector& endpoints) -{ - assert(ref->isIndirect()); - - Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat); - out << msg << '\n'; - if(!ref->isWellKnown()) - { - out << "adapter = " << ref->getAdapterId() << '\n'; - } - else - { - out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n'; - } - - const char* sep = endpoints.size() > 1 ? ":" : ""; - ostringstream o; - transform(endpoints.begin(), endpoints.end(), ostream_iterator(o, sep), - Ice::constMemFun(&Endpoint::toString)); - out << "endpoints = " << o.str(); -} - void IceInternal::LocatorInfo::getEndpointsException(const ReferencePtr& ref, const Ice::Exception& exc) { @@ -867,101 +786,9 @@ IceInternal::LocatorInfo::getEndpointsException(const ReferencePtr& ref, const I } } -void -IceInternal::LocatorInfo::getEndpointsException(const ReferencePtr& ref, const Ice::Exception& exc, - const GetEndpointsCallbackPtr& callback) -{ - try - { - getEndpointsException(ref, exc); - } - catch(const Ice::LocalException& ex) - { - callback->setException(ex); - } -} - void -IceInternal::LocatorInfo::getWellKnownObjectEndpoints(const ReferencePtr& ref, - const Ice::ObjectPrx& object, - int ttl, - bool objectCached, - const GetEndpointsCallbackPtr& callback) -{ - class Callback : public GetEndpointsCallback - { - public: - - virtual void - setEndpoints(const vector& endpoints, bool endpointsCached) - { - if(!_objectCached && !endpoints.empty()) - { - _table->addProxy(_reference->getIdentity(), _object); - } - - if(_reference->getInstance()->traceLevels()->location >= 1) - { - _locatorInfo->getEndpointsTrace(_reference, endpoints, _objectCached || endpointsCached); - } - - _callback->setEndpoints(endpoints, _objectCached || endpointsCached); - } - - virtual void - setException(const Ice::LocalException& ex) - { - _callback->setException(ex); - } - - Callback(const LocatorInfoPtr& locatorInfo, const LocatorTablePtr& table, - const ReferencePtr& reference, const Ice::ObjectPrx& object, - bool objectCached, const GetEndpointsCallbackPtr& callback) : - _locatorInfo(locatorInfo), _table(table), _reference(reference), _object(object), - _objectCached(objectCached), _callback(callback) - { - } - - private: - - const LocatorInfoPtr _locatorInfo; - const LocatorTablePtr _table; - const ReferencePtr _reference; - const Ice::ObjectPrx _object; - const bool _objectCached; - const GetEndpointsCallbackPtr _callback; - }; - - vector endpoints; - if(object) - { - ReferencePtr r = object->__reference(); - if(!r->isIndirect()) - { - endpoints = r->getEndpoints(); - } - else if(!r->isWellKnown()) - { - getEndpoints(r, ttl, new Callback(this, _table, ref, object, objectCached, callback)); - return; - } - } - - if(!objectCached && !endpoints.empty()) - { - _table->addProxy(ref->getIdentity(), object); - } - - if(ref->getInstance()->traceLevels()->location >= 1) - { - getEndpointsTrace(ref, endpoints, objectCached); - } - - callback->setEndpoints(endpoints, objectCached); -} - -void -IceInternal::LocatorInfo::getEndpointsTrace(const ReferencePtr& ref, const vector& endpoints, +IceInternal::LocatorInfo::getEndpointsTrace(const ReferencePtr& ref, + const vector& endpoints, bool cached) { if(!endpoints.empty()) @@ -992,49 +819,116 @@ IceInternal::LocatorInfo::getEndpointsTrace(const ReferencePtr& ref, const vecto } } +void +IceInternal::LocatorInfo::trace(const string& msg, const ReferencePtr& ref, const vector& endpoints) +{ + assert(ref->isIndirect()); + + Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat); + out << msg << '\n'; + if(!ref->isWellKnown()) + { + out << "adapter = " << ref->getAdapterId() << '\n'; + } + else + { + out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n'; + } + + const char* sep = endpoints.size() > 1 ? ":" : ""; + ostringstream o; + transform(endpoints.begin(), endpoints.end(), ostream_iterator(o, sep), + Ice::constMemFun(&Endpoint::toString)); + out << "endpoints = " << o.str(); +} + IceInternal::LocatorInfo::RequestPtr -IceInternal::LocatorInfo::getAdapterRequest(const string& id) +IceInternal::LocatorInfo::getAdapterRequest(const ReferencePtr& ref) { IceUtil::Mutex::Lock sync(*this); - map::const_iterator p = _adapterRequests.find(id); + if(ref->getInstance()->traceLevels()->location >= 1) + { + Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat); + out << "searching for adapter by id\nadapter = " << ref->getAdapterId(); + } + + map::const_iterator p = _adapterRequests.find(ref->getAdapterId()); if(p != _adapterRequests.end()) { return p->second; } - RequestPtr request = new AdapterRequest(this, id); - _adapterRequests.insert(make_pair(id, request)); + RequestPtr request = new AdapterRequest(this, ref); + _adapterRequests.insert(make_pair(ref->getAdapterId(), request)); return request; } -void -IceInternal::LocatorInfo::removeAdapterRequest(const string& id) -{ - IceUtil::Mutex::Lock sync(*this); - assert(_adapterRequests.find(id) != _adapterRequests.end()); - _adapterRequests.erase(id); -} - IceInternal::LocatorInfo::RequestPtr -IceInternal::LocatorInfo::getObjectRequest(const Ice::Identity& id) +IceInternal::LocatorInfo::getObjectRequest(const ReferencePtr& ref) { IceUtil::Mutex::Lock sync(*this); - map::const_iterator p = _objectRequests.find(id); + if(ref->getInstance()->traceLevels()->location >= 1) + { + Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat); + out << "searching for object by id\nobject = " << ref->getInstance()->identityToString(ref->getIdentity()); + } + + map::const_iterator p = _objectRequests.find(ref->getIdentity()); if(p != _objectRequests.end()) { return p->second; } - - RequestPtr request = new ObjectRequest(this, id); - _objectRequests.insert(make_pair(id, request)); + RequestPtr request = new ObjectRequest(this, ref); + _objectRequests.insert(make_pair(ref->getIdentity(), request)); return request; } void -IceInternal::LocatorInfo::removeObjectRequest(const Ice::Identity& id) +IceInternal::LocatorInfo::finishRequest(const ReferencePtr& ref, + const vector& wellKnownRefs, + const Ice::ObjectPrx& proxy, + bool notRegistered) { - IceUtil::Mutex::Lock sync(*this); - assert(_objectRequests.find(id) != _objectRequests.end()); - _objectRequests.erase(id); -} + if(!proxy || proxy->__reference()->isIndirect()) + { + // + // Remove the cached references of well-known objects for which we tried + // to resolved the endpoints if these endpoints are empty. + // + for(vector::const_iterator q = wellKnownRefs.begin(); q != wellKnownRefs.end(); ++q) + { + _table->removeObjectReference((*q)->getIdentity()); + } + } + + if(!ref->isWellKnown()) + { + if(proxy && !proxy->__reference()->isIndirect()) // Cache the adapter endpoints. + { + _table->addAdapterEndpoints(ref->getAdapterId(), proxy->__reference()->getEndpoints()); + } + else if(notRegistered) // If the adapter isn't registered anymore, remove it from the cache. + { + _table->removeAdapterEndpoints(ref->getAdapterId()); + } + IceUtil::Mutex::Lock sync(*this); + assert(_adapterRequests.find(ref->getAdapterId()) != _adapterRequests.end()); + _adapterRequests.erase(ref->getAdapterId()); + } + else + { + if(proxy && !proxy->__reference()->isWellKnown()) // Cache the well-known object reference. + { + _table->addObjectReference(ref->getIdentity(), proxy->__reference()); + } + else if(notRegistered) // If the well-known object isn't registered anymore, remove it from the cache. + { + _table->removeObjectReference(ref->getIdentity()); + } + + IceUtil::Mutex::Lock sync(*this); + assert(_objectRequests.find(ref->getIdentity()) != _objectRequests.end()); + _objectRequests.erase(ref->getIdentity()); + } +} diff --git a/cpp/src/Ice/LocatorInfo.h b/cpp/src/Ice/LocatorInfo.h index a4fe455a942..92b3d68dd2a 100644 --- a/cpp/src/Ice/LocatorInfo.h +++ b/cpp/src/Ice/LocatorInfo.h @@ -18,6 +18,7 @@ #include #include #include +#include namespace IceInternal { @@ -26,7 +27,7 @@ class LocatorManager : public IceUtil::Shared, public IceUtil::Mutex { public: - LocatorManager(); + LocatorManager(const Ice::PropertiesPtr&); void destroy(); @@ -38,6 +39,8 @@ public: private: + const bool _background; + std::map _table; std::map::iterator _tableHint; @@ -56,28 +59,45 @@ public: void addAdapterEndpoints(const std::string&, const ::std::vector&); ::std::vector removeAdapterEndpoints(const std::string&); - bool getProxy(const Ice::Identity&, int, Ice::ObjectPrx&); - void addProxy(const Ice::Identity&, const Ice::ObjectPrx&); - Ice::ObjectPrx removeProxy(const Ice::Identity&); + bool getObjectReference(const Ice::Identity&, int, ReferencePtr&); + void addObjectReference(const Ice::Identity&, const ReferencePtr&); + ReferencePtr removeObjectReference(const Ice::Identity&); private: bool checkTTL(const IceUtil::Time&, int) const; std::map > > _adapterEndpointsMap; - std::map > _objectMap; + std::map > _objectMap; }; class LocatorInfo : public IceUtil::Shared, public IceUtil::Mutex { public: + class GetEndpointsCallback : virtual public IceUtil::Shared + { + public: + + virtual void setEndpoints(const std::vector&, bool) = 0; + virtual void setException(const Ice::LocalException&) = 0; + }; + typedef IceUtil::Handle GetEndpointsCallbackPtr; + class RequestCallback : virtual public IceUtil::Shared { public: - virtual void response(const LocatorInfoPtr&, const Ice::ObjectPrx&) = 0; - virtual void exception(const LocatorInfoPtr&, const Ice::Exception&) = 0; + RequestCallback(const ReferencePtr&, int, const GetEndpointsCallbackPtr&); + + void response(const LocatorInfoPtr&, const Ice::ObjectPrx&); + void exception(const LocatorInfoPtr&, const Ice::Exception&); + + private: + + const ReferencePtr _ref; + const int _ttl; + const GetEndpointsCallbackPtr _callback; }; typedef IceUtil::Handle RequestCallbackPtr; @@ -85,24 +105,26 @@ public: { public: - void addCallback(const RequestCallbackPtr&); - Ice::ObjectPrx getProxy(); + void addCallback(const ReferencePtr&, const ReferencePtr&, int, const GetEndpointsCallbackPtr&); + std::vector getEndpoints(const ReferencePtr&, const ReferencePtr&, int, bool&); protected: - Request(const LocatorInfoPtr&); + Request(const LocatorInfoPtr&, const ReferencePtr&); void response(const Ice::ObjectPrx&); void exception(const Ice::Exception&); - virtual void send() = 0; + virtual void send(bool) = 0; const LocatorInfoPtr _locatorInfo; + const ReferencePtr _ref; private: IceUtil::Monitor _monitor; std::vector _callbacks; + std::vector _wellKnownRefs; bool _sent; bool _response; Ice::ObjectPrx _proxy; @@ -110,16 +132,7 @@ public: }; typedef IceUtil::Handle RequestPtr; - class GetEndpointsCallback : virtual public IceUtil::Shared - { - public: - - virtual void setEndpoints(const std::vector&, bool) = 0; - virtual void setException(const Ice::LocalException&) = 0; - }; - typedef IceUtil::Handle GetEndpointsCallbackPtr; - - LocatorInfo(const Ice::LocatorPrx&, const LocatorTablePtr&); + LocatorInfo(const Ice::LocatorPrx&, const LocatorTablePtr&, bool); void destroy(); @@ -130,36 +143,36 @@ public: Ice::LocatorPrx getLocator() const; Ice::LocatorRegistryPrx getLocatorRegistry(); - std::vector getEndpoints(const ReferencePtr&, int, bool&); - void getEndpoints(const ReferencePtr&, int, const GetEndpointsCallbackPtr&); + std::vector getEndpoints(const ReferencePtr& ref, int ttl, bool& cached) + { + return getEndpoints(ref, 0, ttl, cached); + } + void getEndpoints(const ReferencePtr& ref, int ttl, const GetEndpointsCallbackPtr& cb) + { + getEndpoints(ref, 0, ttl, cb); + } + std::vector getEndpoints(const ReferencePtr&, const ReferencePtr&, int, bool&); + void getEndpoints(const ReferencePtr&, const ReferencePtr&, int, const GetEndpointsCallbackPtr&); + void clearCache(const ReferencePtr&); - void clearObjectCache(const ReferencePtr&); - // - // The following methods need to be public for access by AMI callbacks. - // +private: + void getEndpointsException(const ReferencePtr&, const Ice::Exception&); - void getWellKnownObjectEndpoints(const ReferencePtr&, const Ice::ObjectPrx&, int, bool, - const GetEndpointsCallbackPtr&); - void getEndpointsException(const ReferencePtr&, const Ice::Exception&, const GetEndpointsCallbackPtr&); void getEndpointsTrace(const ReferencePtr&, const std::vector&, bool); + void trace(const std::string&, const ReferencePtr&, const std::vector&); - const LocatorTablePtr& getTable() { return _table; } - - RequestPtr getAdapterRequest(const std::string&); - void removeAdapterRequest(const std::string&); - - RequestPtr getObjectRequest(const Ice::Identity&); - void removeObjectRequest(const Ice::Identity&); - -private: - + RequestPtr getAdapterRequest(const ReferencePtr&); + RequestPtr getObjectRequest(const ReferencePtr&); - void trace(const std::string&, const ReferencePtr&, const std::vector&); + void finishRequest(const ReferencePtr&, const std::vector&, const Ice::ObjectPrx&, bool); + friend class Request; + friend class RequestCallback; const Ice::LocatorPrx _locator; Ice::LocatorRegistryPrx _locatorRegistry; const LocatorTablePtr _table; + const bool _background; std::map _adapterRequests; std::map _objectRequests; diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index f697540a3fd..d85fda1a87d 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Dec 23 19:01:32 2008 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Tue Jan 20 15:47:00 2009 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -35,6 +35,7 @@ const IceInternal::Property IcePropsData[] = IceInternal::Property("Ice.Admin.Facets", false, 0), IceInternal::Property("Ice.Admin.InstanceName", false, 0), IceInternal::Property("Ice.Admin.ServerId", false, 0), + IceInternal::Property("Ice.BackgroundLocatorCacheUpdates", false, 0), IceInternal::Property("Ice.BatchAutoFlush", false, 0), IceInternal::Property("Ice.ChangeUser", false, 0), IceInternal::Property("Ice.Compression.Level", false, 0), diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index e734e179526..2fd2fde2324 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Dec 23 19:01:32 2008 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Tue Jan 20 15:47:00 2009 // IMPORTANT: Do not edit this file -- any edits made here will be lost! diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp index 723442c30fa..4e5b67217fd 100644 --- a/cpp/src/Ice/ProxyFactory.cpp +++ b/cpp/src/Ice/ProxyFactory.cpp @@ -125,7 +125,11 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, // We retry ObjectNotExistException if the reference is // indirect. // - li->clearObjectCache(ref); + + if(ref->isWellKnown()) + { + li->clearCache(ref); + } } else if(ref->getRouterInfo() && one->operation == "ice_add_proxy") { diff --git a/cpp/test/Ice/location/AllTests.cpp b/cpp/test/Ice/location/AllTests.cpp index 77b8a09ec3a..1c41791f45b 100644 --- a/cpp/test/Ice/location/AllTests.cpp +++ b/cpp/test/Ice/location/AllTests.cpp @@ -34,6 +34,9 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) TestLocatorPrx locator = TestLocatorPrx::uncheckedCast(communicator->getDefaultLocator()); test(manager); + TestLocatorRegistryPrx registry = TestLocatorRegistryPrx::checkedCast(locator->getRegistry()); + test(registry); + cout << "testing stringToProxy... " << flush; Ice::ObjectPrx base = communicator->stringToProxy("test @ TestAdapter"); Ice::ObjectPrx base2 = communicator->stringToProxy("test @ TestAdapter"); @@ -302,7 +305,8 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) count = locator->getRequestCount(); hello->ice_ping(); test(++count == locator->getRequestCount()); - for(int i = 0; i < 1000; i++) + int i; + for(i = 0; i < 1000; i++) { class AMICallback : public Test::AMI_Hello_sayHello { @@ -320,10 +324,10 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) }; hello->sayHello_async(new AMICallback()); } - test(locator->getRequestCount() > count && locator->getRequestCount() < count + 100); + test(locator->getRequestCount() > count && locator->getRequestCount() < count + 500); count = locator->getRequestCount(); hello = hello->ice_adapterId("unknown"); - for(int i = 0; i < 1000; i++) + for(i = 0; i < 1000; i++) { class AMICallback : public Test::AMI_Hello_sayHello { @@ -342,7 +346,201 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) }; hello->sayHello_async(new AMICallback()); } - test(locator->getRequestCount() > count && locator->getRequestCount() < count + 100); + test(locator->getRequestCount() > count && locator->getRequestCount() < count + 500); + cout << "ok" << endl; + + cout << "testing adapter locator cache... " << flush; + + try + { + communicator->stringToProxy("test@TestAdapter3")->ice_ping(); + test(false); + } + catch(const Ice::NotRegisteredException& ex) + { + test(ex.kindOfObject == "object adapter"); + test(ex.id == "TestAdapter3"); + } + registry->setAdapterDirectProxy("TestAdapter3", locator->findAdapterById("TestAdapter")); + try + { + communicator->stringToProxy("test@TestAdapter3")->ice_ping(); + registry->setAdapterDirectProxy("TestAdapter3", communicator->stringToProxy("dummy:tcp")); + communicator->stringToProxy("test@TestAdapter3")->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + communicator->stringToProxy("test@TestAdapter3")->ice_locatorCacheTimeout(0)->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } + try + { + communicator->stringToProxy("test@TestAdapter3")->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } + registry->setAdapterDirectProxy("TestAdapter3", locator->findAdapterById("TestAdapter")); + try + { + communicator->stringToProxy("test@TestAdapter3")->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + cout << "ok" <addObject(communicator->stringToProxy("test3@TestUnknown")); + try + { + communicator->stringToProxy("test3")->ice_ping(); + test(false); + } + catch(const Ice::NotRegisteredException& ex) + { + test(ex.kindOfObject == "object adapter"); + test(ex.id == "TestUnknown"); + } + registry->addObject(communicator->stringToProxy("test3@TestAdapter4")); // Update + registry->setAdapterDirectProxy("TestAdapter4", communicator->stringToProxy("dummy:tcp")); + try + { + communicator->stringToProxy("test3")->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } + registry->setAdapterDirectProxy("TestAdapter4", locator->findAdapterById("TestAdapter")); + try + { + communicator->stringToProxy("test3")->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + registry->setAdapterDirectProxy("TestAdapter4", communicator->stringToProxy("dummy:tcp")); + try + { + communicator->stringToProxy("test3")->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + try + { + communicator->stringToProxy("test@TestAdapter4")->ice_locatorCacheTimeout(0)->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } + try + { + communicator->stringToProxy("test@TestAdapter4")->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } + try + { + communicator->stringToProxy("test3")->ice_ping(); + test(false); + } + catch(const Ice::LocalException&) + { + } + registry->addObject(communicator->stringToProxy("test3@TestAdapter")); + try + { + communicator->stringToProxy("test3")->ice_ping(); + } + catch(const Ice::LocalException&) + { + test(false); + } + + registry->addObject(communicator->stringToProxy("test4")); + try + { + communicator->stringToProxy("test4")->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + cout << "ok" << endl; + + cout << "testing locator cache background updates... " << flush; + { + Ice::InitializationData initData; + initData.properties = communicator->getProperties()->clone(); + initData.properties->setProperty("Ice.BackgroundLocatorCacheUpdates", "1"); + Ice::CommunicatorPtr ic = Ice::initialize(initData); + + registry->setAdapterDirectProxy("TestAdapter5", locator->findAdapterById("TestAdapter")); + registry->addObject(communicator->stringToProxy("test3@TestAdapter")); + + int count = locator->getRequestCount(); + ic->stringToProxy("test@TestAdapter5")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache. + ic->stringToProxy("test3")->ice_locatorCacheTimeout(0)->ice_ping(); // No locator cache. + count += 3; + test(count == locator->getRequestCount()); + registry->setAdapterDirectProxy("TestAdapter5", 0); + registry->addObject(communicator->stringToProxy("test3:tcp")); + ic->stringToProxy("test@TestAdapter5")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout. + ic->stringToProxy("test3")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout. + test(count == locator->getRequestCount()); + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(1200)); + + // The following requets should trigger the background updates but still use the cached endpoints + // and therefore succeed. + ic->stringToProxy("test@TestAdapter5")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout. + ic->stringToProxy("test3")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout. + + try + { + while(true) + { + ic->stringToProxy("test@TestAdapter5")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout. + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + } + } + catch(const Ice::LocalException&) + { + // Expected to fail once they endpoints have been updated in the background. + } + try + { + while(true) + { + ic->stringToProxy("test3")->ice_locatorCacheTimeout(1)->ice_ping(); // 1s timeout. + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(10)); + } + } + catch(const Ice::LocalException&) + { + // Expected to fail once they endpoints have been updated in the background. + } + ic->destroy(); + } cout << "ok" << endl; cout << "testing proxy from server after shutdown... " << flush; @@ -402,9 +600,6 @@ allTests(const Ice::CommunicatorPtr& communicator, const string& ref) Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "default"); adapter->setLocator(locator); - TestLocatorRegistryPrx registry = TestLocatorRegistryPrx::checkedCast(locator->getRegistry()); - test(registry); - Ice::Identity id; id.name = IceUtil::generateUUID(); registry->addObject(adapter->add(new HelloI, id)); diff --git a/cpp/test/Ice/location/ServerLocator.cpp b/cpp/test/Ice/location/ServerLocator.cpp index d7cfa342544..3221166c1e5 100644 --- a/cpp/test/Ice/location/ServerLocator.cpp +++ b/cpp/test/Ice/location/ServerLocator.cpp @@ -22,7 +22,14 @@ ServerLocatorRegistry::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistr const std::string& adapter, const ::Ice::ObjectPrx& object, const ::Ice::Current&) { - _adapters[adapter] = object; + if(!object) + { + _adapters.erase(adapter); + } + else + { + _adapters[adapter] = object; + } cb->ice_response(); } @@ -32,8 +39,16 @@ ServerLocatorRegistry::setReplicatedAdapterDirectProxy_async( const std::string& adapter, const ::std::string& replicaGroup, const ::Ice::ObjectPrx& object, const ::Ice::Current&) { - _adapters[adapter] = object; - _adapters[replicaGroup] = object; + if(!object) + { + _adapters.erase(adapter); + _adapters.erase(replicaGroup); + } + else + { + _adapters[adapter] = object; + _adapters[replicaGroup] = object; + } cb->ice_response(); } diff --git a/cpp/test/Ice/location/TestI.cpp b/cpp/test/Ice/location/TestI.cpp index a9131f5bb57..b35c819d037 100644 --- a/cpp/test/Ice/location/TestI.cpp +++ b/cpp/test/Ice/location/TestI.cpp @@ -60,6 +60,7 @@ ServerManagerI::startServer(const Ice::Current& current) Ice::ObjectPtr object = new TestI(adapter, adapter2, _registry); _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test"))); _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test2"))); + adapter->add(object, serverCommunicator->stringToIdentity("test3")); adapter->activate(); adapter2->activate(); diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs index 31e493a1b53..e849b09a7e6 100644 --- a/cs/src/Ice/Instance.cs +++ b/cs/src/Ice/Instance.cs @@ -736,7 +736,7 @@ namespace IceInternal _routerManager = new RouterManager(); - _locatorManager = new LocatorManager(); + _locatorManager = new LocatorManager(_initData.properties); _referenceFactory = new ReferenceFactory(this, communicator); diff --git a/cs/src/Ice/LocatorInfo.cs b/cs/src/Ice/LocatorInfo.cs index e7588353c3e..ed89f032a76 100644 --- a/cs/src/Ice/LocatorInfo.cs +++ b/cs/src/Ice/LocatorInfo.cs @@ -16,93 +16,172 @@ namespace IceInternal { public sealed class LocatorInfo { - private interface RequestCallback + public interface GetEndpointsCallback { - void response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy); - void exception(LocatorInfo locatorInfo, Ice.Exception ex); + void setEndpoints(EndpointI[] endpoints, bool cached); + void setException(Ice.LocalException ex); } + private class RequestCallback + { + public void + response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy) + { + EndpointI[] endpoints = null; + if(proxy != null) + { + Reference r = ((Ice.ObjectPrxHelperBase)proxy).reference__(); + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); + } + else if(_ref.isWellKnown() && !r.isWellKnown()) + { + // + // We're resolving the endpoints of a well-known object and the proxy returned + // by the locator is an indirect proxy. We now need to resolve the endpoints + // of this indirect proxy. + // + locatorInfo.getEndpoints(r, _ref, _ttl, _callback); + return; + } + } + + if(_ref.getInstance().traceLevels().location >= 1) + { + locatorInfo.getEndpointsTrace(_ref, endpoints, false); + } + if(_callback != null) + { + _callback.setEndpoints(endpoints == null ? new EndpointI[0] : endpoints, false); + } + } + + public void + exception(LocatorInfo locatorInfo, Ice.Exception exc) + { + try + { + locatorInfo.getEndpointsException(_ref, exc); // This throws. + } + catch(Ice.LocalException ex) + { + if(_callback != null) + { + _callback.setException(ex); + } + } + } + + public + RequestCallback(Reference @ref, int ttl, GetEndpointsCallback cb) + { + _ref = @ref; + _ttl = ttl; + _callback = cb; + } + + readonly Reference _ref; + readonly int _ttl; + readonly GetEndpointsCallback _callback; + }; + private abstract class Request { public void - addCallback(RequestCallback callback) + addCallback(Reference @ref, Reference wellKnownRef, int ttl, GetEndpointsCallback cb) { lock(this) { + RequestCallback callback = new RequestCallback(@ref, ttl, cb); if(_response) { callback.response(_locatorInfo, _proxy); - return; } else if(_exception != null) { callback.exception(_locatorInfo, _exception); - return; } - - _callbacks.Add(callback); - - if(!_sent) + else { - _sent = true; - try + _callbacks.Add(callback); + if(wellKnownRef != null) { - send(); + // This request is to resolve the endpoints of a cached well-known object ref + _wellKnownRefs.Add(wellKnownRef); } - catch(Ice.Exception ex) + if(!_sent) { - exception(ex); + _sent = true; + send(true); } } } } - - public Ice.ObjectPrx - getProxy() + + public EndpointI[] + getEndpoints(Reference @ref, Reference wellKnownRef, int ttl, out bool cached) { lock(this) { - if(_response) + if(!_response || _exception == null) { - return _proxy; + if(wellKnownRef != null) + { + // This request is to resolve the endpoints of a cached well-known object ref + _wellKnownRefs.Add(wellKnownRef); + } + if(!_sent) + { + _sent = true; + send(true); + } + + while(!_response && _exception == null) + { + Monitor.Wait(this); + } } - else if(_exception != null) + + if(_exception != null) { - throw _exception; + _locatorInfo.getEndpointsException(@ref, _exception); // This throws. } - - if(!_sent) + + Debug.Assert(_response); + EndpointI[] endpoints = null; + if(_proxy != null) { - _sent = true; - try + Reference r = ((Ice.ObjectPrxHelperBase)_proxy).reference__(); + if(!r.isIndirect()) { - send(); + endpoints = r.getEndpoints(); } - catch(Ice.Exception ex) + else if(@ref.isWellKnown() && !r.isWellKnown()) { - exception(ex); + // + // We're resolving the endpoints of a well-known object and the proxy returned + // by the locator is an indirect proxy. We now need to resolve the endpoints + // of this indirect proxy. + // + return _locatorInfo.getEndpoints(r, @ref, ttl, out cached); } } - - while(!_response && _exception == null) - { - Monitor.Wait(this); - } - - if(_exception != null) + + cached = false; + if(_ref.getInstance().traceLevels().location >= 1) { - throw _exception; + _locatorInfo.getEndpointsTrace(@ref, endpoints, false); } - Debug.Assert(_response); - return _proxy; + return endpoints == null ? new EndpointI[0] : endpoints; } } - - protected - Request(LocatorInfo locatorInfo) + + public Request(LocatorInfo locatorInfo, Reference @ref) { _locatorInfo = locatorInfo; - _sent = false; + _ref = @ref; + _sent = false; _response = false; } @@ -111,245 +190,154 @@ namespace IceInternal { lock(this) { + _locatorInfo.finishRequest(_ref, _wellKnownRefs, proxy, false); _response = true; _proxy = proxy; - foreach(RequestCallback c in _callbacks) + foreach(RequestCallback callback in _callbacks) { - c.response(_locatorInfo, proxy); + callback.response(_locatorInfo, proxy); } Monitor.PulseAll(this); } } - + public void exception(Ice.Exception ex) { + if(ex is Ice.CollocationOptimizationException) + { + send(false); // Use synchronous collocation optimized locator request instead. + return; + } + lock(this) { + _locatorInfo.finishRequest(_ref, _wellKnownRefs, null, ex is Ice.UserException); _exception = ex; - foreach(RequestCallback c in _callbacks) + foreach(RequestCallback callback in _callbacks) { - c.exception(_locatorInfo, ex); + callback.exception(_locatorInfo, ex); } Monitor.PulseAll(this); } } - protected abstract void send(); + protected abstract void send(bool async); - protected readonly LocatorInfo _locatorInfo; + readonly protected LocatorInfo _locatorInfo; + readonly protected Reference _ref; private List _callbacks = new List(); + private List _wellKnownRefs = new List(); private bool _sent; private bool _response; private Ice.ObjectPrx _proxy; private Ice.Exception _exception; - } + }; private class ObjectRequest : Request { private class AMICallback : Ice.AMI_Locator_findObjectById { - public AMICallback(Request request, LocatorInfo locatorInfo, Ice.Identity id) + public AMICallback(Request request) { _request = request; - _locatorInfo = locatorInfo; - _id = id; } override public void ice_response(Ice.ObjectPrx proxy) { - _locatorInfo.removeObjectRequest(_id); _request.response(proxy); } override public void ice_exception(Ice.Exception ex) { - _locatorInfo.removeObjectRequest(_id); _request.exception(ex); } private readonly Request _request; - private readonly LocatorInfo _locatorInfo; - private readonly Ice.Identity _id; } - public ObjectRequest(LocatorInfo locatorInfo, Ice.Identity id) : base(locatorInfo) + public ObjectRequest(LocatorInfo locatorInfo, Reference @ref) : base(locatorInfo, @ref) { - _id = id; } override protected void - send() + send(bool async) { - _locatorInfo.getLocator().findObjectById_async(new AMICallback(this, _locatorInfo, _id), _id); + try + { + if(async) + { + _locatorInfo.getLocator().findObjectById_async(new AMICallback(this), _ref.getIdentity()); + } + else + { + response(_locatorInfo.getLocator().findObjectById(_ref.getIdentity())); + } + } + catch(Ice.Exception ex) + { + exception(ex); + } } - - private readonly Ice.Identity _id; } private class AdapterRequest : Request { private class AMICallback : Ice.AMI_Locator_findAdapterById { - public AMICallback(Request request, LocatorInfo locatorInfo, string id) + public AMICallback(Request request) { _request = request; - _locatorInfo = locatorInfo; - _id = id; } override public void ice_response(Ice.ObjectPrx proxy) { - _locatorInfo.removeAdapterRequest(_id); _request.response(proxy); } override public void ice_exception(Ice.Exception ex) { - _locatorInfo.removeAdapterRequest(_id); _request.exception(ex); } private readonly Request _request; - private readonly LocatorInfo _locatorInfo; - private readonly string _id; } - public AdapterRequest(LocatorInfo locatorInfo, string id) : base(locatorInfo) + public AdapterRequest(LocatorInfo locatorInfo, Reference @ref) : base(locatorInfo, @ref) { - _id = id; } override protected void - send() - { - _locatorInfo.getLocator().findAdapterById_async(new AMICallback(this, _locatorInfo, _id), _id); - } - - private readonly string _id; - } - - private class ObjectRequestCallback : RequestCallback - { - public void - response(LocatorInfo locatorInfo, Ice.ObjectPrx obj) - { - locatorInfo.getWellKnownObjectEndpoints(_reference, obj, _ttl, false, _callback); - } - - public void - exception(LocatorInfo locatorInfo, Ice.Exception ex) - { - if(ex is Ice.CollocationOptimizationException) - { - try - { - bool cached; - _callback.setEndpoints(locatorInfo.getEndpoints(_reference, _ttl, out cached), cached); - } - catch(Ice.LocalException e) - { - _callback.setException(e); - } - } - else - { - locatorInfo.getEndpointsException(_reference, ex, _callback); - } - } - - public - ObjectRequestCallback(Reference @ref, int ttl, GetEndpointsCallback cb) - { - _reference = @ref; - _ttl = ttl; - _callback = cb; - } - - private readonly Reference _reference; - private readonly int _ttl; - private readonly GetEndpointsCallback _callback; - } - - private class AdapterRequestCallback : RequestCallback - { - public void - response(LocatorInfo locatorInfo, Ice.ObjectPrx obj) + send(bool async) { - EndpointI[] endpoints = null; - if(obj != null) + try { - endpoints = ((Ice.ObjectPrxHelperBase)obj).reference__().getEndpoints(); - if(endpoints.Length > 0) + if(async) { - locatorInfo.getTable().addAdapterEndpoints(_reference.getAdapterId(), endpoints); + _locatorInfo.getLocator().findAdapterById_async(new AMICallback(this), _ref.getAdapterId()); } - } - - if(_reference.getInstance().traceLevels().location >= 1) - { - locatorInfo.getEndpointsTrace(_reference, endpoints, false); - } - - if(endpoints == null) - { - _callback.setEndpoints(new EndpointI[0], false); - } - else - { - _callback.setEndpoints(endpoints, false); - } - } - - public void - exception(LocatorInfo locatorInfo, Ice.Exception ex) - { - if(ex is Ice.CollocationOptimizationException) - { - try - { - bool cached; - _callback.setEndpoints(locatorInfo.getEndpoints(_reference, _ttl, out cached), cached); - } - catch(Ice.LocalException e) + else { - _callback.setException(e); + response(_locatorInfo.getLocator().findAdapterById(_ref.getAdapterId())); } } - else + catch(Ice.Exception ex) { - locatorInfo.getEndpointsException(_reference, ex, _callback); + exception(ex); } } - - public - AdapterRequestCallback(Reference @ref, int ttl, GetEndpointsCallback callback) - { - _reference = @ref; - _ttl = ttl; - _callback = callback; - } - - private readonly Reference _reference; - private readonly int _ttl; - private readonly GetEndpointsCallback _callback; } - public interface GetEndpointsCallback - { - void setEndpoints(EndpointI[] endpoints, bool cached); - void setException(Ice.LocalException ex); - } - - internal LocatorInfo(Ice.LocatorPrx locator, LocatorTable table) + internal LocatorInfo(Ice.LocatorPrx locator, LocatorTable table, bool background) { _locator = locator; _table = table; + _background = background; } public void destroy() @@ -403,195 +391,133 @@ namespace IceInternal } } - public EndpointI[] getEndpoints(Reference @ref, int ttl, out bool cached) + public EndpointI[] + getEndpoints(Reference @ref, int ttl, out bool cached) + { + return getEndpoints(@ref, null, ttl, out cached); + } + + public EndpointI[] + getEndpoints(Reference @ref, Reference wellKnownRef, int ttl, out bool cached) { Debug.Assert(@ref.isIndirect()); - EndpointI[] endpoints = null; - Ice.ObjectPrx obj = null; - cached = true; - string adapterId = @ref.getAdapterId(); - Ice.Identity identity = @ref.getIdentity(); - - try + cached = false; + if(!@ref.isWellKnown()) { - if(!@ref.isWellKnown()) + endpoints = _table.getAdapterEndpoints(@ref.getAdapterId(), ttl, out cached); + if(!cached) { - endpoints = _table.getAdapterEndpoints(adapterId, ttl); - if(endpoints == null) + if(_background && endpoints != null) { - cached = false; - - if(@ref.getInstance().traceLevels().location >= 1) - { - System.Text.StringBuilder s = new System.Text.StringBuilder(); - s.Append("searching for adapter by id\n"); - s.Append("adapter = " + adapterId); - @ref.getInstance().initializationData().logger.trace( - @ref.getInstance().traceLevels().locationCat, s.ToString()); - } - - // - // Search the adapter in the location service if we didn't - // find it in the cache. - // - Request request = getAdapterRequest(adapterId); - obj = request.getProxy(); - if(obj != null) - { - endpoints = ((Ice.ObjectPrxHelperBase)obj).reference__().getEndpoints(); - - if(endpoints != null && endpoints.Length > 0) - { - _table.addAdapterEndpoints(adapterId, endpoints); - } - } + getAdapterRequest(@ref).addCallback(@ref, wellKnownRef, ttl, null); } - } - else - { - bool objectCached = true; - obj = _table.getProxy(identity, ttl); - if(obj == null) + else { - objectCached = false; - - if(@ref.getInstance().traceLevels().location >= 1) - { - System.Text.StringBuilder s = new System.Text.StringBuilder(); - s.Append("searching for object by id\n"); - s.Append("object = " + @ref.getInstance().identityToString(identity)); - @ref.getInstance().initializationData().logger.trace( - @ref.getInstance().traceLevels().locationCat, s.ToString()); - } - - Request request = getObjectRequest(identity); - obj = request.getProxy(); + return getAdapterRequest(@ref).getEndpoints(@ref, wellKnownRef, ttl, out cached); } - - bool endpointsCached = true; - if(obj != null) + } + } + else + { + Reference r = _table.getObjectReference(@ref.getIdentity(), ttl, out cached); + if(!cached) + { + if(_background && r != null) { - Reference r = ((Ice.ObjectPrxHelperBase)obj).reference__(); - if(!r.isIndirect()) - { - endpointsCached = false; - endpoints = r.getEndpoints(); - } - else if(!r.isWellKnown()) - { - endpoints = getEndpoints(r, ttl, out endpointsCached); - } + getObjectRequest(@ref).addCallback(@ref, null, ttl, null); } - - if(!objectCached && endpoints != null && endpoints.Length > 0) + else { - _table.addProxy(identity, obj); + return getObjectRequest(@ref).getEndpoints(@ref, null, ttl, out cached); } - - cached = objectCached || endpointsCached; + } + + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); + } + else if(!r.isWellKnown()) + { + return getEndpoints(r, @ref, ttl, out cached); } } - catch(System.Exception ex) - { - getEndpointsException(@ref, ex); - } - + + Debug.Assert(endpoints != null); + cached = true; if(@ref.getInstance().traceLevels().location >= 1) { - getEndpointsTrace(@ref, endpoints, cached); - } - - return endpoints == null ? new EndpointI[0] : endpoints; + getEndpointsTrace(@ref, endpoints, true); + } + return endpoints; } - public void getEndpoints(Reference @ref, int ttl, GetEndpointsCallback callback) + public void + getEndpoints(Reference @ref, int ttl, GetEndpointsCallback callback) + { + getEndpoints(@ref, null, ttl, callback); + } + + public void + getEndpoints(Reference @ref, Reference wellKnownRef, int ttl, GetEndpointsCallback callback) { Debug.Assert(@ref.isIndirect()); - - string adapterId = @ref.getAdapterId(); - Ice.Identity identity = @ref.getIdentity(); - Instance instance = @ref.getInstance(); + EndpointI[] endpoints = null; + bool cached = false; if(!@ref.isWellKnown()) { - EndpointI[] endpoints = _table.getAdapterEndpoints(adapterId, ttl); - if(endpoints == null) + endpoints = _table.getAdapterEndpoints(@ref.getAdapterId(), ttl, out cached); + if(!cached) { - if(instance.traceLevels().location >= 1) + if(_background && endpoints != null) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); - s.Append("searching for adapter by id\n"); - s.Append("adapter = " + adapterId); - instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); + getAdapterRequest(@ref).addCallback(@ref, wellKnownRef, ttl, null); } - - // - // Search the adapter in the location service if we didn't - // find it in the cache. - // - Request request = getAdapterRequest(adapterId); - request.addCallback(new AdapterRequestCallback(@ref, ttl, callback)); - return; - } - else - { - if(instance.traceLevels().location >= 1) + else { - getEndpointsTrace(@ref, endpoints, true); + getAdapterRequest(@ref).addCallback(@ref, wellKnownRef, ttl, callback); + return; } - callback.setEndpoints(endpoints, true); - return; } } else { - Ice.ObjectPrx obj = _table.getProxy(identity, ttl); - if(obj == null) + Reference r = _table.getObjectReference(@ref.getIdentity(), ttl, out cached); + if(!cached) { - if(instance.traceLevels().location >= 1) + if(_background && r != null) { - System.Text.StringBuilder s = new System.Text.StringBuilder(); - s.Append("searching for object by id\n"); - s.Append("object = " + instance.identityToString(identity)); - instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); + getObjectRequest(@ref).addCallback(@ref, null, ttl, null); + } + else + { + getObjectRequest(@ref).addCallback(@ref, null, ttl, callback); + return; } - - Request request = getObjectRequest(identity); - request.addCallback(new ObjectRequestCallback(@ref, ttl, callback)); - return; } - else + + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); + } + else if(!r.isWellKnown()) { - getWellKnownObjectEndpoints(@ref, obj, ttl, true, callback); + getEndpoints(r, @ref, ttl, callback); return; } } - } - - public void clearObjectCache(Reference rf) - { - Debug.Assert(rf.isIndirect()); - if(rf.getAdapterId().Length == 0) + + Debug.Assert(endpoints != null); + if(@ref.getInstance().traceLevels().location >= 1) { - Ice.ObjectPrx obj = _table.removeProxy(rf.getIdentity()); - if(obj != null) - { - Reference r = ((Ice.ObjectPrxHelperBase)obj).reference__(); - if(!r.isIndirect()) - { - if(rf.getInstance().traceLevels().location >= 2) - { - trace("removed endpoints from locator table", rf, r.getEndpoints()); - } - } - else if(!r.isWellKnown()) - { - clearCache(r); - } - } + getEndpointsTrace(@ref, endpoints, true); + } + if(callback != null) + { + callback.setEndpoints(endpoints, true); } } - + public void clearCache(Reference rf) { Debug.Assert(rf.isIndirect()); @@ -606,10 +532,9 @@ namespace IceInternal } else { - Ice.ObjectPrx obj = _table.removeProxy(rf.getIdentity()); - if(obj != null) + Reference r = _table.removeObjectReference(rf.getIdentity()); + if(r != null) { - Reference r = ((Ice.ObjectPrxHelperBase)obj).reference__(); if(!r.isIndirect()) { if(rf.getInstance().traceLevels().location >= 2) @@ -720,100 +645,6 @@ namespace IceInternal } } - private void getEndpointsException(Reference @ref, System.Exception exc, GetEndpointsCallback callback) - { - try - { - getEndpointsException(@ref, exc); - } - catch(Ice.LocalException ex) - { - callback.setException(ex); - } - catch(System.Exception) - { - Debug.Assert(false); - } - } - - private class GetWellKnownObjectEndpointsCallback : GetEndpointsCallback - { - internal GetWellKnownObjectEndpointsCallback(LocatorInfo info, Reference @ref, Ice.ObjectPrx obj, - bool objectCached, GetEndpointsCallback callback) - { - _info = info; - _ref = @ref; - _obj = obj; - _objectCached = objectCached; - _callback = callback; - } - - public void setEndpoints(EndpointI[] endpoints, bool endpointsCached) - { - if(!_objectCached && endpoints != null && endpoints.Length > 0) - { - _info._table.addProxy(_ref.getIdentity(), _obj); - } - - if(_ref.getInstance().traceLevels().location >= 1) - { - _info.getEndpointsTrace(_ref, endpoints, _objectCached || endpointsCached); - } - - _callback.setEndpoints(endpoints, _objectCached || endpointsCached); - } - - public void setException(Ice.LocalException ex) - { - _callback.setException(ex); - } - - private LocatorInfo _info; - private Reference _ref; - private Ice.ObjectPrx _obj; - private bool _objectCached; - private GetEndpointsCallback _callback; - } - - private void getWellKnownObjectEndpoints(Reference @ref, Ice.ObjectPrx obj, int ttl, - bool objectCached, GetEndpointsCallback callback) - { - EndpointI[] endpoints = null; - if(obj != null) - { - Reference r = ((Ice.ObjectPrxHelperBase)obj).reference__(); - if(!r.isIndirect()) - { - endpoints = r.getEndpoints(); - } - else if(!r.isWellKnown()) - { - getEndpoints(r, ttl, - new GetWellKnownObjectEndpointsCallback(this, @ref, obj, objectCached, callback)); - return; - } - } - - if(!objectCached && endpoints != null && endpoints.Length > 0) - { - _table.addProxy(@ref.getIdentity(), obj); - } - - if(@ref.getInstance().traceLevels().location >= 1) - { - getEndpointsTrace(@ref, endpoints, objectCached); - } - - if(endpoints == null) - { - callback.setEndpoints(new EndpointI[0], false); - } - else - { - callback.setEndpoints(endpoints, objectCached); - } - } - private void getEndpointsTrace(Reference @ref, EndpointI[] endpoints, bool cached) { if(endpoints != null && endpoints.Length > 0) @@ -847,79 +678,127 @@ namespace IceInternal } private Request - getAdapterRequest(string id) + getAdapterRequest(Reference @ref) { + if(@ref.getInstance().traceLevels().location >= 1) + { + Instance instance = @ref.getInstance(); + System.Text.StringBuilder s = new System.Text.StringBuilder(); + s.Append("searching for adapter by id\nadapter = "); + s.Append(@ref.getAdapterId()); + instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); + } + lock(this) { Request request; - if(_adapterRequests.TryGetValue(id, out request)) + if(_adapterRequests.TryGetValue(@ref.getAdapterId(), out request)) { return request; } - request = new AdapterRequest(this, id); - _adapterRequests.Add(id, request); + request = new AdapterRequest(this, @ref); + _adapterRequests.Add(@ref.getAdapterId(), request); return request; } } - private void - removeAdapterRequest(string id) + private Request + getObjectRequest(Reference @ref) { - lock(this) + if(@ref.getInstance().traceLevels().location >= 1) { - Debug.Assert(_adapterRequests.ContainsKey(id)); - _adapterRequests.Remove(id); + Instance instance = @ref.getInstance(); + System.Text.StringBuilder s = new System.Text.StringBuilder(); + s.Append("searching for object by id\nobject = "); + s.Append(instance.identityToString(@ref.getIdentity())); + instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); } - } - private Request - getObjectRequest(Ice.Identity id) - { lock(this) { Request request; - if(_objectRequests.TryGetValue(id, out request)) + if(_objectRequests.TryGetValue(@ref.getIdentity(), out request)) { return request; } - request = new ObjectRequest(this, id); - _objectRequests.Add(id, request); + request = new ObjectRequest(this, @ref); + _objectRequests.Add(@ref.getIdentity(), request); return request; } } private void - removeObjectRequest(Ice.Identity id) + finishRequest(Reference @ref, List wellKnownRefs, Ice.ObjectPrx proxy, bool notRegistered) { - lock(this) + if(proxy == null || ((Ice.ObjectPrxHelperBase)proxy).reference__().isIndirect()) { - Debug.Assert(_objectRequests.ContainsKey(id)); - _objectRequests.Remove(id); + // + // Remove the cached references of well-known objects for which we tried + // to resolved the endpoints if these endpoints are empty. + // + foreach(Reference r in wellKnownRefs) + { + _table.removeObjectReference(r.getIdentity()); + } } - } + + if(!@ref.isWellKnown()) + { + if(proxy != null && !((Ice.ObjectPrxHelperBase)proxy).reference__().isIndirect()) + { + // Cache the adapter endpoints. + _table.addAdapterEndpoints(@ref.getAdapterId(), + ((Ice.ObjectPrxHelperBase)proxy).reference__().getEndpoints()); + } + else if(notRegistered) // If the adapter isn't registered anymore, remove it from the cache. + { + _table.removeAdapterEndpoints(@ref.getAdapterId()); + } + + lock(this) + { + Debug.Assert(_adapterRequests.ContainsKey(@ref.getAdapterId())); + _adapterRequests.Remove(@ref.getAdapterId()); + } + } + else + { + if(proxy != null && !((Ice.ObjectPrxHelperBase)proxy).reference__().isWellKnown()) + { + // Cache the well-known object reference. + _table.addObjectReference(@ref.getIdentity(), ((Ice.ObjectPrxHelperBase)proxy).reference__()); + } + else if(notRegistered) // If the well-known object isn't registered anymore, remove it from the cache. + { + _table.removeObjectReference(@ref.getIdentity()); + } - private LocatorTable - getTable() - { - return _table; + lock(this) + { + Debug.Assert(_objectRequests.ContainsKey(@ref.getIdentity())); + _objectRequests.Remove(@ref.getIdentity()); + } + } } private readonly Ice.LocatorPrx _locator; private Ice.LocatorRegistryPrx _locatorRegistry; private readonly LocatorTable _table; - + private readonly bool _background; + private Dictionary _adapterRequests = new Dictionary(); private Dictionary _objectRequests = new Dictionary(); } public sealed class LocatorManager { - internal LocatorManager() + internal LocatorManager(Ice.Properties properties) { _table = new Hashtable(); _locatorTables = new Hashtable(); + _background = properties.getPropertyAsInt("Ice.BackgroundLocatorCacheUpdates") > 0; } internal void destroy() @@ -972,7 +851,7 @@ namespace IceInternal _locatorTables[locator.ice_getIdentity()] = table; } - info = new LocatorInfo(locator, table); + info = new LocatorInfo(locator, table, _background); _table[locator] = info; } @@ -982,6 +861,7 @@ namespace IceInternal private Hashtable _table; private Hashtable _locatorTables; + private readonly bool _background; } sealed class LocatorTable @@ -1001,20 +881,23 @@ namespace IceInternal } } - internal IceInternal.EndpointI[] getAdapterEndpoints(string adapter, int ttl) + internal IceInternal.EndpointI[] getAdapterEndpoints(string adapter, int ttl, out bool cached) { if(ttl == 0) // Locator cache disabled. { + cached = false; return null; } lock(this) { EndpointTableEntry entry = (EndpointTableEntry)_adapterEndpointsTable[adapter]; - if(entry != null && checkTTL(entry.time, ttl)) + if(entry != null) { + cached = checkTTL(entry.time, ttl); return entry.endpoints; } + cached = false; return null; } } @@ -1038,39 +921,42 @@ namespace IceInternal } } - internal Ice.ObjectPrx getProxy(Ice.Identity id, int ttl) + internal Reference getObjectReference(Ice.Identity id, int ttl, out bool cached) { if(ttl == 0) // Locator cache disabled. { + cached = false; return null; } lock(this) { - ProxyTableEntry entry = (ProxyTableEntry)_objectTable[id]; - if(entry != null && checkTTL(entry.time, ttl)) + ReferenceTableEntry entry = (ReferenceTableEntry)_objectTable[id]; + if(entry != null) { - return entry.proxy; + cached = checkTTL(entry.time, ttl); + return entry.reference; } + cached = false; return null; } } - internal void addProxy(Ice.Identity id, Ice.ObjectPrx proxy) + internal void addObjectReference(Ice.Identity id, Reference reference) { lock(this) { - _objectTable[id] = new ProxyTableEntry(Time.currentMonotonicTimeMillis(), proxy); + _objectTable[id] = new ReferenceTableEntry(Time.currentMonotonicTimeMillis(), reference); } } - internal Ice.ObjectPrx removeProxy(Ice.Identity id) + internal Reference removeObjectReference(Ice.Identity id) { lock(this) { - ProxyTableEntry entry = (ProxyTableEntry)_objectTable[id]; + ReferenceTableEntry entry = (ReferenceTableEntry)_objectTable[id]; _objectTable.Remove(id); - return entry != null ? entry.proxy : null; + return entry != null ? entry.reference : null; } } @@ -1099,16 +985,16 @@ namespace IceInternal public IceInternal.EndpointI[] endpoints; } - sealed private class ProxyTableEntry + sealed private class ReferenceTableEntry { - public ProxyTableEntry(long time, Ice.ObjectPrx proxy) + public ReferenceTableEntry(long time, Reference reference) { this.time = time; - this.proxy = proxy; + this.reference = reference; } public long time; - public Ice.ObjectPrx proxy; + public Reference reference; } private Hashtable _adapterEndpointsTable; diff --git a/cs/src/Ice/PropertyNames.cs b/cs/src/Ice/PropertyNames.cs index 20d1554265c..e7186a9d9d9 100644 --- a/cs/src/Ice/PropertyNames.cs +++ b/cs/src/Ice/PropertyNames.cs @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Dec 23 19:01:32 2008 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Tue Jan 20 15:47:00 2009 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -37,6 +37,7 @@ namespace IceInternal new Property(@"^Ice\.Admin\.Facets$", false, null), new Property(@"^Ice\.Admin\.InstanceName$", false, null), new Property(@"^Ice\.Admin\.ServerId$", false, null), + new Property(@"^Ice\.BackgroundLocatorCacheUpdates$", false, null), new Property(@"^Ice\.BatchAutoFlush$", false, null), new Property(@"^Ice\.ChangeUser$", false, null), new Property(@"^Ice\.Compression\.Level$", false, null), diff --git a/cs/src/Ice/ProxyFactory.cs b/cs/src/Ice/ProxyFactory.cs index da593d96f25..7525754df68 100644 --- a/cs/src/Ice/ProxyFactory.cs +++ b/cs/src/Ice/ProxyFactory.cs @@ -106,7 +106,11 @@ namespace IceInternal // We retry ObjectNotExistException if the reference is // indirect. // - li.clearObjectCache(@ref); + + if(@ref.isWellKnown()) + { + li.clearCache(@ref); + } } else if(@ref.getRouterInfo() != null && one.operation.Equals("ice_add_proxy")) { diff --git a/cs/test/Ice/location/AllTests.cs b/cs/test/Ice/location/AllTests.cs index eeaa4945134..504036cdd4f 100644 --- a/cs/test/Ice/location/AllTests.cs +++ b/cs/test/Ice/location/AllTests.cs @@ -56,6 +56,8 @@ public class AllTests test(manager != null); TestLocatorPrx locator = TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator()); test(locator != null); + TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); + test(registry != null); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); @@ -299,6 +301,7 @@ public class AllTests Console.Out.Write("testing proxy from server... "); Console.Out.Flush(); + obj = TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter")); HelloPrx hello = obj.getHello(); hello.sayHello(); test(hello.ice_getAdapterId().Equals("TestAdapter")); @@ -324,14 +327,282 @@ public class AllTests { hello.sayHello_async(new AMICallbackResponse()); } - test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 500); count = locator.getRequestCount(); hello = (HelloPrx)hello.ice_adapterId("unknown"); for(int i = 0; i < 1000; i++) { hello.sayHello_async(new AMICallbackException()); } - test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 500); + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing adapter locator cache... "); + Console.Out.Flush(); + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + test(false); + } + catch(Ice.NotRegisteredException ex) + { + test(ex.kindOfObject == "object adapter"); + test(ex.id.Equals("TestAdapter3")); + } + try + { + registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + try + { + registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + } + catch(Ice.LocalException) + { + test(false); + } + + try + { + communicator.stringToProxy("test@TestAdapter3").ice_locatorCacheTimeout(0).ice_ping(); + test(false); + } + catch(Ice.LocalException) + { + } + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + test(false); + } + catch(Ice.LocalException) + { + } + try + { + registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + } + catch(Ice.LocalException) + { + test(false); + } + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing well-known object locator cache... "); + Console.Out.Flush(); + registry.addObject(communicator.stringToProxy("test3@TestUnknown")); + try + { + communicator.stringToProxy("test3").ice_ping(); + test(false); + } + catch(Ice.NotRegisteredException ex) + { + test(ex.kindOfObject == "object adapter"); + test(ex.id.Equals("TestUnknown")); + } + registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update + try + { + registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + + try + { + communicator.stringToProxy("test3").ice_ping(); + test(false); + } + catch(Ice.LocalException) + { + } + try + { + registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + try + { + communicator.stringToProxy("test3").ice_ping(); + } + catch(Ice.LocalException) + { + test(false); + } + + try + { + registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + try + { + communicator.stringToProxy("test3").ice_ping(); + } + catch(Ice.LocalException) + { + test(false); + } + + try + { + communicator.stringToProxy("test@TestAdapter4").ice_locatorCacheTimeout(0).ice_ping(); + test(false); + } + catch(Ice.LocalException) + { + } + try + { + communicator.stringToProxy("test@TestAdapter4").ice_ping(); + test(false); + } + catch(Ice.LocalException) + { + } + try + { + communicator.stringToProxy("test3").ice_ping(); + test(false); + } + catch(Ice.LocalException) + { + } + registry.addObject(communicator.stringToProxy("test3@TestAdapter")); + try + { + communicator.stringToProxy("test3").ice_ping(); + } + catch(Ice.LocalException) + { + test(false); + } + + registry.addObject(communicator.stringToProxy("test4")); + try + { + communicator.stringToProxy("test4").ice_ping(); + test(false); + } + catch(Ice.NoEndpointException) + { + } + Console.Out.WriteLine("ok"); + + Console.Out.Write("testing locator cache background updates... "); + Console.Out.Flush(); + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = communicator.getProperties().ice_clone_(); + initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1"); + Ice.Communicator ic = Ice.Util.initialize(initData); + + try + { + registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter")); + registry.addObject(communicator.stringToProxy("test3@TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + + count = locator.getRequestCount(); + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. + ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. + count += 3; + test(count == locator.getRequestCount()); + try + { + registry.setAdapterDirectProxy("TestAdapter5", null); + } + catch(Ice.AdapterAlreadyActiveException) + { + } + catch(Ice.AdapterNotFoundException) + { + } + registry.addObject(communicator.stringToProxy("test3:tcp")); + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + test(count == locator.getRequestCount()); + System.Threading.Thread.Sleep(new System.TimeSpan(10 * 1200 * 1000)); + + // The following requets should trigger the background updates but still use the cached endpoints + // and therefore succeed. + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + + try + { + while(true) + { + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + System.Threading.Thread.Sleep(new System.TimeSpan(10 * 10 * 1000)); + } + } + catch(Ice.LocalException) + { + // Expected to fail once they endpoints have been updated in the background. + } + try + { + while(true) + { + ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + System.Threading.Thread.Sleep(new System.TimeSpan(10 * 10 * 1000)); + } + } + catch(Ice.LocalException) + { + // Expected to fail once they endpoints have been updated in the background. + } + ic.destroy(); + } Console.Out.WriteLine("ok"); Console.Out.Write("testing object migration... "); @@ -365,8 +636,6 @@ public class AllTests properties.setProperty("Ice.PrintAdapterReady", "0"); Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default"); adapter.setLocator(locator); - TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); - test(registry != null); Ice.Identity id = new Ice.Identity(); id.name = Ice.Util.generateUUID(); diff --git a/cs/test/Ice/location/ServerLocatorRegistry.cs b/cs/test/Ice/location/ServerLocatorRegistry.cs index 121f8ef037e..332a17e65e4 100644 --- a/cs/test/Ice/location/ServerLocatorRegistry.cs +++ b/cs/test/Ice/location/ServerLocatorRegistry.cs @@ -20,7 +20,14 @@ public class ServerLocatorRegistry : Test.TestLocatorRegistryDisp_ public override void setAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setAdapterDirectProxy cb, string adapter, Ice.ObjectPrx obj, Ice.Current current) { - _adapters[adapter] = obj; + if(obj != null) + { + _adapters[adapter] = obj; + } + else + { + _adapters.Remove(adapter); + } cb.ice_response(); } @@ -28,8 +35,16 @@ public class ServerLocatorRegistry : Test.TestLocatorRegistryDisp_ Ice.AMD_LocatorRegistry_setReplicatedAdapterDirectProxy cb, string adapter, string replica, Ice.ObjectPrx obj, Ice.Current current) { - _adapters[adapter] = obj; - _adapters[replica] = obj; + if(obj != null) + { + _adapters[adapter] = obj; + _adapters[replica] = obj; + } + else + { + _adapters.Remove(adapter); + _adapters.Remove(replica); + } cb.ice_response(); } diff --git a/cs/test/Ice/location/ServerManagerI.cs b/cs/test/Ice/location/ServerManagerI.cs index e3abbfcc458..51a25a24abd 100644 --- a/cs/test/Ice/location/ServerManagerI.cs +++ b/cs/test/Ice/location/ServerManagerI.cs @@ -56,6 +56,7 @@ public class ServerManagerI : ServerManagerDisp_ Ice.Object @object = new TestI(adapter, adapter2, _registry); _registry.addObject(adapter.add(@object, serverCommunicator.stringToIdentity("test"))); _registry.addObject(adapter.add(@object, serverCommunicator.stringToIdentity("test2"))); + adapter.add(@object, serverCommunicator.stringToIdentity("test3")); adapter.activate(); adapter2.activate(); diff --git a/java/src/IceInternal/Instance.java b/java/src/IceInternal/Instance.java index bf5b9831311..1764476cf1d 100644 --- a/java/src/IceInternal/Instance.java +++ b/java/src/IceInternal/Instance.java @@ -684,7 +684,7 @@ public final class Instance _routerManager = new RouterManager(); - _locatorManager = new LocatorManager(); + _locatorManager = new LocatorManager(_initData.properties); _referenceFactory = new ReferenceFactory(this, communicator); diff --git a/java/src/IceInternal/LocatorInfo.java b/java/src/IceInternal/LocatorInfo.java index 5e7938a3ce2..bcf28e5865d 100644 --- a/java/src/IceInternal/LocatorInfo.java +++ b/java/src/IceInternal/LocatorInfo.java @@ -11,329 +11,324 @@ package IceInternal; public final class LocatorInfo { - private interface RequestCallback + interface GetEndpointsCallback { - public void response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy); - public void exception(LocatorInfo locatorInfo, Exception ex); - }; + void setEndpoints(EndpointI[] endpoints, boolean cached); + void setException(Ice.LocalException ex); + } - private abstract class Request + private class RequestCallback { - synchronized public void - addCallback(RequestCallback callback) + public void + response(LocatorInfo locatorInfo, Ice.ObjectPrx proxy) { - if(_response) + EndpointI[] endpoints = null; + if(proxy != null) { - callback.response(_locatorInfo, _proxy); - return; + Reference r = ((Ice.ObjectPrxHelperBase)proxy).__reference(); + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); + } + else if(_ref.isWellKnown() && !r.isWellKnown()) + { + // + // We're resolving the endpoints of a well-known object and the proxy returned + // by the locator is an indirect proxy. We now need to resolve the endpoints + // of this indirect proxy. + // + locatorInfo.getEndpoints(r, _ref, _ttl, _callback); + return; + } } - else if(_exception != null) + + if(_ref.getInstance().traceLevels().location >= 1) { - callback.exception(_locatorInfo, _exception); - return; + locatorInfo.getEndpointsTrace(_ref, endpoints, false); } + if(_callback != null) + { + _callback.setEndpoints(endpoints == null ? new EndpointI[0] : endpoints, false); + } + } - _callbacks.add(callback); - - if(!_sent) + public void + exception(LocatorInfo locatorInfo, Exception exc) + { + try { - _sent = true; - try - { - send(); - } - catch(Exception ex) + locatorInfo.getEndpointsException(_ref, exc); // This throws. + } + catch(Ice.LocalException ex) + { + if(_callback != null) { - exception(ex); + _callback.setException(ex); } } } - synchronized public Ice.ObjectPrx - getProxy() - throws Exception + RequestCallback(Reference ref, int ttl, GetEndpointsCallback cb) + { + _ref = ref; + _ttl = ttl; + _callback = cb; + } + + final Reference _ref; + final int _ttl; + final GetEndpointsCallback _callback; + }; + + private abstract class Request + { + synchronized public void + addCallback(Reference ref, Reference wellKnownRef, int ttl, GetEndpointsCallback cb) { + RequestCallback callback = new RequestCallback(ref, ttl, cb); if(_response) { - return _proxy; + callback.response(_locatorInfo, _proxy); } else if(_exception != null) { - throw _exception; + callback.exception(_locatorInfo, _exception); } - - if(!_sent) + else { - _sent = true; - try + _callbacks.add(callback); + if(wellKnownRef != null) // This request is to resolve the endpoints of a cached well-known object ref { - send(); + _wellKnownRefs.add(wellKnownRef); } - catch(Exception ex) + if(!_sent) { - exception(ex); + _sent = true; + send(true); } } - - while(!_response && _exception == null) + } + + synchronized EndpointI[] + getEndpoints(Reference ref, Reference wellKnownRef, int ttl, Ice.BooleanHolder cached) + { + if(!_response || _exception == null) { - try + if(wellKnownRef != null) // This request is to resolve the endpoints of a cached well-known object ref { - wait(); + _wellKnownRefs.add(wellKnownRef); } - catch(java.lang.InterruptedException ex) + if(!_sent) { + _sent = true; + send(true); + } + + while(!_response && _exception == null) + { + try + { + wait(); + } + catch(java.lang.InterruptedException ex) + { + } } } - + if(_exception != null) { - throw _exception; + _locatorInfo.getEndpointsException(ref, _exception); // This throws. } + assert(_response); - return _proxy; + EndpointI[] endpoints = null; + if(_proxy != null) + { + Reference r = ((Ice.ObjectPrxHelperBase)_proxy).__reference(); + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); + } + else if(ref.isWellKnown() && !r.isWellKnown()) + { + // + // We're resolving the endpoints of a well-known object and the proxy returned + // by the locator is an indirect proxy. We now need to resolve the endpoints + // of this indirect proxy. + // + return _locatorInfo.getEndpoints(r, ref, ttl, cached); + } + } + + cached.value = false; + if(_ref.getInstance().traceLevels().location >= 1) + { + _locatorInfo.getEndpointsTrace(ref, endpoints, false); + } + return endpoints == null ? new EndpointI[0] : endpoints; } - - protected - Request(LocatorInfo locatorInfo) + + Request(LocatorInfo locatorInfo, Reference ref) { _locatorInfo = locatorInfo; - _sent = false; + _ref = ref; + _sent = false; _response = false; } synchronized protected void response(Ice.ObjectPrx proxy) { + _locatorInfo.finishRequest(_ref, _wellKnownRefs, proxy, false); _response = true; _proxy = proxy; - for(RequestCallback c : _callbacks) + for(RequestCallback callback : _callbacks) { - c.response(_locatorInfo, proxy); + callback.response(_locatorInfo, proxy); } notifyAll(); } - synchronized protected void + protected void exception(Exception ex) { - _exception = ex; - for(RequestCallback c : _callbacks) + if(ex instanceof Ice.CollocationOptimizationException) + { + send(false); // Use synchronous collocation optimized locator request instead. + return; + } + + synchronized(this) { - c.exception(_locatorInfo, ex); + _locatorInfo.finishRequest(_ref, _wellKnownRefs, null, ex instanceof Ice.UserException); + _exception = ex; + for(RequestCallback callback : _callbacks) + { + callback.exception(_locatorInfo, ex); + } + notifyAll(); } - notifyAll(); } - protected abstract void send(); + protected abstract void send(boolean async); final protected LocatorInfo _locatorInfo; + final protected Reference _ref; private java.util.List _callbacks = new java.util.ArrayList(); + private java.util.List _wellKnownRefs = new java.util.ArrayList(); private boolean _sent; private boolean _response; private Ice.ObjectPrx _proxy; private Exception _exception; }; - interface GetEndpointsCallback - { - void setEndpoints(EndpointI[] endpoints, boolean cached); - void setException(Ice.LocalException ex); - } - private class ObjectRequest extends Request { - public ObjectRequest(LocatorInfo locatorInfo, Ice.Identity id) + public ObjectRequest(LocatorInfo locatorInfo, Reference reference) { - super(locatorInfo); - _id = id; + super(locatorInfo, reference); + assert(reference.isWellKnown()); } protected void - send() + send(boolean async) { - _locatorInfo.getLocator().findObjectById_async( - new Ice.AMI_Locator_findObjectById() - { - public void - ice_response(Ice.ObjectPrx proxy) - { - _locatorInfo.removeObjectRequest(_id); - response(proxy); - } - - public void - ice_exception(Ice.UserException ex) - { - _locatorInfo.removeObjectRequest(_id); - exception(ex); - } - - public void - ice_exception(Ice.LocalException ex) - { - _locatorInfo.removeObjectRequest(_id); - exception(ex); - } - }, - _id); - } - - private final Ice.Identity _id; - }; - - private class AdapterRequest extends Request - { - public AdapterRequest(LocatorInfo locatorInfo, String id) - { - super(locatorInfo); - _id = id; - } - - protected void - send() - { - _locatorInfo.getLocator().findAdapterById_async( - new Ice.AMI_Locator_findAdapterById() - { - public void - ice_response(Ice.ObjectPrx proxy) - { - _locatorInfo.removeAdapterRequest(_id); - response(proxy); - } - - public void - ice_exception(Ice.UserException ex) - { - _locatorInfo.removeAdapterRequest(_id); - exception(ex); - } - - public void - ice_exception(Ice.LocalException ex) - { - _locatorInfo.removeAdapterRequest(_id); - exception(ex); - } - }, - _id); - } - - private final String _id; - }; - - private class ObjectRequestCallback implements RequestCallback - { - public void - response(LocatorInfo locatorInfo, Ice.ObjectPrx object) - { - locatorInfo.getWellKnownObjectEndpoints(_reference, object, _ttl, false, _callback); - } - - public void - exception(LocatorInfo locatorInfo, Exception ex) - { - if(ex instanceof Ice.CollocationOptimizationException) + try { - try + if(async) { - Ice.BooleanHolder cached = new Ice.BooleanHolder(); - _callback.setEndpoints(locatorInfo.getEndpoints(_reference, _ttl, cached), cached.value); + _locatorInfo.getLocator().findObjectById_async( + new Ice.AMI_Locator_findObjectById() + { + public void + ice_response(Ice.ObjectPrx proxy) + { + response(proxy); + } + + public void + ice_exception(Ice.UserException ex) + { + exception(ex); + } + + public void + ice_exception(Ice.LocalException ex) + { + exception(ex); + } + }, + _ref.getIdentity()); } - catch(Ice.LocalException e) + else { - _callback.setException(e); + response(_locatorInfo.getLocator().findObjectById(_ref.getIdentity())); } } - else + catch(Exception ex) { - locatorInfo.getEndpointsException(_reference, ex, _callback); + exception(ex); } } - - public - ObjectRequestCallback(Reference ref, int ttl, GetEndpointsCallback cb) - { - _reference = ref; - _ttl = ttl; - _callback = cb; - } - - private final Reference _reference; - private final int _ttl; - private final GetEndpointsCallback _callback; }; - private class AdapterRequestCallback implements RequestCallback + private class AdapterRequest extends Request { - public void - response(LocatorInfo locatorInfo, Ice.ObjectPrx object) + public AdapterRequest(LocatorInfo locatorInfo, Reference reference) { - EndpointI[] endpoints = null; - if(object != null) - { - endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints(); - if(endpoints.length > 0) - { - locatorInfo.getTable().addAdapterEndpoints(_reference.getAdapterId(), endpoints); - } - } - - if(_reference.getInstance().traceLevels().location >= 1) - { - locatorInfo.getEndpointsTrace(_reference, endpoints, false); - } - - if(endpoints == null) - { - _callback.setEndpoints(new EndpointI[0], false); - } - else - { - _callback.setEndpoints(endpoints, false); - } + super(locatorInfo, reference); + assert(reference.isIndirect()); } - - public void - exception(LocatorInfo locatorInfo, Exception ex) + + protected void + send(boolean async) { - if(ex instanceof Ice.CollocationOptimizationException) + try { - try + if(async) { - Ice.BooleanHolder cached = new Ice.BooleanHolder(); - _callback.setEndpoints(getEndpoints(_reference, _ttl, cached), cached.value); + _locatorInfo.getLocator().findAdapterById_async( + new Ice.AMI_Locator_findAdapterById() + { + public void + ice_response(Ice.ObjectPrx proxy) + { + response(proxy); + } + + public void + ice_exception(Ice.UserException ex) + { + exception(ex); + } + + public void + ice_exception(Ice.LocalException ex) + { + exception(ex); + } + }, + _ref.getAdapterId()); } - catch(Ice.LocalException e) + else { - _callback.setException(e); + response(_locatorInfo.getLocator().findAdapterById(_ref.getAdapterId())); } } - else + catch(Exception ex) { - getEndpointsException(_reference, ex, _callback); + exception(ex); } } - - public - AdapterRequestCallback(Reference ref, int ttl, GetEndpointsCallback callback) - { - _reference = ref; - _ttl = ttl; - _callback = callback; - } - - private final Reference _reference; - private final int _ttl; - private final GetEndpointsCallback _callback; }; - LocatorInfo(Ice.LocatorPrx locator, LocatorTable table) + LocatorInfo(Ice.LocatorPrx locator, LocatorTable table, boolean background) { _locator = locator; _table = table; + _background = background; } synchronized public void @@ -387,195 +382,130 @@ public final class LocatorInfo public EndpointI[] getEndpoints(Reference ref, int ttl, Ice.BooleanHolder cached) { - assert(ref.isIndirect()); + return getEndpoints(ref, null, ttl, cached); + } + public EndpointI[] + getEndpoints(Reference ref, Reference wellKnownRef, int ttl, Ice.BooleanHolder cached) + { + assert(ref.isIndirect()); EndpointI[] endpoints = null; - Ice.ObjectPrx object = null; - cached.value = true; - String adapterId = ref.getAdapterId(); - Ice.Identity identity = ref.getIdentity(); - - try + cached.value = false; + if(!ref.isWellKnown()) { - if(adapterId.length() > 0) + endpoints = _table.getAdapterEndpoints(ref.getAdapterId(), ttl, cached); + if(!cached.value) { - endpoints = _table.getAdapterEndpoints(adapterId, ttl); - if(endpoints == null) + if(_background && endpoints != null) { - cached.value = false; - - if(ref.getInstance().traceLevels().location >= 1) - { - StringBuffer s = new StringBuffer(); - s.append("searching for adapter by id\n"); - s.append("adapter = " + adapterId); - ref.getInstance().initializationData().logger.trace( - ref.getInstance().traceLevels().locationCat, s.toString()); - } - - // - // Search the adapter in the location service if we didn't - // find it in the cache. - // - Request request = getAdapterRequest(adapterId); - object = request.getProxy(); - if(object != null) - { - endpoints = ((Ice.ObjectPrxHelperBase)object).__reference().getEndpoints(); - - if(endpoints.length > 0) - { - _table.addAdapterEndpoints(adapterId, endpoints); - } - } + getAdapterRequest(ref).addCallback(ref, wellKnownRef, ttl, null); } - } - else - { - boolean objectCached = true; - object = _table.getProxy(identity, ttl); - if(object == null) + else { - objectCached = false; - - if(ref.getInstance().traceLevels().location >= 1) - { - StringBuffer s = new StringBuffer(); - s.append("searching for object by id\n"); - s.append("object = " + ref.getInstance().identityToString(identity)); - ref.getInstance().initializationData().logger.trace( - ref.getInstance().traceLevels().locationCat, s.toString()); - } - - Request request = getObjectRequest(identity); - object = request.getProxy(); + return getAdapterRequest(ref).getEndpoints(ref, wellKnownRef, ttl, cached); } - - boolean endpointsCached = true; - if(object != null) + } + } + else + { + Reference r = _table.getObjectReference(ref.getIdentity(), ttl, cached); + if(!cached.value) + { + if(_background && r != null) { - Reference r = ((Ice.ObjectPrxHelperBase)object).__reference(); - if(!r.isIndirect()) - { - endpointsCached = false; - endpoints = r.getEndpoints(); - } - else if(!r.isWellKnown()) - { - Ice.BooleanHolder c = new Ice.BooleanHolder(); - endpoints = getEndpoints(r, ttl, c); - endpointsCached = c.value; - } + getObjectRequest(ref).addCallback(ref, null, ttl, null); } - - if(!objectCached && endpoints != null && endpoints.length > 0) + else { - _table.addProxy(identity, object); + return getObjectRequest(ref).getEndpoints(ref, null, ttl, cached); } - - cached.value = objectCached || endpointsCached; + } + + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); + } + else if(!r.isWellKnown()) + { + return getEndpoints(r, ref, ttl, cached); } } - catch(Exception ex) - { - getEndpointsException(ref, ex); - } - + + assert(endpoints != null); + cached.value = true; if(ref.getInstance().traceLevels().location >= 1) { - getEndpointsTrace(ref, endpoints, cached.value); + getEndpointsTrace(ref, endpoints, true); } + return endpoints; + } - return endpoints == null ? new EndpointI[0] : endpoints; + public void + getEndpoints(Reference ref, int ttl, GetEndpointsCallback callback) + { + getEndpoints(ref, null, ttl, callback); } public void - getEndpoints(final Reference ref, final int ttl, final GetEndpointsCallback callback) + getEndpoints(Reference ref, Reference wellKnownRef, int ttl, GetEndpointsCallback callback) { - final String adapterId = ref.getAdapterId(); - final Ice.Identity identity = ref.getIdentity(); - final Instance instance = ref.getInstance(); - if(adapterId.length() > 0) + assert(ref.isIndirect()); + EndpointI[] endpoints = null; + Ice.BooleanHolder cached = new Ice.BooleanHolder(); + if(!ref.isWellKnown()) { - EndpointI[] endpoints = _table.getAdapterEndpoints(adapterId, ttl); - if(endpoints == null) + endpoints = _table.getAdapterEndpoints(ref.getAdapterId(), ttl, cached); + if(!cached.value) { - if(instance.traceLevels().location >= 1) + if(_background && endpoints != null) { - StringBuffer s = new StringBuffer(); - s.append("searching for adapter by id\n"); - s.append("adapter = " + adapterId); - instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.toString()); + getAdapterRequest(ref).addCallback(ref, wellKnownRef, ttl, null); } - - // - // Search the adapter in the location service if we didn't - // find it in the cache. - // - Request request = getAdapterRequest(adapterId); - request.addCallback(new AdapterRequestCallback(ref, ttl, callback)); - return; - } - else - { - if(instance.traceLevels().location >= 1) + else { - getEndpointsTrace(ref, endpoints, true); + getAdapterRequest(ref).addCallback(ref, wellKnownRef, ttl, callback); + return; } - callback.setEndpoints(endpoints, true); - return; } } else { - Ice.ObjectPrx object = _table.getProxy(identity, ttl); - if(object == null) + Reference r = _table.getObjectReference(ref.getIdentity(), ttl, cached); + if(!cached.value) { - if(instance.traceLevels().location >= 1) + if(_background && r != null) { - StringBuffer s = new StringBuffer(); - s.append("searching for object by id\n"); - s.append("object = " + instance.identityToString(identity)); - instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.toString()); + getObjectRequest(ref).addCallback(ref, null, ttl, null); } + else + { + getObjectRequest(ref).addCallback(ref, null, ttl, callback); + return; + } + } - Request request = getObjectRequest(identity); - request.addCallback(new ObjectRequestCallback(ref, ttl, callback)); - return; + if(!r.isIndirect()) + { + endpoints = r.getEndpoints(); } - else + else if(!r.isWellKnown()) { - getWellKnownObjectEndpoints(ref, object, ttl, true, callback); + getEndpoints(r, ref, ttl, callback); return; } } - } - public void - clearObjectCache(Reference ref) - { - assert(ref.isIndirect()); - if(ref.isWellKnown()) + assert(endpoints != null); + if(ref.getInstance().traceLevels().location >= 1) { - Ice.ObjectPrx object = _table.removeProxy(ref.getIdentity()); - if(object != null) - { - Reference r = ((Ice.ObjectPrxHelperBase)object).__reference(); - if(!r.isIndirect()) - { - if(ref.getInstance().traceLevels().location >= 2) - { - trace("removed endpoints from locator table", ref, r.getEndpoints()); - } - } - else if(!r.isWellKnown()) - { - clearCache(r); - } - } + getEndpointsTrace(ref, endpoints, true); + } + if(callback != null) + { + callback.setEndpoints(endpoints, true); } } - + public void clearCache(Reference ref) { @@ -592,10 +522,9 @@ public final class LocatorInfo } else { - Ice.ObjectPrx object = _table.removeProxy(ref.getIdentity()); - if(object != null) + Reference r = _table.removeObjectReference(ref.getIdentity()); + if(r != null) { - Reference r = ((Ice.ObjectPrxHelperBase)object).__reference(); if(!r.isIndirect()) { if(ref.getInstance().traceLevels().location >= 2) @@ -712,88 +641,6 @@ public final class LocatorInfo } } - private void - getEndpointsException(Reference ref, Exception exc, GetEndpointsCallback callback) - { - try - { - getEndpointsException(ref, exc); - } - catch(Ice.LocalException ex) - { - callback.setException(ex); - } - catch(Exception ex) - { - assert(false); - } - } - - private void - getWellKnownObjectEndpoints(final Reference ref, - final Ice.ObjectPrx object, - final int ttl, - final boolean objectCached, - final GetEndpointsCallback callback) - { - EndpointI[] endpoints = null; - if(object != null) - { - Reference r = ((Ice.ObjectPrxHelperBase)object).__reference(); - if(!r.isIndirect()) - { - endpoints = r.getEndpoints(); - } - else if(!r.isWellKnown()) - { - getEndpoints(r, ttl, new GetEndpointsCallback() - { - public void - setEndpoints(EndpointI[] endpoints, boolean endpointsCached) - { - if(!objectCached && endpoints != null && endpoints.length > 0) - { - _table.addProxy(ref.getIdentity(), object); - } - - if(ref.getInstance().traceLevels().location >= 1) - { - getEndpointsTrace(ref, endpoints, objectCached || endpointsCached); - } - - callback.setEndpoints(endpoints, objectCached || endpointsCached); - } - - public void - setException(Ice.LocalException ex) - { - callback.setException(ex); - } - }); - return; - } - } - - if(!objectCached && endpoints != null && endpoints.length > 0) - { - _table.addProxy(ref.getIdentity(), object); - } - - if(ref.getInstance().traceLevels().location >= 1) - { - getEndpointsTrace(ref, endpoints, objectCached); - } - - if(endpoints == null) - { - callback.setEndpoints(new EndpointI[0], false); - } - else - { - callback.setEndpoints(endpoints, objectCached); - } - } - private void getEndpointsTrace(Reference ref, EndpointI[] endpoints, boolean cached) { @@ -828,55 +675,107 @@ public final class LocatorInfo } synchronized private Request - getAdapterRequest(String id) + getAdapterRequest(Reference ref) { - Request request = _adapterRequests.get(id); + if(ref.getInstance().traceLevels().location >= 1) + { + Instance instance = ref.getInstance(); + StringBuffer s = new StringBuffer(); + s.append("searching for adapter by id\nadapter="); + s.append(ref.getAdapterId()); + instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.toString()); + } + + Request request = _adapterRequests.get(ref.getAdapterId()); if(request != null) { return request; } - - request = new AdapterRequest(this, id); - _adapterRequests.put(id, request); + request = new AdapterRequest(this, ref); + _adapterRequests.put(ref.getAdapterId(), request); return request; } - synchronized private void - removeAdapterRequest(String id) - { - assert(_adapterRequests.get(id) != null); - _adapterRequests.remove(id); - } - synchronized private Request - getObjectRequest(Ice.Identity id) + getObjectRequest(Reference ref) { - Request request = _objectRequests.get(id); + if(ref.getInstance().traceLevels().location >= 1) + { + Instance instance = ref.getInstance(); + StringBuffer s = new StringBuffer(); + s.append("searching for object by id\nobject = "); + s.append(instance.identityToString(ref.getIdentity())); + instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.toString()); + } + + Request request = _objectRequests.get(ref.getIdentity()); if(request != null) { return request; } - - request = new ObjectRequest(this, id); - _objectRequests.put(id, request); + request = new ObjectRequest(this, ref); + _objectRequests.put(ref.getIdentity(), request); return request; } - synchronized private void - removeObjectRequest(Ice.Identity id) + private void + finishRequest(Reference ref, java.util.List wellKnownRefs, Ice.ObjectPrx proxy, boolean notRegistered) { - assert(_objectRequests.get(id) != null); - _objectRequests.remove(id); - } + if(proxy == null || ((Ice.ObjectPrxHelperBase)proxy).__reference().isIndirect()) + { + // + // Remove the cached references of well-known objects for which we tried + // to resolved the endpoints if these endpoints are empty. + // + for(Reference r : wellKnownRefs) + { + _table.removeObjectReference(r.getIdentity()); + } + } + + if(!ref.isWellKnown()) + { + if(proxy != null && !((Ice.ObjectPrxHelperBase)proxy).__reference().isIndirect()) + { + // Cache the adapter endpoints. + _table.addAdapterEndpoints(ref.getAdapterId(), + ((Ice.ObjectPrxHelperBase)proxy).__reference().getEndpoints()); + } + else if(notRegistered) // If the adapter isn't registered anymore, remove it from the cache. + { + _table.removeAdapterEndpoints(ref.getAdapterId()); + } + + synchronized(this) + { + assert(_adapterRequests.get(ref.getAdapterId()) != null); + _adapterRequests.remove(ref.getAdapterId()); + } + } + else + { + if(proxy != null && !((Ice.ObjectPrxHelperBase)proxy).__reference().isWellKnown()) + { + // Cache the well-known object reference. + _table.addObjectReference(ref.getIdentity(), ((Ice.ObjectPrxHelperBase)proxy).__reference()); + } + else if(notRegistered) // If the well-known object isn't registered anymore, remove it from the cache. + { + _table.removeObjectReference(ref.getIdentity()); + } - LocatorTable getTable() - { - return _table; + synchronized(this) + { + assert(_objectRequests.get(ref.getIdentity()) != null); + _objectRequests.remove(ref.getIdentity()); + } + } } - + private final Ice.LocatorPrx _locator; private Ice.LocatorRegistryPrx _locatorRegistry; private final LocatorTable _table; + private final boolean _background; private java.util.Map _adapterRequests = new java.util.HashMap(); private java.util.Map _objectRequests = new java.util.HashMap(); diff --git a/java/src/IceInternal/LocatorManager.java b/java/src/IceInternal/LocatorManager.java index edf188ab173..61e3a4b9512 100644 --- a/java/src/IceInternal/LocatorManager.java +++ b/java/src/IceInternal/LocatorManager.java @@ -11,8 +11,9 @@ package IceInternal; public final class LocatorManager { - LocatorManager() + LocatorManager(Ice.Properties properties) { + _background = properties.getPropertyAsInt("Ice.BackgroundLocatorCacheUpdates") > 0; } synchronized void @@ -66,7 +67,7 @@ public final class LocatorManager _locatorTables.put(locator.ice_getIdentity(), table); } - info = new LocatorInfo(locator, table); + info = new LocatorInfo(locator, table, _background); _table.put(locator, info); } @@ -74,6 +75,8 @@ public final class LocatorManager } } + final private boolean _background; + private java.util.HashMap _table = new java.util.HashMap(); private java.util.HashMap _locatorTables = diff --git a/java/src/IceInternal/LocatorTable.java b/java/src/IceInternal/LocatorTable.java index db07eabf107..a2fe5a7580c 100644 --- a/java/src/IceInternal/LocatorTable.java +++ b/java/src/IceInternal/LocatorTable.java @@ -23,18 +23,21 @@ final class LocatorTable } synchronized IceInternal.EndpointI[] - getAdapterEndpoints(String adapter, int ttl) + getAdapterEndpoints(String adapter, int ttl, Ice.BooleanHolder cached) { if(ttl == 0) // Locator cache disabled. { + cached.value = false; return null; } EndpointTableEntry entry = _adapterEndpointsTable.get(adapter); - if(entry != null && checkTTL(entry.time, ttl)) + if(entry != null) { + cached.value = checkTTL(entry.time, ttl); return entry.endpoints; } + cached.value = false; return null; } @@ -52,33 +55,36 @@ final class LocatorTable return entry != null ? entry.endpoints : null; } - synchronized Ice.ObjectPrx - getProxy(Ice.Identity id, int ttl) + synchronized Reference + getObjectReference(Ice.Identity id, int ttl, Ice.BooleanHolder cached) { if(ttl == 0) // Locator cache disabled. { + cached.value = false; return null; } - ProxyTableEntry entry = _objectTable.get(id); - if(entry != null && checkTTL(entry.time, ttl)) + ReferenceTableEntry entry = _objectTable.get(id); + if(entry != null) { - return entry.proxy; + cached.value = checkTTL(entry.time, ttl); + return entry.reference; } + cached.value = false; return null; } synchronized void - addProxy(Ice.Identity id, Ice.ObjectPrx proxy) + addObjectReference(Ice.Identity id, Reference ref) { - _objectTable.put(id, new ProxyTableEntry(IceInternal.Time.currentMonotonicTimeMillis(), proxy)); + _objectTable.put(id, new ReferenceTableEntry(IceInternal.Time.currentMonotonicTimeMillis(), ref)); } - synchronized Ice.ObjectPrx - removeProxy(Ice.Identity id) + synchronized Reference + removeObjectReference(Ice.Identity id) { - ProxyTableEntry entry = _objectTable.remove(id); - return entry != null ? entry.proxy : null; + ReferenceTableEntry entry = _objectTable.remove(id); + return entry != null ? entry.reference : null; } private boolean @@ -107,20 +113,20 @@ final class LocatorTable final public IceInternal.EndpointI[] endpoints; } - private static final class ProxyTableEntry + private static final class ReferenceTableEntry { - public ProxyTableEntry(long time, Ice.ObjectPrx proxy) + public ReferenceTableEntry(long time, Reference reference) { this.time = time; - this.proxy = proxy; + this.reference = reference; } final public long time; - final public Ice.ObjectPrx proxy; + final public Reference reference; } private java.util.Map _adapterEndpointsTable = new java.util.HashMap(); - private java.util.Map _objectTable = - new java.util.HashMap(); + private java.util.Map _objectTable = + new java.util.HashMap(); } diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java index 5c4eadf0ea8..3a7990d01cc 100644 --- a/java/src/IceInternal/PropertyNames.java +++ b/java/src/IceInternal/PropertyNames.java @@ -8,7 +8,7 @@ // ********************************************************************** // -// Generated by makeprops.py from file ./config/PropertyNames.xml, Tue Dec 23 19:01:32 2008 +// Generated by makeprops.py from file ../config/PropertyNames.xml, Tue Jan 20 15:47:00 2009 // IMPORTANT: Do not edit this file -- any edits made here will be lost! @@ -37,6 +37,7 @@ public final class PropertyNames new Property("Ice\\.Admin\\.Facets", false, null), new Property("Ice\\.Admin\\.InstanceName", false, null), new Property("Ice\\.Admin\\.ServerId", false, null), + new Property("Ice\\.BackgroundLocatorCacheUpdates", false, null), new Property("Ice\\.BatchAutoFlush", false, null), new Property("Ice\\.ChangeUser", false, null), new Property("Ice\\.Compression\\.Level", false, null), diff --git a/java/src/IceInternal/ProxyFactory.java b/java/src/IceInternal/ProxyFactory.java index eb0762ecb5a..45d3ea2c557 100644 --- a/java/src/IceInternal/ProxyFactory.java +++ b/java/src/IceInternal/ProxyFactory.java @@ -112,7 +112,11 @@ public final class ProxyFactory // We retry ObjectNotExistException if the reference is // indirect. // - li.clearObjectCache(ref); + + if(ref.isWellKnown()) + { + li.clearCache(ref); + } } else if(ref.getRouterInfo() != null && one.operation.equals("ice_add_proxy")) { diff --git a/java/test/Ice/location/AllTests.java b/java/test/Ice/location/AllTests.java index 9ee36e75e0c..89541829ab9 100644 --- a/java/test/Ice/location/AllTests.java +++ b/java/test/Ice/location/AllTests.java @@ -26,9 +26,13 @@ public class AllTests ServerManagerPrx manager = ServerManagerPrxHelper.checkedCast( communicator.stringToProxy("ServerManager :default -t 10000 -p 12010")); test(manager != null); + TestLocatorPrx locator = TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator()); test(locator != null); + TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); + test(registry != null); + System.out.print("testing stringToProxy... "); System.out.flush(); Ice.ObjectPrx base = communicator.stringToProxy("test @ TestAdapter"); @@ -285,6 +289,7 @@ public class AllTests System.out.print("testing proxy from server... "); System.out.flush(); + obj = TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter")); HelloPrx hello = obj.getHello(); test(hello.ice_getAdapterId().equals("TestAdapter")); hello = obj.getReplicatedHello(); @@ -315,7 +320,7 @@ public class AllTests }; hello.sayHello_async(new AMICallback()); } - test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 500); count = locator.getRequestCount(); hello = (HelloPrx)hello.ice_adapterId("unknown"); for(int i = 0; i < 1000; i++) @@ -336,7 +341,293 @@ public class AllTests }; hello.sayHello_async(new AMICallback()); } - test(locator.getRequestCount() > count && locator.getRequestCount() < count + 100); + test(locator.getRequestCount() > count && locator.getRequestCount() < count + 500); + System.out.println("ok"); + + System.out.print("testing adapter locator cache... "); + System.out.flush(); + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + test(false); + } + catch(Ice.NotRegisteredException ex) + { + test(ex.kindOfObject == "object adapter"); + test(ex.id.equals("TestAdapter3")); + } + try + { + registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + try + { + registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + } + catch(Ice.LocalException ex) + { + test(false); + } + + try + { + communicator.stringToProxy("test@TestAdapter3").ice_locatorCacheTimeout(0).ice_ping(); + test(false); + } + catch(Ice.LocalException ex) + { + } + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + test(false); + } + catch(Ice.LocalException ex) + { + } + try + { + registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + try + { + communicator.stringToProxy("test@TestAdapter3").ice_ping(); + } + catch(Ice.LocalException ex) + { + test(false); + } + System.out.println("ok"); + + System.out.print("testing well-known object locator cache... "); + System.out.flush(); + registry.addObject(communicator.stringToProxy("test3@TestUnknown")); + try + { + communicator.stringToProxy("test3").ice_ping(); + test(false); + } + catch(Ice.NotRegisteredException ex) + { + test(ex.kindOfObject == "object adapter"); + test(ex.id.equals("TestUnknown")); + } + registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update + try + { + registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + + try + { + communicator.stringToProxy("test3").ice_ping(); + test(false); + } + catch(Ice.LocalException ex) + { + } + try + { + registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + try + { + communicator.stringToProxy("test3").ice_ping(); + } + catch(Ice.LocalException ex) + { + test(false); + } + + try + { + registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + try + { + communicator.stringToProxy("test3").ice_ping(); + } + catch(Ice.LocalException ex) + { + test(false); + } + + try + { + communicator.stringToProxy("test@TestAdapter4").ice_locatorCacheTimeout(0).ice_ping(); + test(false); + } + catch(Ice.LocalException ex) + { + } + try + { + communicator.stringToProxy("test@TestAdapter4").ice_ping(); + test(false); + } + catch(Ice.LocalException ex) + { + } + try + { + communicator.stringToProxy("test3").ice_ping(); + test(false); + } + catch(Ice.LocalException ex) + { + } + registry.addObject(communicator.stringToProxy("test3@TestAdapter")); + try + { + communicator.stringToProxy("test3").ice_ping(); + } + catch(Ice.LocalException ex) + { + test(false); + } + + registry.addObject(communicator.stringToProxy("test4")); + try + { + communicator.stringToProxy("test4").ice_ping(); + test(false); + } + catch(Ice.NoEndpointException ex) + { + } + System.out.println("ok"); + + System.out.print("testing locator cache background updates... "); + System.out.flush(); + { + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = communicator.getProperties()._clone(); + initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1"); + Ice.Communicator ic = Ice.Util.initialize(initData); + + try + { + registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter")); + registry.addObject(communicator.stringToProxy("test3@TestAdapter")); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + + count = locator.getRequestCount(); + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. + ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. + count += 3; + test(count == locator.getRequestCount()); + try + { + registry.setAdapterDirectProxy("TestAdapter5", null); + } + catch(Ice.AdapterAlreadyActiveException ex) + { + } + catch(Ice.AdapterNotFoundException ex) + { + } + registry.addObject(communicator.stringToProxy("test3:tcp")); + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + test(count == locator.getRequestCount()); + try + { + Thread.sleep(1200); + } + catch(InterruptedException ex) + { + } + + // The following requets should trigger the background updates but still use the cached endpoints + // and therefore succeed. + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + + try + { + while(true) + { + ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + try + { + Thread.sleep(10); + } + catch(InterruptedException ex) + { + } + } + } + catch(Ice.LocalException ex) + { + // Expected to fail once they endpoints have been updated in the background. + } + try + { + while(true) + { + ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. + try + { + Thread.sleep(10); + } + catch(InterruptedException ex) + { + } + } + } + catch(Ice.LocalException ex) + { + // Expected to fail once they endpoints have been updated in the background. + } + ic.destroy(); + } System.out.println("ok"); System.out.print("testing proxy from server after shutdown... "); @@ -376,8 +667,6 @@ public class AllTests properties.setProperty("Ice.PrintAdapterReady", "0"); Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default"); adapter.setLocator(locator); - TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); - test(registry != null); Ice.Identity id = new Ice.Identity(); id.name = Ice.Util.generateUUID(); diff --git a/java/test/Ice/location/ServerLocatorRegistry.java b/java/test/Ice/location/ServerLocatorRegistry.java index fef9d1a2d83..7430c319a76 100644 --- a/java/test/Ice/location/ServerLocatorRegistry.java +++ b/java/test/Ice/location/ServerLocatorRegistry.java @@ -13,7 +13,14 @@ public class ServerLocatorRegistry extends Test._TestLocatorRegistryDisp setAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setAdapterDirectProxy cb, String adapter, Ice.ObjectPrx object, Ice.Current current) { - _adapters.put(adapter, object); + if(object != null) + { + _adapters.put(adapter, object); + } + else + { + _adapters.remove(adapter); + } cb.ice_response(); } @@ -21,8 +28,16 @@ public class ServerLocatorRegistry extends Test._TestLocatorRegistryDisp setReplicatedAdapterDirectProxy_async(Ice.AMD_LocatorRegistry_setReplicatedAdapterDirectProxy cb, String adapter, String replica, Ice.ObjectPrx object, Ice.Current current) { - _adapters.put(adapter, object); - _adapters.put(replica, object); + if(object != null) + { + _adapters.put(adapter, object); + _adapters.put(replica, object); + } + else + { + _adapters.remove(adapter); + _adapters.remove(replica); + } cb.ice_response(); } diff --git a/java/test/Ice/location/ServerManagerI.java b/java/test/Ice/location/ServerManagerI.java index f0c5b02f882..197b8abbe42 100644 --- a/java/test/Ice/location/ServerManagerI.java +++ b/java/test/Ice/location/ServerManagerI.java @@ -59,7 +59,8 @@ public class ServerManagerI extends _ServerManagerDisp Ice.Object object = new TestI(adapter, adapter2, _registry); _registry.addObject(adapter.add(object, serverCommunicator.stringToIdentity("test"))); _registry.addObject(adapter.add(object, serverCommunicator.stringToIdentity("test2"))); - + adapter.add(object, serverCommunicator.stringToIdentity("test3")); + adapter.activate(); adapter2.activate(); } diff --git a/py/test/Ice/location/Server.py b/py/test/Ice/location/Server.py index fec017bc978..ebcbd95df2d 100755 --- a/py/test/Ice/location/Server.py +++ b/py/test/Ice/location/Server.py @@ -19,17 +19,25 @@ if not slice_dir: Ice.loadSlice('-I' + slice_dir + ' Test.ice') import Test -class ServerLocatorRegistry(Ice.LocatorRegistry): +class ServerLocatorRegistry(Test.TestLocatorRegistry): def __init__(self): self._adapters = {} self._objects = {} def setAdapterDirectProxy_async(self, cb, adapter, obj, current=None): - self._adapters[adapter] = obj + if obj: + self._adapters[adapter] = obj + else: + self._adapters.pop(adapter) cb.ice_response() def setReplicatedAdapterDirectProxy_async(self, cb, adapter, replica, obj, current=None): - self._adapters[adapter] = obj + if obj: + self._adapters[adapter] = obj + self._adapters[replica] = obj + else: + self._adapters.pop(adapter) + self._adapters.pop(replica) cb.ice_response() def setServerProcessProxy_async(self, id, proxy, current=None): @@ -48,21 +56,27 @@ class ServerLocatorRegistry(Ice.LocatorRegistry): raise Ice.ObjectNotFoundException() return self._objects[id] -class ServerLocator(Ice.Locator): +class ServerLocator(Test.TestLocator): def __init__(self, registry, registryPrx): self._registry = registry self._registryPrx = registryPrx + self._requestCount = 0 def findObjectById_async(self, response, id, current=None): + self._requestCount += 1 response.ice_response(self._registry.getObject(id)) def findAdapterById_async(self, response, id, current=None): + self._requestCount += 1 response.ice_response(self._registry.getAdapter(id)) def getRegistry(self, current=None): return self._registryPrx + def getRequestCount(self, current=None): + return self._requestCount + class ServerManagerI(Test.ServerManager): def __init__(self, adapter, registry, initData): self._adapter = adapter @@ -71,6 +85,7 @@ class ServerManagerI(Test.ServerManager): self._initData = initData self._initData.properties.setProperty("TestAdapter.Endpoints", "default") self._initData.properties.setProperty("TestAdapter.AdapterId", "TestAdapter") + self._initData.properties.setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter") self._initData.properties.setProperty("TestAdapter2.Endpoints", "default") self._initData.properties.setProperty("TestAdapter2.AdapterId", "TestAdapter2") @@ -97,6 +112,7 @@ class ServerManagerI(Test.ServerManager): object = TestI(adapter, adapter2, self._registry) self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test"))) self._registry.addObject(adapter.add(object, communicator.stringToIdentity("test2"))) + adapter.add(object, communicator.stringToIdentity("test3")) adapter.activate() adapter2.activate() @@ -121,6 +137,9 @@ class TestI(Test.TestIntf): self._adapter1.getCommunicator().shutdown() def getHello(self, current=None): + return Test.HelloPrx.uncheckedCast(self._adapter1.createIndirectProxy(communicator.stringToIdentity("hello"))) + + def getReplicatedHello(self, current=None): return Test.HelloPrx.uncheckedCast(self._adapter1.createProxy(communicator.stringToIdentity("hello"))) def migrateHello(self, current=None): diff --git a/py/test/Ice/location/Test.ice b/py/test/Ice/location/Test.ice index b9db2de57fc..ff667e4a8b1 100644 --- a/py/test/Ice/location/Test.ice +++ b/py/test/Ice/location/Test.ice @@ -23,6 +23,14 @@ interface TestLocatorRegistry extends ::Ice::LocatorRegistry void addObject(Object* obj); }; +interface TestLocator extends ::Ice::Locator +{ + // + // Returns the number of request on the locator interface. + // + ["cpp:const"] idempotent int getRequestCount(); +}; + interface ServerManager { void startServer(); @@ -40,6 +48,8 @@ interface TestIntf Hello* getHello(); + Hello* getReplicatedHello(); + void migrateHello(); }; -- cgit v1.2.3 From 3994b371119ba308c6c4f27475c1b16a1fc518eb Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Thu, 22 Jan 2009 15:19:02 +0100 Subject: Fixed bug 3484 & 3604 --- cpp/src/Ice/ThreadPool.cpp | 19 ++++++++++++++++--- cpp/src/Ice/UdpTransceiver.cpp | 1 - cpp/test/Ice/udp/AllTests.cpp | 32 ++++++++++++++++++++++++++++++++ cpp/test/Ice/udp/Client.cpp | 8 +++++++- cpp/test/Ice/udp/Server.cpp | 8 +++++++- cpp/test/Ice/udp/Test.ice | 3 +++ cpp/test/Ice/udp/TestI.cpp | 15 ++++++++++++++- cpp/test/Ice/udp/TestI.h | 1 + cs/src/Ice/ConnectionI.cs | 9 ++++++--- cs/test/Ice/udp/AllTests.cs | 32 ++++++++++++++++++++++++++++++++ cs/test/Ice/udp/Client.cs | 8 +++++++- cs/test/Ice/udp/Server.cs | 8 +++++++- cs/test/Ice/udp/Test.ice | 3 +++ cs/test/Ice/udp/TestIntfI.cs | 13 ++++++++++++- java/src/IceInternal/ThreadPool.java | 16 ++++++++++++++-- java/test/Ice/udp/AllTests.java | 32 ++++++++++++++++++++++++++++++++ java/test/Ice/udp/Client.java | 9 ++++++++- java/test/Ice/udp/Server.java | 8 +++++++- java/test/Ice/udp/Test.ice | 3 +++ java/test/Ice/udp/TestIntfI.java | 12 ++++++++++++ 20 files changed, 223 insertions(+), 17 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 4b245401c3d..ab41198104c 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -480,6 +480,8 @@ IceInternal::ThreadPool::run() } catch(const DatagramLimitException&) // Expected. { + handler->_stream.resize(0); + handler->_stream.i = stream.b.begin(); continue; } catch(const SocketException& ex) @@ -496,6 +498,8 @@ IceInternal::ThreadPool::run() Warning out(_instance->initializationData().logger); out << "datagram connection exception:\n" << ex << '\n' << handler->toString(); } + handler->_stream.resize(0); + handler->_stream.i = stream.b.begin(); } else { @@ -632,7 +636,17 @@ bool IceInternal::ThreadPool::read(const EventHandlerPtr& handler) { BasicStream& stream = handler->_stream; - + + if(stream.i - stream.b.begin() >= headerSize) + { + if(!handler->read(stream)) + { + return false; + } + assert(stream.i == stream.b.end()); + return true; + } + if(stream.b.size() == 0) { stream.b.resize(headerSize); @@ -656,6 +670,7 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) // throw IllegalMessageSizeException(__FILE__, __LINE__); } + stream.i = stream.b.begin(); const Byte* m; stream.readBlob(m, static_cast(sizeof(magic))); @@ -721,8 +736,6 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler) { Warning out(_instance->initializationData().logger); out << "DatagramLimitException: maximum size of " << pos << " exceeded"; - stream.resize(0); - stream.i = stream.b.begin(); } throw DatagramLimitException(__FILE__, __LINE__); } diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 92852685aea..731de9ce9e8 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -65,7 +65,6 @@ IceInternal::UdpTransceiver::write(Buffer& buf) // // We don't log a warning here because the client gets an exception anyway. // - cerr << packetSize << " " << _maxPacketSize << " " << _sndSize << endl; throw DatagramLimitException(__FILE__, __LINE__); } diff --git a/cpp/test/Ice/udp/AllTests.cpp b/cpp/test/Ice/udp/AllTests.cpp index 41a21e287d7..7b05acad659 100644 --- a/cpp/test/Ice/udp/AllTests.cpp +++ b/cpp/test/Ice/udp/AllTests.cpp @@ -79,6 +79,38 @@ allTests(const CommunicatorPtr& communicator) obj->ping(reply); bool ret = replyI->waitReply(3, IceUtil::Time::seconds(2)); test(ret == true); + + Test::ByteSeq seq; + try + { + seq.resize(1024); + while(true) + { + seq.resize(seq.size() * 2 + 10); + replyI->reset(); + obj->sendByteSeq(seq, reply); + replyI->waitReply(1, IceUtil::Time::seconds(10)); + } + } + catch(const DatagramLimitException&) + { + test(seq.size() > 16384); + } + + communicator->getProperties()->setProperty("Ice.UDP.SndSize", "64000"); + seq.resize(50000); + try + { + replyI->reset(); + obj->sendByteSeq(seq, reply); + test(!replyI->waitReply(1, IceUtil::Time::milliSeconds(500))); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; cout << "testing udp multicast... " << flush; diff --git a/cpp/test/Ice/udp/Client.cpp b/cpp/test/Ice/udp/Client.cpp index 3e476d383f8..b6a24ad19dc 100644 --- a/cpp/test/Ice/udp/Client.cpp +++ b/cpp/test/Ice/udp/Client.cpp @@ -31,7 +31,13 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + + initData.properties->setProperty("Ice.Warn.Connections", "0"); + initData.properties->setProperty("Ice.UDP.SndSize", "16384"); + + communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/Ice/udp/Server.cpp b/cpp/test/Ice/udp/Server.cpp index 3793b860171..bcaa010beea 100644 --- a/cpp/test/Ice/udp/Server.cpp +++ b/cpp/test/Ice/udp/Server.cpp @@ -50,7 +50,13 @@ main(int argc, char* argv[]) try { - communicator = Ice::initialize(argc, argv); + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + + initData.properties->setProperty("Ice.Warn.Connections", "0"); + initData.properties->setProperty("Ice.UDP.RcvSize", "16384"); + + communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/Ice/udp/Test.ice b/cpp/test/Ice/udp/Test.ice index 46adf09ca03..0d4af4d441a 100644 --- a/cpp/test/Ice/udp/Test.ice +++ b/cpp/test/Ice/udp/Test.ice @@ -18,9 +18,12 @@ interface PingReply void reply(); }; +sequence ByteSeq; + interface TestIntf { void ping(PingReply* reply); + void sendByteSeq(ByteSeq seq, PingReply* reply); void shutdown(); }; diff --git a/cpp/test/Ice/udp/TestI.cpp b/cpp/test/Ice/udp/TestI.cpp index 8cd9bf8e1ea..55657e25ada 100644 --- a/cpp/test/Ice/udp/TestI.cpp +++ b/cpp/test/Ice/udp/TestI.cpp @@ -21,7 +21,20 @@ TestIntfI::ping(const Test::PingReplyPrx& reply, const Current& current) { reply->reply(); } - catch(const Ice::Exception ex) + catch(const Ice::Exception&) + { + assert(false); + } +} + +void +TestIntfI::sendByteSeq(const Test::ByteSeq&, const Test::PingReplyPrx& reply, const Current& current) +{ + try + { + reply->reply(); + } + catch(const Ice::Exception&) { assert(false); } diff --git a/cpp/test/Ice/udp/TestI.h b/cpp/test/Ice/udp/TestI.h index 5781faa3e81..ce404a0f264 100644 --- a/cpp/test/Ice/udp/TestI.h +++ b/cpp/test/Ice/udp/TestI.h @@ -17,6 +17,7 @@ class TestIntfI : public Test::TestIntf public: virtual void ping(const Test::PingReplyPrx&, const Ice::Current&); + virtual void sendByteSeq(const Test::ByteSeq&, const Test::PingReplyPrx&, const Ice::Current&); virtual void shutdown(const Ice::Current&); }; diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs index 70b5967b96b..021313db534 100644 --- a/cs/src/Ice/ConnectionI.cs +++ b/cs/src/Ice/ConnectionI.cs @@ -1988,6 +1988,7 @@ namespace Ice } Debug.Assert(_transceiver != null); + bool parseHeader = _stream.isEmpty() || _stream.pos() < IceInternal.Protocol.headerSize; // // Complete an asynchronous read operation if necessary. This may raise a SocketException @@ -2042,7 +2043,7 @@ namespace Ice // When we've read enough to fill out the header, we need to validate it. The stream // will be enlarged if necessary to contain the entire message. // - if(pos == IceInternal.Protocol.headerSize) + if(parseHeader && pos >= IceInternal.Protocol.headerSize) { validateHeader(_stream); @@ -2058,8 +2059,6 @@ namespace Ice _logger.warning("DatagramLimitException: maximum size of " + _stream.pos() + " exceeded"); } - _stream.pos(0); - _stream.resize(0, true); throw new Ice.DatagramLimitException(); } } @@ -2141,6 +2140,8 @@ namespace Ice // // Expected. Restart the read. // + _stream.pos(0); + _stream.resize(IceInternal.Protocol.headerSize, true); // Make room for the next header. readAsync(null); } catch(IceInternal.ReadAbortedException) @@ -2167,6 +2168,8 @@ namespace Ice // // Restart the read. // + _stream.pos(0); + _stream.resize(IceInternal.Protocol.headerSize, true); // Make room for the next header. readAsync(null); } else diff --git a/cs/test/Ice/udp/AllTests.cs b/cs/test/Ice/udp/AllTests.cs index ed19a348211..671e6d7c126 100644 --- a/cs/test/Ice/udp/AllTests.cs +++ b/cs/test/Ice/udp/AllTests.cs @@ -84,6 +84,38 @@ public class AllTests obj.ping(reply); bool ret = replyI.waitReply(3, 2000); test(ret == true); + + byte[] seq = null; + try + { + seq = new byte[1024]; + while(true) + { + seq = new byte[seq.Length * 2 + 10]; + replyI.reset(); + obj.sendByteSeq(seq, reply); + replyI.waitReply(1, 10000); + } + } + catch(Ice.DatagramLimitException) + { + test(seq.Length > 16384); + } + + communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); + seq = new byte[50000]; + try + { + replyI.reset(); + obj.sendByteSeq(seq, reply); + test(!replyI.waitReply(1, 500)); + } + catch(Ice.LocalException ex) + { + Console.Out.WriteLine(ex); + test(false); + } + Console.Out.WriteLine("ok"); Console.Out.Write("testing udp multicast... "); diff --git a/cs/test/Ice/udp/Client.cs b/cs/test/Ice/udp/Client.cs index 1d9e485f0c9..68c990c8c05 100644 --- a/cs/test/Ice/udp/Client.cs +++ b/cs/test/Ice/udp/Client.cs @@ -36,7 +36,13 @@ public class Client try { - communicator = Ice.Util.initialize(ref args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(ref args); + + initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.UDP.SndSize", "16384"); + + communicator = Ice.Util.initialize(ref args, initData); status = run(args, communicator); } catch(System.Exception ex) diff --git a/cs/test/Ice/udp/Server.cs b/cs/test/Ice/udp/Server.cs index 82f15c5bb46..1c7c8526358 100644 --- a/cs/test/Ice/udp/Server.cs +++ b/cs/test/Ice/udp/Server.cs @@ -57,7 +57,13 @@ public class Server try { - communicator = Ice.Util.initialize(ref args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(ref args); + + initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.UDP.RcvSize", "16384"); + + communicator = Ice.Util.initialize(ref args, initData); status = run(args, communicator); } catch(System.Exception ex) diff --git a/cs/test/Ice/udp/Test.ice b/cs/test/Ice/udp/Test.ice index 46adf09ca03..0d4af4d441a 100644 --- a/cs/test/Ice/udp/Test.ice +++ b/cs/test/Ice/udp/Test.ice @@ -18,9 +18,12 @@ interface PingReply void reply(); }; +sequence ByteSeq; + interface TestIntf { void ping(PingReply* reply); + void sendByteSeq(ByteSeq seq, PingReply* reply); void shutdown(); }; diff --git a/cs/test/Ice/udp/TestIntfI.cs b/cs/test/Ice/udp/TestIntfI.cs index e7b5aaa6226..d00ce1abe30 100644 --- a/cs/test/Ice/udp/TestIntfI.cs +++ b/cs/test/Ice/udp/TestIntfI.cs @@ -13,7 +13,18 @@ public sealed class TestIntfI : Test.TestIntfDisp_ { public override void ping(Test.PingReplyPrx reply, Ice.Current current) { - System.Console.WriteLine("ping"); + try + { + reply.reply(); + } + catch(Ice.LocalException) + { + Debug.Assert(false); + } + } + + public override void sendByteSeq(byte[] seq, Test.PingReplyPrx reply, Ice.Current current) + { try { reply.reply(); diff --git a/java/src/IceInternal/ThreadPool.java b/java/src/IceInternal/ThreadPool.java index 78316f1f910..ea80b046a77 100644 --- a/java/src/IceInternal/ThreadPool.java +++ b/java/src/IceInternal/ThreadPool.java @@ -524,6 +524,8 @@ public final class ThreadPool } catch(Ice.DatagramLimitException ex) // Expected. { + handler._stream.pos(0); + handler._stream.resize(0, true); continue; } catch(Ice.SocketException ex) @@ -548,6 +550,8 @@ public final class ThreadPool _instance.initializationData().logger.warning( "datagram connection exception:\n" + ex + "\n" + handler.toString()); } + handler._stream.pos(0); + handler._stream.resize(0, true); } else { @@ -718,6 +722,16 @@ public final class ThreadPool { BasicStream stream = handler._stream; + if(stream.pos() >= Protocol.headerSize) + { + if(!handler.read(stream)) + { + return false; + } + assert(stream.pos() == stream.size()); + return true; + } + if(stream.size() == 0) { stream.resize(Protocol.headerSize, true); @@ -805,8 +819,6 @@ public final class ThreadPool _instance.initializationData().logger.warning("DatagramLimitException: maximum size of " + stream.pos() + " exceeded"); } - stream.pos(0); - stream.resize(0, true); throw new Ice.DatagramLimitException(); } else diff --git a/java/test/Ice/udp/AllTests.java b/java/test/Ice/udp/AllTests.java index b15d57f901c..5e23f10d62e 100644 --- a/java/test/Ice/udp/AllTests.java +++ b/java/test/Ice/udp/AllTests.java @@ -82,6 +82,38 @@ public class AllTests obj.ping(reply); boolean ret = replyI.waitReply(3, 2000); test(ret == true); + + byte[] seq = null; + try + { + seq = new byte[1024]; + while(true) + { + seq = new byte[seq.length * 2 + 10]; + replyI.reset(); + obj.sendByteSeq(seq, reply); + replyI.waitReply(1, 10000); + } + } + catch(Ice.DatagramLimitException ex) + { + test(seq.length > 16384); + } + + communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); + seq = new byte[50000]; + try + { + replyI.reset(); + obj.sendByteSeq(seq, reply); + test(!replyI.waitReply(1, 500)); + } + catch(Ice.LocalException ex) + { + System.err.println(ex); + test(false); + } + System.out.println("ok"); System.out.print("testing udp multicast... "); diff --git a/java/test/Ice/udp/Client.java b/java/test/Ice/udp/Client.java index 3315d78da6b..321f89d3ecf 100644 --- a/java/test/Ice/udp/Client.java +++ b/java/test/Ice/udp/Client.java @@ -27,7 +27,14 @@ public class Client try { - communicator = Ice.Util.initialize(args); + Ice.StringSeqHolder argHolder = new Ice.StringSeqHolder(args); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argHolder); + + initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.UDP.SndSize", "16384"); + + communicator = Ice.Util.initialize(argHolder, initData); status = run(args, communicator); } catch(Exception ex) diff --git a/java/test/Ice/udp/Server.java b/java/test/Ice/udp/Server.java index 4ea6e29a4b8..bedd63218bb 100644 --- a/java/test/Ice/udp/Server.java +++ b/java/test/Ice/udp/Server.java @@ -48,7 +48,13 @@ public class Server try { Ice.StringSeqHolder argHolder = new Ice.StringSeqHolder(args); - communicator = Ice.Util.initialize(argHolder); + Ice.InitializationData initData = new Ice.InitializationData(); + initData.properties = Ice.Util.createProperties(argHolder); + + initData.properties.setProperty("Ice.Warn.Connections", "0"); + initData.properties.setProperty("Ice.UDP.RcvSize", "16384"); + + communicator = Ice.Util.initialize(argHolder, initData); status = run(argHolder.value, communicator); } catch(Exception ex) diff --git a/java/test/Ice/udp/Test.ice b/java/test/Ice/udp/Test.ice index 46adf09ca03..0d4af4d441a 100644 --- a/java/test/Ice/udp/Test.ice +++ b/java/test/Ice/udp/Test.ice @@ -18,9 +18,12 @@ interface PingReply void reply(); }; +sequence ByteSeq; + interface TestIntf { void ping(PingReply* reply); + void sendByteSeq(ByteSeq seq, PingReply* reply); void shutdown(); }; diff --git a/java/test/Ice/udp/TestIntfI.java b/java/test/Ice/udp/TestIntfI.java index 8a3d3887767..585d00be077 100644 --- a/java/test/Ice/udp/TestIntfI.java +++ b/java/test/Ice/udp/TestIntfI.java @@ -21,6 +21,18 @@ public final class TestIntfI extends Test._TestIntfDisp } } + public void sendByteSeq(byte[] seq, Test.PingReplyPrx reply, Ice.Current current) + { + try + { + reply.reply(); + } + catch(Ice.LocalException ex) + { + assert(false); + } + } + public void shutdown(Ice.Current current) { current.adapter.getCommunicator().shutdown(); -- cgit v1.2.3 From 34e0afaa23ff0d3dfbf59115c20c5145d0b5b71d Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Tue, 27 Jan 2009 12:15:40 -0330 Subject: Fixed some BCC compile errors --- cpp/src/Ice/LocatorInfo.cpp | 4 ++-- cpp/src/Slice/FileTracker.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index a2cc09ff1af..4271e3ceaab 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -34,7 +34,7 @@ class ObjectRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findO { public: - ObjectRequest(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : Request(locatorInfo, ref) + ObjectRequest(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : LocatorInfo::Request(locatorInfo, ref) { assert(ref->isWellKnown()); } @@ -73,7 +73,7 @@ class AdapterRequest : public LocatorInfo::Request, public Ice::AMI_Locator_find { public: - AdapterRequest(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : Request(locatorInfo, ref) + AdapterRequest(const LocatorInfoPtr& locatorInfo, const ReferencePtr& ref) : LocatorInfo::Request(locatorInfo, ref) { assert(ref->isIndirect() && !ref->isWellKnown()); } diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp index 438670cf2f8..43d9632ad17 100644 --- a/cpp/src/Slice/FileTracker.cpp +++ b/cpp/src/Slice/FileTracker.cpp @@ -16,7 +16,7 @@ using namespace std; Slice::FileException::FileException(const char* file, int line, const string& r) : - Exception(file, line), + IceUtil::Exception(file, line), _reason(r) { } @@ -36,7 +36,7 @@ Slice::FileException::ice_name() const void Slice::FileException::ice_print(ostream& out) const { - Exception::ice_print(out); + IceUtil::Exception::ice_print(out); out << ": " << _reason; } -- cgit v1.2.3 From 55f6e6863b8f17312e8ff58d05d6d035c822187b Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 27 Jan 2009 19:28:59 +0100 Subject: Squashed commit of the following: commit 9aa67a8862e402cb52276282b26a40422fae4adb Author: Jose Gutierrez Date: Tue Jan 27 19:25:22 2009 +0100 Fixed 3374 --header-ext not work as intended. --- cpp/include/Slice/Preprocessor.h | 3 +- cpp/src/Freeze/PingObject.ice | 2 + cpp/src/IceGrid/Internal.ice | 2 + cpp/src/IceStorm/Election.ice | 2 + cpp/src/IceStorm/IceStormInternal.ice | 2 + cpp/src/IceStorm/LinkRecord.ice | 2 + cpp/src/IceStorm/SubscriberRecord.ice | 2 + cpp/src/IceStorm/V31Format.ice | 2 + cpp/src/IceStorm/V32Format.ice | 2 + cpp/src/Slice/Preprocessor.cpp | 7 +- cpp/src/slice2cpp/Gen.cpp | 132 +++++++++++++++++++++++++------- cpp/src/slice2cpp/Gen.h | 16 ++++ cpp/src/slice2cpp/Main.cpp | 4 +- slice/Freeze/BackgroundSaveEvictor.ice | 2 + slice/Freeze/CatalogData.ice | 2 + slice/Freeze/Connection.ice | 2 + slice/Freeze/ConnectionF.ice | 2 + slice/Freeze/DB.ice | 2 + slice/Freeze/Evictor.ice | 2 + slice/Freeze/EvictorF.ice | 2 + slice/Freeze/EvictorStorage.ice | 2 + slice/Freeze/Exception.ice | 2 + slice/Freeze/Transaction.ice | 2 + slice/Freeze/TransactionalEvictor.ice | 2 + slice/Glacier2/PermissionsVerifier.ice | 2 + slice/Glacier2/PermissionsVerifierF.ice | 2 + slice/Glacier2/Router.ice | 2 + slice/Glacier2/RouterF.ice | 2 + slice/Glacier2/SSLInfo.ice | 2 + slice/Glacier2/Session.ice | 2 + slice/Glacier2/SessionF.ice | 2 + slice/Ice/BuiltinSequences.ice | 2 + slice/Ice/Communicator.ice | 2 + slice/Ice/CommunicatorF.ice | 2 + slice/Ice/Connection.ice | 2 + slice/Ice/ConnectionF.ice | 2 + slice/Ice/Current.ice | 2 + slice/Ice/Endpoint.ice | 2 + slice/Ice/FacetMap.ice | 2 + slice/Ice/Identity.ice | 2 + slice/Ice/ImplicitContext.ice | 2 + slice/Ice/ImplicitContextF.ice | 2 + slice/Ice/LocalException.ice | 2 + slice/Ice/Locator.ice | 2 + slice/Ice/LocatorF.ice | 2 + slice/Ice/Logger.ice | 2 + slice/Ice/LoggerF.ice | 2 + slice/Ice/ObjectAdapter.ice | 2 + slice/Ice/ObjectAdapterF.ice | 2 + slice/Ice/ObjectFactory.ice | 2 + slice/Ice/ObjectFactoryF.ice | 6 +- slice/Ice/Plugin.ice | 2 + slice/Ice/PluginF.ice | 2 + slice/Ice/Process.ice | 2 + slice/Ice/ProcessF.ice | 2 + slice/Ice/Properties.ice | 2 + slice/Ice/PropertiesF.ice | 2 + slice/Ice/Router.ice | 2 + slice/Ice/RouterF.ice | 2 + slice/Ice/ServantLocator.ice | 2 + slice/Ice/ServantLocatorF.ice | 2 + slice/Ice/SliceChecksumDict.ice | 2 + slice/Ice/Stats.ice | 2 + slice/Ice/StatsF.ice | 2 + slice/IceBox/IceBox.ice | 2 + slice/IceGrid/Admin.ice | 2 + slice/IceGrid/Descriptor.ice | 2 + slice/IceGrid/Exception.ice | 2 + slice/IceGrid/FileParser.ice | 2 + slice/IceGrid/Locator.ice | 2 + slice/IceGrid/Observer.ice | 2 + slice/IceGrid/Query.ice | 2 + slice/IceGrid/Registry.ice | 2 + slice/IceGrid/Session.ice | 2 + slice/IceGrid/UserAccountMapper.ice | 2 + slice/IcePatch2/FileInfo.ice | 2 + slice/IcePatch2/FileServer.ice | 2 + slice/IceStorm/IceStorm.ice | 2 + 78 files changed, 276 insertions(+), 36 deletions(-) (limited to 'cpp/src') diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h index 98a018fbfbe..54535e28812 100644 --- a/cpp/include/Slice/Preprocessor.h +++ b/cpp/include/Slice/Preprocessor.h @@ -32,7 +32,7 @@ class SLICE_API Preprocessor { public: - Preprocessor(const std::string&, const std::string&, const std::vector&); + Preprocessor(const std::string&, const std::string&, const std::vector&, const std::string& = "cpp"); ~Preprocessor(); FILE* preprocess(bool); @@ -54,6 +54,7 @@ private: const std::string _path; const std::string _fileName; const std::vector _args; + const std::string _cppSourceExt; #ifdef _WIN32 std::wstring _cppFile; #else diff --git a/cpp/src/Freeze/PingObject.ice b/cpp/src/Freeze/PingObject.ice index 9ef1772eb57..ac0262e47d5 100644 --- a/cpp/src/Freeze/PingObject.ice +++ b/cpp/src/Freeze/PingObject.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_PING_OBJECT_ICE #define FREEZE_PING_OBJECT_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index 63d2bfb8f12..a1e510d8c38 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_INTERNAL_ICE #define ICE_GRID_INTERNAL_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/cpp/src/IceStorm/Election.ice b/cpp/src/IceStorm/Election.ice index 2ba02e1035c..2a2fde7f0e9 100644 --- a/cpp/src/IceStorm/Election.ice +++ b/cpp/src/IceStorm/Election.ice @@ -10,6 +10,8 @@ #ifndef ELECTION_ICE #define ELECTION_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/cpp/src/IceStorm/IceStormInternal.ice b/cpp/src/IceStorm/IceStormInternal.ice index 744a5339eab..476dde4c346 100644 --- a/cpp/src/IceStorm/IceStormInternal.ice +++ b/cpp/src/IceStorm/IceStormInternal.ice @@ -10,6 +10,8 @@ #ifndef ICE_STORM_INTERNAL_ICE #define ICE_STORM_INTERNAL_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/cpp/src/IceStorm/LinkRecord.ice b/cpp/src/IceStorm/LinkRecord.ice index 6d30eb428c7..744755fedef 100644 --- a/cpp/src/IceStorm/LinkRecord.ice +++ b/cpp/src/IceStorm/LinkRecord.ice @@ -10,6 +10,8 @@ #ifndef LINK_RECORD_ICE #define LINK_RECORD_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/cpp/src/IceStorm/SubscriberRecord.ice b/cpp/src/IceStorm/SubscriberRecord.ice index 6a8c4133189..2c37010150d 100644 --- a/cpp/src/IceStorm/SubscriberRecord.ice +++ b/cpp/src/IceStorm/SubscriberRecord.ice @@ -10,6 +10,8 @@ #ifndef SUBSCRIBER_RECORD_ICE #define SUBSCRIBER_RECORD_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/cpp/src/IceStorm/V31Format.ice b/cpp/src/IceStorm/V31Format.ice index ca45b0a7f0c..9607990a156 100644 --- a/cpp/src/IceStorm/V31Format.ice +++ b/cpp/src/IceStorm/V31Format.ice @@ -10,6 +10,8 @@ #ifndef V31_FORMAT_ICE #define V31_FORMAT_ICE +[["cpp:header-ext:h"]] + #include module IceStorm diff --git a/cpp/src/IceStorm/V32Format.ice b/cpp/src/IceStorm/V32Format.ice index 248de06da41..860120756a2 100644 --- a/cpp/src/IceStorm/V32Format.ice +++ b/cpp/src/IceStorm/V32Format.ice @@ -10,6 +10,8 @@ #ifndef V32_FORMAT_ICE #define V32_FORMAT_ICE +[["cpp:header-ext:h"]] + #include module IceStorm diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp index 6c226c2db72..636c772b94d 100644 --- a/cpp/src/Slice/Preprocessor.cpp +++ b/cpp/src/Slice/Preprocessor.cpp @@ -44,10 +44,11 @@ extern "C" int mcpp_lib_main(int argc, char** argv); extern "C" void mcpp_use_mem_buffers(int tf); extern "C" char* mcpp_get_mem_buffer(Outdest od); -Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector& args) : +Slice::Preprocessor::Preprocessor(const string& path, const string& fileName, const vector& args, const string& cppSourceExt) : _path(path), _fileName(fileName), _args(args), + _cppSourceExt(cppSourceExt), _cppHandle(0) { } @@ -390,12 +391,12 @@ Slice::Preprocessor::printMakefileDependencies(Language lang, const vector #include #include +#include #include #include -#include +#include + +#include //TODO using namespace std; using namespace Slice; @@ -44,11 +47,13 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& bool imp, bool checksum, bool stream, bool ice) : _base(base), _headerExtension(headerExtension), + _implHeaderExtension(headerExtension), _sourceExtension(sourceExtension), _extraHeaders(extraHeaders), _include(include), _includePaths(includePaths), _dllExport(dllExport), + _dir(dir), _impl(imp), _checksum(checksum), _stream(stream), @@ -64,15 +69,41 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& { _base.erase(0, pos + 1); } +} + +Slice::Gen::~Gen() +{ + H << "\n\n#endif\n"; + C << '\n'; + + if(_impl) + { + implH << "\n\n#endif\n"; + implC << '\n'; + } +} + +void +Slice::Gen::generate(const UnitPtr& p) +{ + + // + // Check the header-ext global meta data if is not empty we override _headerExtension + // + string headerExtension = getHeaderExt(p->modules()); + if(!headerExtension.empty()) + { + _headerExtension = headerExtension; + } if(_impl) { - string fileImplH = _base + "I." + _headerExtension; + string fileImplH = _base + "I." + _implHeaderExtension; string fileImplC = _base + "I." + _sourceExtension; - if(!dir.empty()) + if(!_dir.empty()) { - fileImplH = dir + '/' + fileImplH; - fileImplC = dir + '/' + fileImplC; + fileImplH = _dir + '/' + fileImplH; + fileImplC = _dir + '/' + fileImplC; } struct stat st; @@ -120,10 +151,10 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& string fileH = _base + "." + _headerExtension; string fileC = _base + "." + _sourceExtension; - if(!dir.empty()) + if(!_dir.empty()) { - fileH = dir + '/' + fileH; - fileC = dir + '/' + fileC; + fileH = _dir + '/' + fileH; + fileC = _dir + '/' + fileC; } H.open(fileH.c_str()); @@ -158,23 +189,7 @@ Slice::Gen::Gen(const string& base, const string& headerExtension, const string& H << "\n#ifndef __" << s << "__"; H << "\n#define __" << s << "__"; H << '\n'; -} - -Slice::Gen::~Gen() -{ - H << "\n\n#endif\n"; - C << '\n'; - - if(_impl) - { - implH << "\n\n#endif\n"; - implC << '\n'; - } -} -void -Slice::Gen::generate(const UnitPtr& p) -{ validateMetaData(p); writeExtraHeaders(C); @@ -193,6 +208,7 @@ Slice::Gen::generate(const UnitPtr& p) } C << _base << "." << _headerExtension << ">"; + H << "\n#include "; H << "\n#include "; H << "\n#include "; @@ -224,6 +240,7 @@ Slice::Gen::generate(const UnitPtr& p) } else if(p->hasNonLocalClassDecls()) { + H << "\n#include "; } @@ -274,7 +291,12 @@ Slice::Gen::generate(const UnitPtr& p) for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q) { - H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">"; + string extension = getHeaderExt((*q), p->modules()); + if(extension.empty()) + { + extension = _headerExtension; + } + H << "\n#include <" << changeInclude(*q, _includePaths) << "." << extension << ">"; } H << "\n#include "; @@ -339,7 +361,7 @@ Slice::Gen::generate(const UnitPtr& p) { implH << _include << '/'; } - implH << _base << ".h>"; + implH << _base << "." << _headerExtension << ">"; writeExtraHeaders(implC); @@ -348,7 +370,7 @@ Slice::Gen::generate(const UnitPtr& p) { implC << _include << '/'; } - implC << _base << "I.h>"; + implC << _base << "I." << _implHeaderExtension << ">"; ImplVisitor implVisitor(implH, implC, _dllExport); p->visit(&implVisitor, false); @@ -5641,6 +5663,8 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p) StringList globalMetaData = dc->getMetaData(); string file = dc->filename(); static const string prefix = "cpp:"; + + int headerExtension = 0; for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q) { string s = *q; @@ -5653,7 +5677,15 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p) { continue; } - cerr << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl; + else if(ss.find("header-ext:") == 0) + { + headerExtension++; + if(headerExtension == 1) + { + continue; + } + } + cerr << file << ": warning: ignoring invalid global metadata `" << s << "', the cpp:header-ext global metadata can only appear once per file." << endl; } _history.insert(s); } @@ -5866,3 +5898,47 @@ Slice::Gen::resetUseWstring(list& hist) hist.pop_back(); return use; } + +string +Slice::Gen::getHeaderExt(const string& file, const ModuleList& modules) +{ + string ext = ""; + if(!modules.empty()) // Just in case the Slice file has no definitions + { + for(ModuleList::const_iterator i = modules.begin(); i != modules.end(); ++i) + { + if((*i)->definitionContext()->filename() == file) + { + string meta = (*i)->definitionContext()->findMetaData("cpp:header-ext"); + string::size_type index = meta.find_last_of(":"); + if(index != string::npos && index + 1 < meta.size()) + { + ext = meta.substr(index + 1, meta.size() - index - 1); + } + } + } + } + return ext; +} + +string +Slice::Gen::getHeaderExt(const ModuleList& modules) +{ + string ext = ""; + if(!modules.empty()) // Just in case the Slice file has no definitions + { + for(ModuleList::const_iterator i = modules.begin(); i != modules.end(); ++i) + { + if((*i)->definitionContext()->includeLevel() == 0) + { + string meta = (*i)->definitionContext()->findMetaData("cpp:header-ext"); + string::size_type index = meta.find_last_of(":"); + if(index != string::npos && index + 1 < meta.size()) + { + ext = meta.substr(index + 1, meta.size() - index - 1); + } + } + } + } + return ext; +} diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index e3c1c9afc01..9cb699a205c 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -44,6 +44,20 @@ private: void writeExtraHeaders(::IceUtilInternal::Output&); + + // + // Get the header extension defined in the global metadata for a given file + // if there isn't defined returns a empty string + // + std::string getHeaderExt(const std::string& file, const ModuleList& modules); + + // + // Get the header extension defined in the global metadata for the current + // compiling file. + // if there isn't defined returns a empty string + // + std::string getHeaderExt(const ModuleList& modules); + ::IceUtilInternal::Output H; ::IceUtilInternal::Output C; @@ -52,11 +66,13 @@ private: std::string _base; std::string _headerExtension; + std::string _implHeaderExtension; std::string _sourceExtension; std::vector _extraHeaders; std::string _include; std::vector _includePaths; std::string _dllExport; + std::string _dir; bool _impl; bool _checksum; bool _stream; diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 7e2ff8b58b1..86eafe9e64f 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -169,7 +169,7 @@ main(int argc, char* argv[]) { if(depend) { - Preprocessor icecpp(argv[0], *i, cppArgs); + Preprocessor icecpp(argv[0], *i, cppArgs, sourceExtension); if(!icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths)) { return EXIT_FAILURE; @@ -177,7 +177,7 @@ main(int argc, char* argv[]) } else { - Preprocessor icecpp(argv[0], *i, cppArgs); + Preprocessor icecpp(argv[0], *i, cppArgs, sourceExtension); FILE* cppHandle = icecpp.preprocess(false); if(cppHandle == 0) diff --git a/slice/Freeze/BackgroundSaveEvictor.ice b/slice/Freeze/BackgroundSaveEvictor.ice index 381c0c6ce55..5dbdd4206a2 100644 --- a/slice/Freeze/BackgroundSaveEvictor.ice +++ b/slice/Freeze/BackgroundSaveEvictor.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_BACKGROUND_SAVE_EVICTOR_ICE #define FREEZE_BACKGROUND_SAVE_EVICTOR_ICE +[["cpp:header-ext:h"]] + #include module Freeze diff --git a/slice/Freeze/CatalogData.ice b/slice/Freeze/CatalogData.ice index 8df77614183..ad4d9dbe53e 100644 --- a/slice/Freeze/CatalogData.ice +++ b/slice/Freeze/CatalogData.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_CATALOG_DATA_ICE #define FREEZE_CATALOG_DATA_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/Connection.ice b/slice/Freeze/Connection.ice index 4fe590a50d7..834eff9c53c 100644 --- a/slice/Freeze/Connection.ice +++ b/slice/Freeze/Connection.ice @@ -13,6 +13,8 @@ #include #include +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/ConnectionF.ice b/slice/Freeze/ConnectionF.ice index 9a9b1e52ed0..b4d393b7049 100644 --- a/slice/Freeze/ConnectionF.ice +++ b/slice/Freeze/ConnectionF.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_CONNECTION_F_ICE #define FREEZE_CONNECTION_F_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/DB.ice b/slice/Freeze/DB.ice index cd7d617ed56..a12feb001aa 100644 --- a/slice/Freeze/DB.ice +++ b/slice/Freeze/DB.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_DB_ICE #define FREEZE_DB_ICE +[["cpp:header-ext:h"]] + /** * * Freeze provides automatic persistence for Ice servants. diff --git a/slice/Freeze/Evictor.ice b/slice/Freeze/Evictor.ice index 2022e795772..0f0979e6a9b 100644 --- a/slice/Freeze/Evictor.ice +++ b/slice/Freeze/Evictor.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EVICTOR_ICE #define FREEZE_EVICTOR_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Freeze/EvictorF.ice b/slice/Freeze/EvictorF.ice index a93f4d73c3c..8daa0b536fd 100644 --- a/slice/Freeze/EvictorF.ice +++ b/slice/Freeze/EvictorF.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EVICTOR_F_ICE #define FREEZE_EVICTOR_F_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/EvictorStorage.ice b/slice/Freeze/EvictorStorage.ice index cb4f27e0953..4a2304edc90 100644 --- a/slice/Freeze/EvictorStorage.ice +++ b/slice/Freeze/EvictorStorage.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EVICTOR_STORAGE_ICE #define FREEZE_EVICTOR_STORAGE_ICE +[["cpp:header-ext:h"]] + #include module Freeze diff --git a/slice/Freeze/Exception.ice b/slice/Freeze/Exception.ice index 53d9456cd37..31919486793 100644 --- a/slice/Freeze/Exception.ice +++ b/slice/Freeze/Exception.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_EXCEPTION_ICE #define FREEZE_EXCEPTION_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/Transaction.ice b/slice/Freeze/Transaction.ice index 34eac416b5d..ab8179ec3ae 100644 --- a/slice/Freeze/Transaction.ice +++ b/slice/Freeze/Transaction.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_TRANSACTION_ICE #define FREEZE_TRANSACTION_ICE +[["cpp:header-ext:h"]] + module Freeze { diff --git a/slice/Freeze/TransactionalEvictor.ice b/slice/Freeze/TransactionalEvictor.ice index dfdf7fd45ea..9acab43a232 100644 --- a/slice/Freeze/TransactionalEvictor.ice +++ b/slice/Freeze/TransactionalEvictor.ice @@ -10,6 +10,8 @@ #ifndef FREEZE_TRANSACTIONAL_EVICTOR_ICE #define FREEZE_TRANSACTIONAL_EVICTOR_ICE +[["cpp:header-ext:h"]] + #include module Freeze diff --git a/slice/Glacier2/PermissionsVerifier.ice b/slice/Glacier2/PermissionsVerifier.ice index 733d5b56f79..07cdda5a663 100644 --- a/slice/Glacier2/PermissionsVerifier.ice +++ b/slice/Glacier2/PermissionsVerifier.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_PERMISSIONS_VERIFIER_ICE #define GLACIER2_PERMISSIONS_VERIFIER_ICE +[["cpp:header-ext:h"]] + #include module Glacier2 diff --git a/slice/Glacier2/PermissionsVerifierF.ice b/slice/Glacier2/PermissionsVerifierF.ice index 1f20eb76b85..5620c94be55 100644 --- a/slice/Glacier2/PermissionsVerifierF.ice +++ b/slice/Glacier2/PermissionsVerifierF.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_PERMISSIONS_VERIFIER_F_ICE #define GLACIER2_PERMISSIONS_VERIFIER_F_ICE +[["cpp:header-ext:h"]] + module Glacier2 { diff --git a/slice/Glacier2/Router.ice b/slice/Glacier2/Router.ice index 2bc9a3ac317..cc8c090f1f4 100644 --- a/slice/Glacier2/Router.ice +++ b/slice/Glacier2/Router.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_ROUTER_ICE #define GLACIER2_ROUTER_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Glacier2/RouterF.ice b/slice/Glacier2/RouterF.ice index 70664f44801..ec420e71f63 100644 --- a/slice/Glacier2/RouterF.ice +++ b/slice/Glacier2/RouterF.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_ROUTER_F_ICE #define GLACIER2_ROUTER_F_ICE +[["cpp:header-ext:h"]] + module Glacier2 { diff --git a/slice/Glacier2/SSLInfo.ice b/slice/Glacier2/SSLInfo.ice index d1ae83b1433..94132ecf01b 100644 --- a/slice/Glacier2/SSLInfo.ice +++ b/slice/Glacier2/SSLInfo.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_SSL_INFO_ICE #define GLACIER2_SSL_INFO_ICE +[["cpp:header-ext:h"]] + #include module Glacier2 diff --git a/slice/Glacier2/Session.ice b/slice/Glacier2/Session.ice index ea687194350..02596804fc1 100644 --- a/slice/Glacier2/Session.ice +++ b/slice/Glacier2/Session.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_SESSION_ICE #define GLACIER2_SESSION_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Glacier2/SessionF.ice b/slice/Glacier2/SessionF.ice index 74a4faa5309..08386afc758 100644 --- a/slice/Glacier2/SessionF.ice +++ b/slice/Glacier2/SessionF.ice @@ -10,6 +10,8 @@ #ifndef GLACIER2_SESSION_F_ICE #define GLACIER2_SESSION_F_ICE +[["cpp:header-ext:h"]] + module Glacier2 { diff --git a/slice/Ice/BuiltinSequences.ice b/slice/Ice/BuiltinSequences.ice index 87e26022fce..306e6314a37 100644 --- a/slice/Ice/BuiltinSequences.ice +++ b/slice/Ice/BuiltinSequences.ice @@ -10,6 +10,8 @@ #ifndef ICE_BUILTIN_SEQUENCES_ICE #define ICE_BUILTIN_SEQUENCES_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Communicator.ice b/slice/Ice/Communicator.ice index 4d464677612..aaffff1b0f3 100644 --- a/slice/Ice/Communicator.ice +++ b/slice/Ice/Communicator.ice @@ -10,6 +10,8 @@ #ifndef ICE_COMMUNICATOR_ICE #define ICE_COMMUNICATOR_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Ice/CommunicatorF.ice b/slice/Ice/CommunicatorF.ice index 2ea5062d412..ea8ae669fe9 100644 --- a/slice/Ice/CommunicatorF.ice +++ b/slice/Ice/CommunicatorF.ice @@ -10,6 +10,8 @@ #ifndef ICE_COMMUNICATOR_F_ICE #define ICE_COMMUNICATOR_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Connection.ice b/slice/Ice/Connection.ice index 8603a697994..29d4c59562a 100644 --- a/slice/Ice/Connection.ice +++ b/slice/Ice/Connection.ice @@ -10,6 +10,8 @@ #ifndef ICE_CONNECTION_ICE #define ICE_CONNECTION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/ConnectionF.ice b/slice/Ice/ConnectionF.ice index f8602c60c90..b7c982d7537 100644 --- a/slice/Ice/ConnectionF.ice +++ b/slice/Ice/ConnectionF.ice @@ -10,6 +10,8 @@ #ifndef ICE_CONNECTION_F_ICE #define ICE_CONNECTION_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Current.ice b/slice/Ice/Current.ice index a3af5456927..40d46264adf 100644 --- a/slice/Ice/Current.ice +++ b/slice/Ice/Current.ice @@ -10,6 +10,8 @@ #ifndef ICE_CURRENT_ICE #define ICE_CURRENT_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Ice/Endpoint.ice b/slice/Ice/Endpoint.ice index 84732f8b089..fafd424fc3b 100644 --- a/slice/Ice/Endpoint.ice +++ b/slice/Ice/Endpoint.ice @@ -10,6 +10,8 @@ #ifndef ICE_ENDPOINT_ICE #define ICE_ENDPOINT_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/FacetMap.ice b/slice/Ice/FacetMap.ice index 09aefe146f0..6299bf8e5f6 100644 --- a/slice/Ice/FacetMap.ice +++ b/slice/Ice/FacetMap.ice @@ -10,6 +10,8 @@ #ifndef ICE_FACET_MAP_ICE #define ICE_FACET_MAP_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Identity.ice b/slice/Ice/Identity.ice index 736759de678..649fdcad838 100644 --- a/slice/Ice/Identity.ice +++ b/slice/Ice/Identity.ice @@ -10,6 +10,8 @@ #ifndef ICE_IDENTITY_ICE #define ICE_IDENTITY_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ImplicitContext.ice b/slice/Ice/ImplicitContext.ice index 2b26687aa33..40c53d54257 100644 --- a/slice/Ice/ImplicitContext.ice +++ b/slice/Ice/ImplicitContext.ice @@ -10,6 +10,8 @@ #ifndef ICE_IMPLICIT_CONTEXT_ICE #define ICE_IMPLICIT_CONTEXT_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/ImplicitContextF.ice b/slice/Ice/ImplicitContextF.ice index 4e4a552d522..8d91544e96f 100644 --- a/slice/Ice/ImplicitContextF.ice +++ b/slice/Ice/ImplicitContextF.ice @@ -10,6 +10,8 @@ #ifndef ICE_IMPLICIT_CONTEXT_F_ICE #define ICE_IMPLICIT_CONTEXT_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/LocalException.ice b/slice/Ice/LocalException.ice index b4cd5cba645..24923d87509 100644 --- a/slice/Ice/LocalException.ice +++ b/slice/Ice/LocalException.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOCAL_EXCEPTION_ICE #define ICE_LOCAL_EXCEPTION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/Locator.ice b/slice/Ice/Locator.ice index 8b5c74ea437..3b5325b90f4 100644 --- a/slice/Ice/Locator.ice +++ b/slice/Ice/Locator.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOCATOR_ICE #define ICE_LOCATOR_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/LocatorF.ice b/slice/Ice/LocatorF.ice index 2490e4a31e7..401b6f5040c 100644 --- a/slice/Ice/LocatorF.ice +++ b/slice/Ice/LocatorF.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOCATOR_F_ICE #define ICE_LOCATOR_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Logger.ice b/slice/Ice/Logger.ice index 42d4bcf2407..3baa235b7dd 100644 --- a/slice/Ice/Logger.ice +++ b/slice/Ice/Logger.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOGGER_ICE #define ICE_LOGGER_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/LoggerF.ice b/slice/Ice/LoggerF.ice index a162f3eecbc..567670b6bfb 100644 --- a/slice/Ice/LoggerF.ice +++ b/slice/Ice/LoggerF.ice @@ -10,6 +10,8 @@ #ifndef ICE_LOGGER_F_ICE #define ICE_LOGGER_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ObjectAdapter.ice b/slice/Ice/ObjectAdapter.ice index 264aa046784..c1d48a151e2 100644 --- a/slice/Ice/ObjectAdapter.ice +++ b/slice/Ice/ObjectAdapter.ice @@ -10,6 +10,8 @@ #ifndef ICE_OBJECT_ADAPTER_ICE #define ICE_OBJECT_ADAPTER_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/Ice/ObjectAdapterF.ice b/slice/Ice/ObjectAdapterF.ice index 47413a198d6..c124ba8f7fb 100644 --- a/slice/Ice/ObjectAdapterF.ice +++ b/slice/Ice/ObjectAdapterF.ice @@ -10,6 +10,8 @@ #ifndef ICE_OBJECT_ADAPTER_F_ICE #define ICE_OBJECT_ADAPTER_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ObjectFactory.ice b/slice/Ice/ObjectFactory.ice index 06593a58c24..8e97300c874 100644 --- a/slice/Ice/ObjectFactory.ice +++ b/slice/Ice/ObjectFactory.ice @@ -10,6 +10,8 @@ #ifndef ICE_OBJECT_FACTORY_ICE #define ICE_OBJECT_FACTORY_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ObjectFactoryF.ice b/slice/Ice/ObjectFactoryF.ice index 9b8f7fad0c5..fff74448aa0 100644 --- a/slice/Ice/ObjectFactoryF.ice +++ b/slice/Ice/ObjectFactoryF.ice @@ -7,8 +7,10 @@ // // ********************************************************************** -#ifndef ICE_SERVANT_FACTORY_F_ICE -#define ICE_SERVANT_FACTORY_F_ICE +#ifndef ICE_OBJECT_FACTORY_F_ICE +#define ICE_OBJECT_FACTORY_F_ICE + +[["cpp:header-ext:h"]] module Ice { diff --git a/slice/Ice/Plugin.ice b/slice/Ice/Plugin.ice index a872ed658aa..0d6e1515e9c 100644 --- a/slice/Ice/Plugin.ice +++ b/slice/Ice/Plugin.ice @@ -10,6 +10,8 @@ #ifndef ICE_PLUGIN_ICE #define ICE_PLUGIN_ICE +[["cpp:header-ext:h"]] + #include module Ice diff --git a/slice/Ice/PluginF.ice b/slice/Ice/PluginF.ice index 04aca2b7616..b30f0636adf 100644 --- a/slice/Ice/PluginF.ice +++ b/slice/Ice/PluginF.ice @@ -10,6 +10,8 @@ #ifndef ICE_PLUGIN_F_ICE #define ICE_PLUGIN_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Process.ice b/slice/Ice/Process.ice index 162e13d3958..1662775c1e3 100644 --- a/slice/Ice/Process.ice +++ b/slice/Ice/Process.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROCESS_ICE #define ICE_PROCESS_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ProcessF.ice b/slice/Ice/ProcessF.ice index 86951dc6fee..c9cb8d2297d 100644 --- a/slice/Ice/ProcessF.ice +++ b/slice/Ice/ProcessF.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROCESS_F_ICE #define ICE_PROCESS_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Properties.ice b/slice/Ice/Properties.ice index c391403c711..f193c00caab 100644 --- a/slice/Ice/Properties.ice +++ b/slice/Ice/Properties.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROPERTIES_ICE #define ICE_PROPERTIES_ICE +[["cpp:header-ext:h"]] + #include module Ice diff --git a/slice/Ice/PropertiesF.ice b/slice/Ice/PropertiesF.ice index cd93484aedb..8da07da5117 100644 --- a/slice/Ice/PropertiesF.ice +++ b/slice/Ice/PropertiesF.ice @@ -10,6 +10,8 @@ #ifndef ICE_PROPERTIES_F_ICE #define ICE_PROPERTIES_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Router.ice b/slice/Ice/Router.ice index 70b90801c31..385e353fc41 100644 --- a/slice/Ice/Router.ice +++ b/slice/Ice/Router.ice @@ -10,6 +10,8 @@ #ifndef ICE_ROUTER_ICE #define ICE_ROUTER_ICE +[["cpp:header-ext:h"]] + #include module Ice diff --git a/slice/Ice/RouterF.ice b/slice/Ice/RouterF.ice index 0bf87bd732b..47093b80825 100644 --- a/slice/Ice/RouterF.ice +++ b/slice/Ice/RouterF.ice @@ -10,6 +10,8 @@ #ifndef ICE_ROUTER_F_ICE #define ICE_ROUTER_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/ServantLocator.ice b/slice/Ice/ServantLocator.ice index 310c9c90ba5..504ea58e411 100644 --- a/slice/Ice/ServantLocator.ice +++ b/slice/Ice/ServantLocator.ice @@ -10,6 +10,8 @@ #ifndef ICE_SERVANT_LOCATOR_ICE #define ICE_SERVANT_LOCATOR_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/Ice/ServantLocatorF.ice b/slice/Ice/ServantLocatorF.ice index 458eff0d057..20e6398f4b0 100644 --- a/slice/Ice/ServantLocatorF.ice +++ b/slice/Ice/ServantLocatorF.ice @@ -10,6 +10,8 @@ #ifndef ICE_SERVANT_LOCATOR_F_ICE #define ICE_SERVANT_LOCATOR_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/SliceChecksumDict.ice b/slice/Ice/SliceChecksumDict.ice index 464081c54ea..87d2da1cd69 100644 --- a/slice/Ice/SliceChecksumDict.ice +++ b/slice/Ice/SliceChecksumDict.ice @@ -10,6 +10,8 @@ #ifndef ICE_SLICE_CHECKSUM_DICT_ICE #define ICE_SLICE_CHECKSUM_DICT_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/Stats.ice b/slice/Ice/Stats.ice index c6f57fb9ed6..45a58d25b31 100644 --- a/slice/Ice/Stats.ice +++ b/slice/Ice/Stats.ice @@ -10,6 +10,8 @@ #ifndef ICE_STATS_ICE #define ICE_STATS_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/Ice/StatsF.ice b/slice/Ice/StatsF.ice index 004858ab54c..540edd45712 100644 --- a/slice/Ice/StatsF.ice +++ b/slice/Ice/StatsF.ice @@ -10,6 +10,8 @@ #ifndef ICE_STATS_F_ICE #define ICE_STATS_F_ICE +[["cpp:header-ext:h"]] + module Ice { diff --git a/slice/IceBox/IceBox.ice b/slice/IceBox/IceBox.ice index b9c0c0cb118..e599a4323ef 100644 --- a/slice/IceBox/IceBox.ice +++ b/slice/IceBox/IceBox.ice @@ -10,6 +10,8 @@ #ifndef ICE_BOX_ICE_BOX_ICE #define ICE_BOX_ICE_BOX_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Admin.ice b/slice/IceGrid/Admin.ice index 8660878aca6..212392a148e 100644 --- a/slice/IceGrid/Admin.ice +++ b/slice/IceGrid/Admin.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_ADMIN_ICE #define ICE_GRID_ADMIN_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Descriptor.ice b/slice/IceGrid/Descriptor.ice index 3ac6dad3e41..2d1de16743b 100644 --- a/slice/IceGrid/Descriptor.ice +++ b/slice/IceGrid/Descriptor.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_DESCRIPTOR_ICE #define ICE_GRID_DESCRIPTOR_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/Exception.ice b/slice/IceGrid/Exception.ice index cbccce90ac0..0a2a692eb7e 100644 --- a/slice/IceGrid/Exception.ice +++ b/slice/IceGrid/Exception.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_EXCEPTION_ICE #define ICE_GRID_EXCEPTION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/FileParser.ice b/slice/IceGrid/FileParser.ice index d99633e116a..7b27455eeaa 100644 --- a/slice/IceGrid/FileParser.ice +++ b/slice/IceGrid/FileParser.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_FILE_PARSER_ICE #define ICE_GRID_FILE_PARSER_ICE +[["cpp:header-ext:h"]] + #include module IceGrid diff --git a/slice/IceGrid/Locator.ice b/slice/IceGrid/Locator.ice index a236b37b6a9..91877f6a8b2 100644 --- a/slice/IceGrid/Locator.ice +++ b/slice/IceGrid/Locator.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_LOCATOR_ICE #define ICE_GRID_LOCATOR_ICE +[["cpp:header-ext:h"]] + #include module IceGrid diff --git a/slice/IceGrid/Observer.ice b/slice/IceGrid/Observer.ice index abbd069664e..8b89278c2da 100644 --- a/slice/IceGrid/Observer.ice +++ b/slice/IceGrid/Observer.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_OBSERVER_ICE #define ICE_GRID_OBSERVER_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Query.ice b/slice/IceGrid/Query.ice index 2304e7edc77..4ea597e852c 100644 --- a/slice/IceGrid/Query.ice +++ b/slice/IceGrid/Query.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_QUERY_ICE #define ICE_GRID_QUERY_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/Registry.ice b/slice/IceGrid/Registry.ice index 5ef47fae173..6dd91bf6dae 100644 --- a/slice/IceGrid/Registry.ice +++ b/slice/IceGrid/Registry.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_REGISTRY_ICE #define ICE_GRID_REGISTRY_ICE +[["cpp:header-ext:h"]] + #include #include #include diff --git a/slice/IceGrid/Session.ice b/slice/IceGrid/Session.ice index ffd00c9f570..d071fc7ca6a 100644 --- a/slice/IceGrid/Session.ice +++ b/slice/IceGrid/Session.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_SESSION_ICE #define ICE_GRID_SESSION_ICE +[["cpp:header-ext:h"]] + #include #include diff --git a/slice/IceGrid/UserAccountMapper.ice b/slice/IceGrid/UserAccountMapper.ice index d145b08af50..4befb4da59b 100644 --- a/slice/IceGrid/UserAccountMapper.ice +++ b/slice/IceGrid/UserAccountMapper.ice @@ -10,6 +10,8 @@ #ifndef ICE_GRID_USERACCOUNTMAPPER_ICE #define ICE_GRID_USERACCOUNTMAPPER_ICE +[["cpp:header-ext:h"]] + module IceGrid { diff --git a/slice/IcePatch2/FileInfo.ice b/slice/IcePatch2/FileInfo.ice index 194d1034851..e85a784982b 100644 --- a/slice/IcePatch2/FileInfo.ice +++ b/slice/IcePatch2/FileInfo.ice @@ -10,6 +10,8 @@ #ifndef ICE_PATCH2_FILE_INFO_ICE #define ICE_PATCH2_FILE_INFO_ICE +[["cpp:header-ext:h"]] + #include module IcePatch2 diff --git a/slice/IcePatch2/FileServer.ice b/slice/IcePatch2/FileServer.ice index e18fb043bc4..7e1317c5de9 100644 --- a/slice/IcePatch2/FileServer.ice +++ b/slice/IcePatch2/FileServer.ice @@ -10,6 +10,8 @@ #ifndef ICE_PATCH2_FILE_SERVER_ICE #define ICE_PATCH2_FILE_SERVER_ICE +[["cpp:header-ext:h"]] + #include /** diff --git a/slice/IceStorm/IceStorm.ice b/slice/IceStorm/IceStorm.ice index 013ea0e6c23..8a0e96bd4dc 100644 --- a/slice/IceStorm/IceStorm.ice +++ b/slice/IceStorm/IceStorm.ice @@ -10,6 +10,8 @@ #ifndef ICE_STORM_ICE #define ICE_STORM_ICE +[["cpp:header-ext:h"]] + #include #include -- cgit v1.2.3 From d316cdad7d0a850a8a7828d5b9a7519123bbc29d Mon Sep 17 00:00:00 2001 From: Michi Henning Date: Wed, 28 Jan 2009 06:54:53 +1000 Subject: Squashed commit of the following: commit cf1aad9f7f2ef0df6dff5300249e2f6683a3ab66 Author: michi Date: Wed Jan 28 06:47:55 2009 +1000 Added test to C++ to include class with name that is a C++ keyword. The keyword tests for the other language mappings all already contained a class named with a keyword. commit 9dd664f3b3ac11c06936fbb5cf51bd8c2b6f87dd Author: michi Date: Wed Jan 28 06:34:39 2009 +1000 Bug 3677: slice2cpp generates bad code for class named with C++ keyword --- CHANGES | 3 +++ cpp/src/slice2cpp/Gen.cpp | 2 +- cpp/test/Slice/keyword/Client.cpp | 12 ++++++------ cpp/test/Slice/keyword/Key.ice | 8 ++++---- 4 files changed, 14 insertions(+), 11 deletions(-) (limited to 'cpp/src') diff --git a/CHANGES b/CHANGES index ae0b8ca51fb..568cce9efff 100644 --- a/CHANGES +++ b/CHANGES @@ -58,6 +58,9 @@ General Changes C++ Changes =========== +- Fixed bug in slice2cpp that caused bad code to be generated for classes + whose name was a C++ keyword. + - Fixed a bug in IceSSL where the IceSSL.CheckCertName property did not have any effect. diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 51ea19f40d2..22a033421c6 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -3857,7 +3857,7 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) H << sp << nl << scoped << " _init;"; H << eb << ';'; _doneStaticSymbol = true; - H << sp << nl << "static " << scoped << "__staticInit _" << p->name() << "_init;"; + H << sp << nl << "static " << p->name() << "__staticInit _" << p->name() << "_init;"; } if(p->isLocal()) diff --git a/cpp/test/Slice/keyword/Client.cpp b/cpp/test/Slice/keyword/Client.cpp index d96b6a8694a..5eaf65563a8 100644 --- a/cpp/test/Slice/keyword/Client.cpp +++ b/cpp/test/Slice/keyword/Client.cpp @@ -31,7 +31,7 @@ public: } }; -class complI: public _cpp_and::_cpp_compl +class switchI: public _cpp_and::_cpp_switch { public: virtual void foo(const _cpp_and::charPrx&, Ice::Int&, const ::Ice::Current&) @@ -58,15 +58,15 @@ class friendI : public _cpp_and::_cpp_friend public: virtual _cpp_and::_cpp_auto _cpp_goto(_cpp_and::_cpp_continue, const _cpp_and::_cpp_auto&, const _cpp_and::deletePtr&, - const _cpp_and::complPtr&, const _cpp_and::doPtr&, const _cpp_and::breakPrx&, - const _cpp_and::charPrx&, const _cpp_and::complPrx&, const _cpp_and::doPrx&, + const _cpp_and::switchPtr&, const _cpp_and::doPtr&, const _cpp_and::breakPrx&, + const _cpp_and::charPrx&, const _cpp_and::switchPrx&, const _cpp_and::doPrx&, ::Ice::Int, ::Ice::Int, ::Ice::Int, ::Ice::Int) { return _cpp_and::_cpp_auto(); } }; -class fooI : public _cpp_and::AMI_compl_foo +class fooI : public _cpp_and::AMI_switch_foo { public: @@ -99,9 +99,9 @@ testtypes() e->_cpp_explicit(); _cpp_and::charPtr e1 = new charI(); - _cpp_and::complPrx f; + _cpp_and::switchPrx f; f->foo_async(new fooI(), e); - _cpp_and::complPtr f1 = new complI(); + _cpp_and::switchPtr f1 = new switchI(); _cpp_and::doPrx g; g->_cpp_case(0, d2); diff --git a/cpp/test/Slice/keyword/Key.ice b/cpp/test/Slice/keyword/Key.ice index 2c4238c688c..bb1d0a8e311 100644 --- a/cpp/test/Slice/keyword/Key.ice +++ b/cpp/test/Slice/keyword/Key.ice @@ -35,12 +35,12 @@ interface char void explicit(); }; -class compl +class switch { ["ami"] void foo(char* export, out int volatile); }; -class do extends compl implements char, break +class do extends switch implements char, break { }; @@ -60,8 +60,8 @@ exception sizeof extends return local interface friend { - auto goto(continue if, auto d, delete inline, compl private, do mutable, break* namespace, - char* new, compl* not, do* operator, int or, int protected, int public, int register) + auto goto(continue if, auto d, delete inline, switch private, do mutable, break* namespace, + char* new, switch* not, do* operator, int or, int protected, int public, int register) throws return, sizeof; }; -- cgit v1.2.3