author | Lorenzo Bettini <bettini@dsi.unifi.it> | 2009年12月03日 21:56:33 +0100 |
---|---|---|
committer | Lorenzo Bettini <bettini@dsi.unifi.it> | 2009年12月03日 21:56:33 +0100 |
commit | 8d3510c735e74d0c88a18d0c78c918232255ab72 (patch) | |
tree | 216ece5c3ea4f7384789a116b60dd6cdbc878c0c | |
parent | 482fafe389d465b9bdf1a6189478bb0f693d4c04 (diff) | |
download | src-highlite-8d3510c735e74d0c88a18d0c78c918232255ab72.tar.gz |
-rw-r--r-- | lib/srchilite/langdefparser.cc | 2270 | ||||
-rw-r--r-- | lib/srchilite/langdefparser.h | 139 | ||||
-rw-r--r-- | lib/srchilite/langdefscanner.cc | 2361 | ||||
-rw-r--r-- | lib/srchilite/outlangdefparser.cc | 1993 | ||||
-rw-r--r-- | lib/srchilite/outlangdefparser.h | 125 | ||||
-rw-r--r-- | lib/srchilite/outlangdefscanner.cc | 2458 | ||||
-rw-r--r-- | lib/srchilite/srchilite.pro | 104 | ||||
-rw-r--r-- | lib/srchilite/stylecssparser.cc | 1872 | ||||
-rw-r--r-- | lib/srchilite/stylecssparser.h | 90 | ||||
-rw-r--r-- | lib/srchilite/stylecssscanner.cc | 2306 | ||||
-rw-r--r-- | lib/srchilite/styleparser.cc | 1923 | ||||
-rw-r--r-- | lib/srchilite/styleparser.h | 92 | ||||
-rw-r--r-- | lib/srchilite/stylescanner.cc | 2040 |
diff --git a/lib/srchilite/langdefparser.cc b/lib/srchilite/langdefparser.cc new file mode 100644 index 0000000..aec0c3e --- /dev/null +++ b/lib/srchilite/langdefparser.cc @@ -0,0 +1,2270 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by 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 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + +/* Substitute the variable and function names. */ +#define yyparse langdef_parse +#define yylex langdef_lex +#define yyerror langdef_error +#define yylval langdef_lval +#define yychar langdef_char +#define yydebug langdef_debug +#define yynerrs langdef_nerrs +#define yylloc langdef_lloc + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BEGIN_T = 258, + END_T = 259, + ENVIRONMENT_T = 260, + STATE_T = 261, + MULTILINE_T = 262, + DELIM_T = 263, + START_T = 264, + ESCAPE_T = 265, + NESTED_T = 266, + EXIT_ALL = 267, + EXIT_T = 268, + VARDEF_T = 269, + REDEF_T = 270, + SUBST_T = 271, + NONSENSITIVE_T = 272, + WRONG_BACKREFERENCE = 273, + LEVEL = 274, + KEY = 275, + STRINGDEF = 276, + REGEXPNOPREPROC = 277, + VARUSE = 278, + BACKREFVAR = 279, + WRONG_INCLUDE_FILE = 280, + REGEXPDEF = 281 + }; +#endif +/* Tokens. */ +#define BEGIN_T 258 +#define END_T 259 +#define ENVIRONMENT_T 260 +#define STATE_T 261 +#define MULTILINE_T 262 +#define DELIM_T 263 +#define START_T 264 +#define ESCAPE_T 265 +#define NESTED_T 266 +#define EXIT_ALL 267 +#define EXIT_T 268 +#define VARDEF_T 269 +#define REDEF_T 270 +#define SUBST_T 271 +#define NONSENSITIVE_T 272 +#define WRONG_BACKREFERENCE 273 +#define LEVEL 274 +#define KEY 275 +#define STRINGDEF 276 +#define REGEXPNOPREPROC 277 +#define VARUSE 278 +#define BACKREFVAR 279 +#define WRONG_INCLUDE_FILE 280 +#define REGEXPDEF 281 + + + + +/* Copy the first part of user declarations. */ +#line 1 "../../../lib/srchilite/langdefparser.yy" + +/* + * Copyright (C) 1999-2009 Lorenzo Bettini <http://www.lorenzobettini.it> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <iostream> +#include <string> + +#include "stringdef.h" +#include "statelangelem.h" +#include "statestartlangelem.h" +#include "stringlistlangelem.h" +#include "delimitedlangelem.h" +#include "langelems.h" +#include "langdefparserfun.h" +#include "langdefscanner.h" +#include "vardefinitions.h" +#include "namedsubexpslangelem.h" +#include "parserexception.h" +#include "ioexception.h" + +using std::cerr; +using std::string; + +using namespace srchilite; + +extern int langdef_lex() ; +extern FILE *langdef_in; +extern ParseStructPtr parsestruct; + +static void yyerror( const char *s ) ; +static void yyerror( const string &s ) ; + +/// the buffer for storing errors +static string errorBuffer; + +/// this is where the parsed elements are store +LangElems *current_lang_elems = 0; + +VarDefinitions *vardefinitions = 0; + +/// used to record that the error is due to an included file not found +static bool includedFileNotFound = false; + +#define UPDATE_REDEF(el, r) if (r == 1) { el->setRedef(); } else if (r == 2) { el->setSubst(); } +#define ADD_ELEMENT(elems, elem) \ + if (elem) { \ + if (elem->isRedef()) \ + elems->redef(elem); \ + else if (elem->isSubst()) \ + elems->subst(elem); \ + else \ + elems->add(elem); \ + } + +struct Key : public ParserInfo +{ + const string *key; + + ~Key() { + /* the string belongs to the string table so it is + deallocated automatically by clearing the scanner */ + } +}; + +// this is a trick since ElementNames is a typedef and cannot +// be used in the union below +struct ElementNamesList : ElementNames { +}; + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 91 "../../../lib/srchilite/langdefparser.yy" +{ + int tok ; /* command */ + bool booloption ; + const std::string * string ; /* string : id, ... */ + class srchilite::StringDef *stringdef; + class StringDefs *stringdefs; + class LangElem *langelem; + class StateLangElem *statelangelem; + class StateStartLangElem *statestartlangelem; + class LangElems *langelems; + class NamedSubExpsLangElem *namedsubexpslangelem; + struct Key *key; + struct ElementNamesList *keys; + int flag ; + unsigned int level; +} +/* Line 187 of yacc.c. */ +#line 263 "langdefparser.cc" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 216 of yacc.c. */ +#line 288 "langdefparser.cc" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss; + YYSTYPE yyvs; + YYLTYPE yyls; +}; + +/* 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 (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * 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 \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (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 (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 10 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 81 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 32 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 18 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 49 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 71 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 281 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 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, + 28, 29, 2, 31, 30, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 27, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 6, 9, 11, 15, 22, 27, + 29, 37, 41, 46, 52, 54, 58, 60, 63, 64, + 66, 69, 70, 72, 73, 75, 77, 79, 80, 82, + 84, 85, 87, 88, 90, 91, 95, 97, 99, 101, + 103, 105, 107, 111, 113, 115, 117, 119, 121, 125 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 33, 0, -1, -1, 34, -1, 34, 35, -1, 35, + -1, 44, 36, 40, -1, 44, 42, 36, 3, 34, + 4, -1, 14, 20, 27, 47, -1, 25, -1, 37, + 8, 49, 48, 39, 43, 45, -1, 37, 9, 49, + -1, 37, 27, 47, 46, -1, 28, 38, 29, 27, + 22, -1, 20, -1, 38, 30, 20, -1, 20, -1, + 10, 49, -1, -1, 12, -1, 13, 41, -1, -1, + 19, -1, -1, 5, -1, 6, -1, 7, -1, -1, + 15, -1, 16, -1, -1, 11, -1, -1, 17, -1, + -1, 47, 30, 49, -1, 49, -1, 26, -1, 21, + -1, 22, -1, 23, -1, 24, -1, 48, 31, 48, + -1, 18, -1, 26, -1, 21, -1, 22, -1, 23, + -1, 49, 31, 49, -1, 18, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 134, 134, 143, 146, 150, 156, 165, 173, 177, + 188, 195, 200, 206, 212, 219, 224, 231, 232, 235, + 236, 237, 240, 241, 244, 245, 248, 249, 252, 253, + 254, 257, 258, 261, 262, 265, 266, 271, 274, 277, + 280, 287, 291, 296, 306, 309, 312, 315, 322, 327 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[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", "BEGIN_T", "END_T", "ENVIRONMENT_T", + "STATE_T", "MULTILINE_T", "DELIM_T", "START_T", "ESCAPE_T", "NESTED_T", + "EXIT_ALL", "EXIT_T", "VARDEF_T", "REDEF_T", "SUBST_T", "NONSENSITIVE_T", + "WRONG_BACKREFERENCE", "LEVEL", "KEY", "STRINGDEF", "REGEXPNOPREPROC", + "VARUSE", "BACKREFVAR", "WRONG_INCLUDE_FILE", "REGEXPDEF", "'='", "'('", + "')'", "','", "'+'", "$accept", "allelements", "elemdefs", "elemdef", + "complexelem", "key", "keys", "escapedef", "exitlevel", "level", + "startnewenv", "multiline", "redefsubst", "nested", "nonsensitive", + "stringdefs", "stringdefwreferences", "stringdef", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 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, 61, 40, 41, + 44, 43 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 32, 33, 33, 34, 34, 35, 35, 35, 35, + 36, 36, 36, 36, 37, 38, 38, 39, 39, 40, + 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, + 44, 45, 45, 46, 46, 47, 47, 48, 48, 48, + 48, 48, 48, 48, 49, 49, 49, 49, 49, 49 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 2, 1, 3, 6, 4, 1, + 7, 3, 4, 5, 1, 3, 1, 2, 0, 1, + 2, 0, 1, 0, 1, 1, 1, 0, 1, 1, + 0, 1, 0, 1, 0, 3, 1, 1, 1, 1, + 1, 1, 3, 1, 1, 1, 1, 1, 3, 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 yytype_uint8 yydefact[] = +{ + 30, 0, 28, 29, 9, 0, 30, 5, 0, 0, + 1, 4, 24, 25, 14, 0, 21, 0, 0, 0, + 16, 0, 19, 23, 6, 0, 0, 0, 0, 49, + 45, 46, 47, 44, 8, 36, 0, 0, 22, 20, + 0, 11, 34, 30, 0, 0, 0, 15, 43, 38, + 39, 40, 41, 37, 18, 33, 12, 30, 35, 48, + 13, 0, 0, 27, 7, 17, 42, 26, 32, 31, + 10 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 5, 6, 7, 16, 17, 21, 63, 24, 39, + 18, 68, 8, 70, 56, 34, 54, 35 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -25 +static const yytype_int8 yypact[] = +{ + 3, -13, -25, -25, -25, 31, 8, -25, 6, 11, + -25, -25, -25, -25, -25, 23, -3, 21, -15, 50, + -25, 17, -25, 16, -25, 50, 50, 50, 47, -25, + -25, -25, -25, -25, 25, 26, 29, 39, -25, -25, + 18, 26, 15, 38, 50, 50, 36, -25, -25, -25, + -25, -25, -25, -25, -4, -25, -25, 0, 26, 26, + -25, 50, 43, 53, -25, 26, 44, -25, 51, -25, + -25 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -25, -25, 27, -6, 56, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, 52, 19, -24 +}; + +/* 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 yytype_int8 yytable[] = +{ + 11, 40, 41, -2, 64, 14, 61, 9, -3, 22, + 23, 12, 13, 15, 1, 2, 3, 1, 2, 3, + 58, 59, 1, 2, 3, 4, 14, 62, 4, 25, + 26, 10, 55, 4, 15, 38, 48, 65, 19, 49, + 50, 51, 52, 20, 53, 44, 36, 37, 27, 45, + 43, 11, 1, 2, 3, 44, 46, 45, 60, 47, + 67, 48, 69, 4, 49, 50, 51, 52, 29, 53, + 57, 30, 31, 32, 28, 62, 33, 0, 0, 42, + 0, 66 +}; + +static const yytype_int8 yycheck[] = +{ + 6, 25, 26, 0, 4, 20, 10, 20, 0, 12, + 13, 5, 6, 28, 14, 15, 16, 14, 15, 16, + 44, 45, 14, 15, 16, 25, 20, 31, 25, 8, + 9, 0, 17, 25, 28, 19, 18, 61, 27, 21, + 22, 23, 24, 20, 26, 30, 29, 30, 27, 31, + 3, 57, 14, 15, 16, 30, 27, 31, 22, 20, + 7, 18, 11, 25, 21, 22, 23, 24, 18, 26, + 43, 21, 22, 23, 18, 31, 26, -1, -1, 27, + -1, 62 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 14, 15, 16, 25, 33, 34, 35, 44, 20, + 0, 35, 5, 6, 20, 28, 36, 37, 42, 27, + 20, 38, 12, 13, 40, 8, 9, 27, 36, 18, + 21, 22, 23, 26, 47, 49, 29, 30, 19, 41, + 49, 49, 47, 3, 30, 31, 27, 20, 18, 21, + 22, 23, 24, 26, 48, 17, 46, 34, 49, 49, + 22, 10, 31, 39, 4, 49, 48, 7, 43, 11, + 45 +}; + +#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 (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; 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 (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yylsp, yyrule) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) ); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, yylsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, 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 + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# 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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '0円') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '0円'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '0円'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '0円') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yylocationp); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + case 34: /* "elemdefs" */ +#line 126 "../../../lib/srchilite/langdefparser.yy" + { + //std::cout << "freeing discarded symbol" << std::endl; + delete (yyvaluep->langelems); +}; +#line 1255 "langdefparser.cc" + break; + case 35: /* "elemdef" */ +#line 126 "../../../lib/srchilite/langdefparser.yy" + { + //std::cout << "freeing discarded symbol" << std::endl; + delete (yyvaluep->langelem); +}; +#line 1263 "langdefparser.cc" + break; + case 37: /* "key" */ +#line 126 "../../../lib/srchilite/langdefparser.yy" + { + //std::cout << "freeing discarded symbol" << std::endl; + delete (yyvaluep->key); +}; +#line 1271 "langdefparser.cc" + break; + case 38: /* "keys" */ +#line 126 "../../../lib/srchilite/langdefparser.yy" + { + //std::cout << "freeing discarded symbol" << std::endl; + delete (yyvaluep->keys); +}; +#line 1279 "langdefparser.cc" + break; + case 47: /* "stringdefs" */ +#line 126 "../../../lib/srchilite/langdefparser.yy" + { + //std::cout << "freeing discarded symbol" << std::endl; + delete (yyvaluep->stringdefs); +}; +#line 1287 "langdefparser.cc" + break; + case 49: /* "stringdef" */ +#line 126 "../../../lib/srchilite/langdefparser.yy" + { + //std::cout << "freeing discarded symbol" << std::endl; + delete (yyvaluep->stringdef); +}; +#line 1295 "langdefparser.cc" + break; + + 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 */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; +/* Location data for the look-ahead symbol. */ +YYLTYPE yylloc; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* 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. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + 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; + yylsp = yyls; +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 0; +#endif + + 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; + yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* 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 (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + YYSTACK_RELOCATE (yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + 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 + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead 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); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; + 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]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 134 "../../../lib/srchilite/langdefparser.yy" + { + /* no definitions (i.e., empty a .lang file with no definition) */ + /* such as, default.lang */ + /* synthetize a normal elem that catches everything */ + current_lang_elems = new LangElems; + StringDefs *defs = new StringDefs; + defs->push_back (new StringDef("(?:.+)")); + current_lang_elems->add(new StringListLangElem("normal", defs, false)); + } + break; + + case 3: +#line 143 "../../../lib/srchilite/langdefparser.yy" + { current_lang_elems = (yyvsp[(1) - (1)].langelems); } + break; + + case 4: +#line 146 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.langelems) = (yyvsp[(1) - (2)].langelems); + ADD_ELEMENT((yyval.langelems), (yyvsp[(2) - (2)].langelem)); + } + break; + + case 5: +#line 150 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.langelems) = new LangElems; + ADD_ELEMENT((yyval.langelems), (yyvsp[(1) - (1)].langelem)); + } + break; + + case 6: +#line 157 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.langelem) = (yyvsp[(2) - (3)].statestartlangelem); + if ((yyvsp[(3) - (3)].tok) < 0) + (yyvsp[(2) - (3)].statestartlangelem)->setExitAll(); + if ((yyvsp[(3) - (3)].tok) > 0) + (yyvsp[(2) - (3)].statestartlangelem)->setExit((yyvsp[(3) - (3)].tok)); + UPDATE_REDEF((yyvsp[(2) - (3)].statestartlangelem), (yyvsp[(1) - (3)].tok)); + } + break; + + case 7: +#line 166 "../../../lib/srchilite/langdefparser.yy" + { + StateLangElem *statelangelem = new StateLangElem((yyvsp[(3) - (6)].statestartlangelem)->getName(), (yyvsp[(3) - (6)].statestartlangelem), (yyvsp[(5) - (6)].langelems), !(yyvsp[(2) - (6)].booloption)); + (yyval.langelem) = statelangelem; + (yyvsp[(3) - (6)].statestartlangelem)->setStateLangElem(statelangelem); + + UPDATE_REDEF((yyval.langelem), (yyvsp[(1) - (6)].tok)); + } + break; + + case 8: +#line 173 "../../../lib/srchilite/langdefparser.yy" + { + vardefinitions->add(*(yyvsp[(2) - (4)].string), (yyvsp[(4) - (4)].stringdefs)); + (yyval.langelem) = 0; + } + break; + + case 9: +#line 177 "../../../lib/srchilite/langdefparser.yy" + { + // this token is used by the scanner to signal an error + // in opening an include file + includedFileNotFound = true; + yyerror("cannot open include file " + *(yyvsp[(1) - (1)].string)); + YYERROR; + + (yyval.langelem) = 0; + } + break; + + case 10: +#line 189 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.statestartlangelem) = new DelimitedLangElem(*((yyvsp[(1) - (7)].key)->key), (yyvsp[(3) - (7)].stringdef), (yyvsp[(4) - (7)].stringdef), (yyvsp[(5) - (7)].stringdef), (yyvsp[(6) - (7)].booloption), (yyvsp[(7) - (7)].booloption)); + (yyval.statestartlangelem)->setParserInfo((yyvsp[(1) - (7)].key)); + + delete (yyvsp[(1) - (7)].key); + } + break; + + case 11: +#line 195 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.statestartlangelem) = new DelimitedLangElem(*((yyvsp[(1) - (3)].key)->key), (yyvsp[(3) - (3)].stringdef), 0, 0, false, false); + (yyval.statestartlangelem)->setParserInfo((yyvsp[(1) - (3)].key)); + delete (yyvsp[(1) - (3)].key); + } + break; + + case 12: +#line 200 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.statestartlangelem) = new StringListLangElem(*((yyvsp[(1) - (4)].key)->key), (yyvsp[(3) - (4)].stringdefs), (yyvsp[(4) - (4)].booloption)); + (yyval.statestartlangelem)->setParserInfo((yyvsp[(1) - (4)].key)); + + delete (yyvsp[(1) - (4)].key); + } + break; + + case 13: +#line 206 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.statestartlangelem) = new NamedSubExpsLangElem((yyvsp[(2) - (5)].keys), new StringDef(*(yyvsp[(5) - (5)].string))); + (yyval.statestartlangelem)->setParserInfo(parsestruct->file_name, (yylsp[(1) - (5)]).first_line); + } + break; + + case 14: +#line 212 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.key) = new Key; + (yyval.key)->key = (yyvsp[(1) - (1)].string); + (yyval.key)->setParserInfo(parsestruct->file_name, (yylsp[(1) - (1)]).first_line); + } + break; + + case 15: +#line 220 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.keys) = (yyvsp[(1) - (3)].keys); + (yyval.keys)->push_back(*(yyvsp[(3) - (3)].string)); + } + break; + + case 16: +#line 225 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.keys) = new ElementNamesList; + (yyval.keys)->push_back(*(yyvsp[(1) - (1)].string)); + } + break; + + case 17: +#line 231 "../../../lib/srchilite/langdefparser.yy" + { (yyval.stringdef) = (yyvsp[(2) - (2)].stringdef); } + break; + + case 18: +#line 232 "../../../lib/srchilite/langdefparser.yy" + { (yyval.stringdef) = 0; } + break; + + case 19: +#line 235 "../../../lib/srchilite/langdefparser.yy" + { (yyval.tok) = -1; } + break; + + case 20: +#line 236 "../../../lib/srchilite/langdefparser.yy" + { (yyval.tok) = (yyvsp[(2) - (2)].level); } + break; + + case 21: +#line 237 "../../../lib/srchilite/langdefparser.yy" + { (yyval.tok) = 0; } + break; + + case 22: +#line 240 "../../../lib/srchilite/langdefparser.yy" + { (yyval.level) = (yyvsp[(1) - (1)].level); } + break; + + case 23: +#line 241 "../../../lib/srchilite/langdefparser.yy" + { (yyval.level) = 1; } + break; + + case 24: +#line 244 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = true; } + break; + + case 25: +#line 245 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = false; } + break; + + case 26: +#line 248 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = true; } + break; + + case 27: +#line 249 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = false; } + break; + + case 28: +#line 252 "../../../lib/srchilite/langdefparser.yy" + { (yyval.tok) = 1; } + break; + + case 29: +#line 253 "../../../lib/srchilite/langdefparser.yy" + { (yyval.tok) = 2; } + break; + + case 30: +#line 254 "../../../lib/srchilite/langdefparser.yy" + { (yyval.tok) = 0; } + break; + + case 31: +#line 257 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = true; } + break; + + case 32: +#line 258 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = false; } + break; + + case 33: +#line 261 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = true; } + break; + + case 34: +#line 262 "../../../lib/srchilite/langdefparser.yy" + { (yyval.booloption) = false; } + break; + + case 35: +#line 265 "../../../lib/srchilite/langdefparser.yy" + { (yyval.stringdefs) = (yyvsp[(1) - (3)].stringdefs); (yyval.stringdefs)->push_back((yyvsp[(3) - (3)].stringdef)); } + break; + + case 36: +#line 266 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdefs) = new StringDefs; + (yyval.stringdefs)->push_back((yyvsp[(1) - (1)].stringdef)); } + break; + + case 37: +#line 271 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = (yyvsp[(1) - (1)].stringdef); + } + break; + + case 38: +#line 274 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = new StringDef(*(yyvsp[(1) - (1)].string), true); + } + break; + + case 39: +#line 277 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = new StringDef(*(yyvsp[(1) - (1)].string)); + } + break; + + case 40: +#line 280 "../../../lib/srchilite/langdefparser.yy" + { + if (! vardefinitions->contains(*(yyvsp[(1) - (1)].string))) { + yyerror("undefined variable " + *(yyvsp[(1) - (1)].string)); + YYERROR; + } + (yyval.stringdef) = new StringDef(vardefinitions->getVar(*(yyvsp[(1) - (1)].string))); + } + break; + + case 41: +#line 287 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = new StringDef(*(yyvsp[(1) - (1)].string)); + (yyval.stringdef)->setBackRef(true); + } + break; + + case 42: +#line 291 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = StringDef::concat((yyvsp[(1) - (3)].stringdef), (yyvsp[(3) - (3)].stringdef)); + delete (yyvsp[(1) - (3)].stringdef); + delete (yyvsp[(3) - (3)].stringdef); + } + break; + + case 43: +#line 296 "../../../lib/srchilite/langdefparser.yy" + { + // this token is used by the scanner to signal an error + // in scanning a string with backreference + yyerror("backreferences are allowed only inside ` `"); + YYERROR; + + (yyval.stringdef) = 0; + } + break; + + case 44: +#line 306 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = (yyvsp[(1) - (1)].stringdef); + } + break; + + case 45: +#line 309 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = new StringDef(*(yyvsp[(1) - (1)].string), true); + } + break; + + case 46: +#line 312 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = new StringDef(*(yyvsp[(1) - (1)].string)); + } + break; + + case 47: +#line 315 "../../../lib/srchilite/langdefparser.yy" + { + if (! vardefinitions->contains(*(yyvsp[(1) - (1)].string))) { + yyerror("undefined variable " + *(yyvsp[(1) - (1)].string)); + YYERROR; + } + (yyval.stringdef) = new StringDef(vardefinitions->getVar(*(yyvsp[(1) - (1)].string))); + } + break; + + case 48: +#line 322 "../../../lib/srchilite/langdefparser.yy" + { + (yyval.stringdef) = StringDef::concat((yyvsp[(1) - (3)].stringdef), (yyvsp[(3) - (3)].stringdef)); + delete (yyvsp[(1) - (3)].stringdef); + delete (yyvsp[(3) - (3)].stringdef); + } + break; + + case 49: +#line 327 "../../../lib/srchilite/langdefparser.yy" + { + // this token is used by the scanner to signal an error + // in scanning a string with backreference + yyerror("backreferences are allowed only inside ` `"); + YYERROR; + + (yyval.stringdef) = 0; + } + break; + + +/* Line 1267 of yacc.c. */ +#line 1975 "langdefparser.cc" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* 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 + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + 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; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the look-ahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 337 "../../../lib/srchilite/langdefparser.yy" + + +extern int langdef_lex_destroy (void); + +void +yyerror( const char *s ) +{ + errorBuffer = s; +} + +void +yyerror( const string &s ) +{ + yyerror(s.c_str()); +} + +namespace srchilite { + +LangElems * +parse_lang_def() +{ + return parse_lang_def("", "stdin"); +} + +LangElems * +parse_lang_def(const char *path, const char *name) +{ + current_lang_elems = 0; + includedFileNotFound = false; + vardefinitions = new VarDefinitions; + parsestruct = ParseStructPtr(new ParseStruct(path, name)); + + errorBuffer = ""; + int result = 1; + bool fileNotFound = false; + + try { + if (strcmp(name, "stdin") != 0) + open_file_to_scan(path, name); + } catch (IOException &e) { + errorBuffer = e.message; + fileNotFound = true; + } + + if (!fileNotFound) + result = langdef_parse(); + + delete vardefinitions; + + vardefinitions = 0; + + if (result != 0 && ! fileNotFound) { + // make sure the input file is closed + close_langdefinputfile(); + // close it before clearing the scanner + } + + // release scanner memory + clear_langdefscanner (); + + if (result != 0 || errorBuffer.size()) { + if (fileNotFound || includedFileNotFound) { + if (current_lang_elems) delete current_lang_elems; + throw ParserException(errorBuffer); + } else { + ParserException e(errorBuffer, parsestruct.get()); + if (current_lang_elems) delete current_lang_elems; + throw e; + } + } + + return current_lang_elems; +} + +} + diff --git a/lib/srchilite/langdefparser.h b/lib/srchilite/langdefparser.h new file mode 100644 index 0000000..fa4ea75 --- /dev/null +++ b/lib/srchilite/langdefparser.h @@ -0,0 +1,139 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BEGIN_T = 258, + END_T = 259, + ENVIRONMENT_T = 260, + STATE_T = 261, + MULTILINE_T = 262, + DELIM_T = 263, + START_T = 264, + ESCAPE_T = 265, + NESTED_T = 266, + EXIT_ALL = 267, + EXIT_T = 268, + VARDEF_T = 269, + REDEF_T = 270, + SUBST_T = 271, + NONSENSITIVE_T = 272, + WRONG_BACKREFERENCE = 273, + LEVEL = 274, + KEY = 275, + STRINGDEF = 276, + REGEXPNOPREPROC = 277, + VARUSE = 278, + BACKREFVAR = 279, + WRONG_INCLUDE_FILE = 280, + REGEXPDEF = 281 + }; +#endif +/* Tokens. */ +#define BEGIN_T 258 +#define END_T 259 +#define ENVIRONMENT_T 260 +#define STATE_T 261 +#define MULTILINE_T 262 +#define DELIM_T 263 +#define START_T 264 +#define ESCAPE_T 265 +#define NESTED_T 266 +#define EXIT_ALL 267 +#define EXIT_T 268 +#define VARDEF_T 269 +#define REDEF_T 270 +#define SUBST_T 271 +#define NONSENSITIVE_T 272 +#define WRONG_BACKREFERENCE 273 +#define LEVEL 274 +#define KEY 275 +#define STRINGDEF 276 +#define REGEXPNOPREPROC 277 +#define VARUSE 278 +#define BACKREFVAR 279 +#define WRONG_INCLUDE_FILE 280 +#define REGEXPDEF 281 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 91 "../../../lib/srchilite/langdefparser.yy" +{ + int tok ; /* command */ + bool booloption ; + const std::string * string ; /* string : id, ... */ + class srchilite::StringDef *stringdef; + class StringDefs *stringdefs; + class LangElem *langelem; + class StateLangElem *statelangelem; + class StateStartLangElem *statestartlangelem; + class LangElems *langelems; + class NamedSubExpsLangElem *namedsubexpslangelem; + struct Key *key; + struct ElementNamesList *keys; + int flag ; + unsigned int level; +} +/* Line 1489 of yacc.c. */ +#line 118 "langdefparser.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE langdef_lval; + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + +extern YYLTYPE langdef_lloc; diff --git a/lib/srchilite/langdefscanner.cc b/lib/srchilite/langdefscanner.cc new file mode 100644 index 0000000..8297d5c --- /dev/null +++ b/lib/srchilite/langdefscanner.cc @@ -0,0 +1,2361 @@ +#line 2 "langdefscanner.cc" + +#line 4 "langdefscanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer langdef__create_buffer +#define yy_delete_buffer langdef__delete_buffer +#define yy_flex_debug langdef__flex_debug +#define yy_init_buffer langdef__init_buffer +#define yy_flush_buffer langdef__flush_buffer +#define yy_load_buffer_state langdef__load_buffer_state +#define yy_switch_to_buffer langdef__switch_to_buffer +#define yyin langdef_in +#define yyleng langdef_leng +#define yylex langdef_lex +#define yylineno langdef_lineno +#define yyout langdef_out +#define yyrestart langdef_restart +#define yytext langdef_text +#define yywrap langdef_wrap +#define yyalloc langdef_alloc +#define yyrealloc langdef_realloc +#define yyfree langdef_free + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* 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 langdef_restart(langdef_in ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int langdef_leng; + +extern FILE *langdef_in, *langdef_out; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up langdef_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up langdef_text again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + 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; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via langdef_restart()), so that the user can continue scanning by + * just pointing langdef_in at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when langdef_text is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int langdef_leng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow langdef_wrap()'s to do buffer switches + * instead of setting up a fresh langdef_in. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void langdef_restart (FILE *input_file ); +void langdef__switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE langdef__create_buffer (FILE *file,int size ); +void langdef__delete_buffer (YY_BUFFER_STATE b ); +void langdef__flush_buffer (YY_BUFFER_STATE b ); +void langdef_push_buffer_state (YY_BUFFER_STATE new_buffer ); +void langdef_pop_buffer_state (void ); + +static void langdef_ensure_buffer_stack (void ); +static void langdef__load_buffer_state (void ); +static void langdef__init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER langdef__flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE langdef__scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE langdef__scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE langdef__scan_bytes (yyconst char *bytes,int len ); + +void *langdef_alloc (yy_size_t ); +void *langdef_realloc (void *,yy_size_t ); +void langdef_free (void * ); + +#define yy_new_buffer langdef__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + langdef_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + langdef__create_buffer(langdef_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + langdef_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + langdef__create_buffer(langdef_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define langdef_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *langdef_in = (FILE *) 0, *langdef_out = (FILE *) 0; + +typedef int yy_state_type; + +extern int langdef_lineno; + +int langdef_lineno = 1; + +extern char *langdef_text; +#define yytext_ptr langdef_text + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up langdef_text. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + langdef_leng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '0円'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 58 +#define YY_END_OF_BUFFER 59 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[164] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 59, 57, 1, 55, 2, 31, 3, 57, + 40, 29, 30, 28, 27, 56, 26, 57, 25, 48, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 4, + 1, 5, 2, 38, 39, 2, 37, 32, 38, 46, + 47, 2, 45, 41, 46, 53, 54, 2, 49, 53, + 52, 58, 1, 2, 58, 23, 56, 0, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 36, 35, 34, 33, 44, 43, 42, 50, + 51, 0, 23, 0, 25, 25, 7, 25, 25, 25, + + 25, 25, 25, 25, 25, 25, 25, 25, 22, 24, + 25, 25, 25, 25, 16, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 6, 11, 25, 25, 25, 25, + 25, 25, 25, 18, 12, 9, 19, 25, 25, 13, + 25, 25, 25, 14, 25, 17, 25, 15, 21, 25, + 25, 25, 25, 25, 25, 10, 25, 25, 25, 8, + 25, 20, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 5, 6, 7, 1, 1, 8, 9, + 10, 11, 12, 13, 1, 14, 1, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 1, 1, 1, + 16, 1, 17, 18, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 20, 21, 22, 23, 19, 24, 25, 26, 27, 28, + + 29, 30, 31, 19, 32, 19, 19, 33, 34, 35, + 36, 37, 19, 38, 39, 40, 41, 42, 19, 43, + 19, 19, 44, 45, 46, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[47] = + { 0, + 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 3, 1, 1, 1, 4, 1, + 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[173] = + { 0, + 0, 0, 45, 48, 50, 94, 71, 115, 62, 106, + 80, 86, 235, 236, 236, 236, 236, 236, 236, 0, + 236, 236, 236, 236, 236, 219, 236, 189, 0, 236, + 203, 202, 86, 195, 188, 27, 199, 36, 202, 236, + 236, 236, 236, 236, 236, 236, 236, 236, 126, 236, + 236, 236, 236, 236, 92, 236, 236, 236, 236, 57, + 236, 236, 236, 236, 0, 0, 211, 210, 0, 193, + 190, 92, 195, 189, 193, 186, 179, 182, 188, 190, + 188, 175, 236, 236, 236, 236, 236, 236, 236, 236, + 236, 207, 0, 165, 178, 177, 0, 176, 182, 166, + + 172, 164, 163, 163, 172, 55, 161, 167, 236, 236, + 135, 135, 130, 130, 141, 124, 132, 134, 133, 131, + 120, 130, 118, 128, 0, 0, 120, 126, 121, 125, + 119, 123, 115, 0, 0, 0, 0, 119, 113, 0, + 113, 116, 112, 0, 104, 0, 108, 0, 0, 104, + 105, 106, 103, 88, 91, 0, 90, 62, 45, 0, + 40, 0, 236, 171, 175, 179, 183, 187, 54, 189, + 193, 195 + } ; + +static yyconst flex_int16_t yy_def[173] = + { 0, + 163, 1, 164, 164, 165, 165, 166, 166, 167, 167, + 168, 168, 163, 163, 163, 163, 163, 163, 163, 169, + 163, 163, 163, 163, 163, 163, 163, 163, 170, 163, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 171, 172, 163, 163, 170, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 171, 172, 163, 170, 170, 170, 170, 170, 170, + + 170, 170, 170, 170, 170, 170, 170, 170, 163, 163, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 170, 170, 170, 170, 170, 170, 170, 170, + 170, 170, 0, 163, 163, 163, 163, 163, 163, 163, + 163, 163 + } ; + +static yyconst flex_int16_t yy_nxt[283] = + { 0, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 14, 24, 25, 14, 26, 27, 14, 28, 29, 14, + 14, 14, 14, 30, 29, 31, 29, 32, 33, 29, + 29, 34, 29, 35, 36, 29, 29, 37, 38, 29, + 29, 39, 29, 14, 14, 14, 41, 42, 43, 41, + 42, 43, 45, 46, 47, 77, 48, 66, 48, 48, + 48, 48, 78, 48, 57, 58, 48, 48, 162, 48, + 49, 48, 48, 51, 52, 80, 81, 90, 53, 59, + 91, 63, 60, 64, 65, 61, 161, 63, 54, 64, + 65, 55, 121, 48, 122, 48, 45, 46, 47, 87, + + 48, 160, 48, 48, 48, 48, 88, 48, 57, 58, + 48, 48, 89, 48, 49, 48, 48, 51, 52, 97, + 72, 159, 53, 59, 73, 158, 60, 157, 74, 61, + 83, 156, 54, 98, 155, 55, 154, 48, 153, 48, + 84, 152, 151, 150, 149, 148, 85, 147, 146, 145, + 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, + 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, + 86, 40, 40, 40, 40, 44, 44, 44, 44, 50, + 50, 50, 50, 56, 56, 56, 56, 62, 62, 62, + 62, 69, 69, 92, 124, 92, 92, 93, 93, 123, + + 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, + 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, + 100, 99, 96, 95, 94, 67, 82, 79, 76, 75, + 71, 70, 68, 67, 163, 13, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163 + } ; + +static yyconst flex_int16_t yy_chk[283] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 3, 3, 3, 4, + 4, 4, 5, 5, 5, 36, 5, 169, 5, 5, + 5, 5, 36, 5, 9, 9, 5, 5, 161, 5, + 5, 5, 5, 7, 7, 38, 38, 60, 7, 9, + 60, 11, 9, 11, 11, 9, 159, 12, 7, 12, + 12, 7, 106, 5, 106, 5, 6, 6, 6, 55, + + 6, 158, 6, 6, 6, 6, 55, 6, 10, 10, + 6, 6, 55, 6, 6, 6, 6, 8, 8, 72, + 33, 157, 8, 10, 33, 155, 10, 154, 33, 10, + 49, 153, 8, 72, 152, 8, 151, 6, 150, 6, + 49, 147, 145, 143, 142, 141, 49, 139, 138, 133, + 132, 131, 130, 129, 128, 127, 124, 123, 122, 121, + 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, + 49, 164, 164, 164, 164, 165, 165, 165, 165, 166, + 166, 166, 166, 167, 167, 167, 167, 168, 168, 168, + 168, 170, 170, 171, 108, 171, 171, 172, 172, 107, + + 105, 104, 103, 102, 101, 100, 99, 98, 96, 95, + 94, 92, 82, 81, 80, 79, 78, 77, 76, 75, + 74, 73, 71, 70, 68, 67, 39, 37, 35, 34, + 32, 31, 28, 26, 13, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163, 163, 163, 163, 163, 163, 163, 163, 163, + 163, 163 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int langdef__flex_debug; +int langdef__flex_debug = 0; + +/* 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 *langdef_text; +#line 1 "../../../lib/srchilite/langdefscanner.ll" +#line 2 "../../../lib/srchilite/langdefscanner.ll" +/* + * Copyright (C) 1999-2009, Lorenzo Bettini, http://www.lorenzobettini.it + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <cstdlib> +#include <sstream> +#include "stringdef.h" +#include "stringtable.h" +#include "langdefparser.h" +#include "langdefscanner.h" +#include "fileutil.h" +#include "regexpreprocessor.h" +#include "ioexception.h" + +#include <stack> + +//#define DEBUG_SCANNER +#ifdef DEBUG_SCANNER +#include <iostream> // for debug +#define DEB(s) std::cerr << s << std::endl; +#define DEB2(s,s2) std::cerr << s << ": " << s2 << std::endl; +#else +#define DEB(s) +#define DEB2(s,s2) +#endif + +//using srchilite::StringDef; + +//using namespace srchilite; + +static std::ostringstream buff; + +static srchilite::StringTable *stringTable = 0; + +static void buffer(const char *s); +static void buffer_escape(const char *c); +static const std::string *flush_buffer(); +static srchilite::StringDef *flush_buffer_preproc(); +static void open_include_file(const char *file); +static void close_include_file(); + +srchilite::ParseStructPtr parsestruct; + +typedef std::stack<srchilite::ParseStructPtr> ParseStructStack; +static ParseStructStack parsestructstack; + +void +updateTokenInfo() +{ + langdef_lloc.first_line = parsestruct->line ; +} + + + +#line 668 "langdefscanner.cc" + +#define INITIAL 0 +#define COMMENT_STATE 1 +#define STRING_STATE 2 +#define REGEXP_STATE 3 +#define REGEXP_NOPREPROC_STATE 4 +#define INCLUDE_STATE 5 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int langdef_lex_destroy (void ); + +int langdef_get_debug (void ); + +void langdef_set_debug (int debug_flag ); + +YY_EXTRA_TYPE langdef_get_extra (void ); + +void langdef_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *langdef_get_in (void ); + +void langdef_set_in (FILE * in_str ); + +FILE *langdef_get_out (void ); + +void langdef_set_out (FILE * out_str ); + +int langdef_get_leng (void ); + +char *langdef_get_text (void ); + +int langdef_get_lineno (void ); + +void langdef_set_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int langdef_wrap (void ); +#else +extern int langdef_wrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#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 do { if (fwrite( langdef_text, langdef_leng, 1, langdef_out )) {} } while (0) +#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_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( langdef_in )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( langdef_in ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, langdef_in))==0 && ferror(langdef_in)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(langdef_in); \ + } \ + }\ +\ + +#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 + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int langdef_lex (void); + +#define YY_DECL int langdef_lex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after langdef_text and langdef_leng + * 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 + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 86 "../../../lib/srchilite/langdefscanner.ll" + + +#line 863 "langdefscanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! langdef_in ) + langdef_in = stdin; + + if ( ! langdef_out ) + langdef_out = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + langdef_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + langdef__create_buffer(langdef_in,YY_BUF_SIZE ); + } + + langdef__load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of langdef_text. */ + *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 >= 164 ) + 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] != 236 ); + +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 88 "../../../lib/srchilite/langdefscanner.ll" +{} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 90 "../../../lib/srchilite/langdefscanner.ll" +{} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 92 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(COMMENT_STATE); } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 93 "../../../lib/srchilite/langdefscanner.ll" +{} + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 94 "../../../lib/srchilite/langdefscanner.ll" +{ ++(parsestruct->line); BEGIN(INITIAL); } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 96 "../../../lib/srchilite/langdefscanner.ll" +{ return BEGIN_T ; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 97 "../../../lib/srchilite/langdefscanner.ll" +{ return END_T ; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 98 "../../../lib/srchilite/langdefscanner.ll" +{ return ENVIRONMENT_T; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 99 "../../../lib/srchilite/langdefscanner.ll" +{ return STATE_T; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 100 "../../../lib/srchilite/langdefscanner.ll" +{ return MULTILINE_T; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 101 "../../../lib/srchilite/langdefscanner.ll" +{ return DELIM_T; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 102 "../../../lib/srchilite/langdefscanner.ll" +{ return START_T; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 103 "../../../lib/srchilite/langdefscanner.ll" +{ return ESCAPE_T; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 104 "../../../lib/srchilite/langdefscanner.ll" +{ return NESTED_T; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 105 "../../../lib/srchilite/langdefscanner.ll" +{ return EXIT_ALL; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 106 "../../../lib/srchilite/langdefscanner.ll" +{ return EXIT_T; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 107 "../../../lib/srchilite/langdefscanner.ll" +{ return VARDEF_T; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 108 "../../../lib/srchilite/langdefscanner.ll" +{ return REDEF_T; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 109 "../../../lib/srchilite/langdefscanner.ll" +{ return SUBST_T; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 110 "../../../lib/srchilite/langdefscanner.ll" +{ return NONSENSITIVE_T; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 112 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(INCLUDE_STATE); } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 113 "../../../lib/srchilite/langdefscanner.ll" +{ + DEB2("inclusion of ", langdef_text); + + char *file_name = &langdef_text[1]; + file_name[strlen(file_name)-1] = '0円'; + + try { + open_include_file(file_name); + } catch (srchilite::IOException &e) { + langdef_lval.string = stringTable->newString(e.filename); + return WRONG_INCLUDE_FILE; + } + + langdef_push_buffer_state(langdef__create_buffer(langdef_in,YY_BUF_SIZE)); + + BEGIN(INITIAL); +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT_STATE): +case YY_STATE_EOF(STRING_STATE): +case YY_STATE_EOF(REGEXP_STATE): +case YY_STATE_EOF(REGEXP_NOPREPROC_STATE): +case YY_STATE_EOF(INCLUDE_STATE): +#line 131 "../../../lib/srchilite/langdefscanner.ll" +{ + DEB("END OF FILE"); + + fclose(langdef_in); + langdef_in = 0; + langdef_pop_buffer_state(); + + if ( !YY_CURRENT_BUFFER ) + { + yyterminate(); + } + else + close_include_file(); +} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 146 "../../../lib/srchilite/langdefscanner.ll" +{ DEB2("VAR",langdef_text); langdef_lval.string = stringTable->newString(&langdef_text[1]) ; return VARUSE ; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 147 "../../../lib/srchilite/langdefscanner.ll" +{ + DEB2("BACKREFVAR",langdef_text); + langdef_lval.string = stringTable->newString(langdef_text); + return BACKREFVAR ; +} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 152 "../../../lib/srchilite/langdefscanner.ll" +{ DEB2("KEY",langdef_text); langdef_lval.string = stringTable->newString(langdef_text) ; updateTokenInfo(); return KEY ; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 153 "../../../lib/srchilite/langdefscanner.ll" +{ return '=' ; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 154 "../../../lib/srchilite/langdefscanner.ll" +{ return ',' ; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 155 "../../../lib/srchilite/langdefscanner.ll" +{ return '+' ; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 156 "../../../lib/srchilite/langdefscanner.ll" +{ updateTokenInfo(); return '(' ; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 157 "../../../lib/srchilite/langdefscanner.ll" +{ return ')' ; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 159 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(STRING_STATE) ; } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 160 "../../../lib/srchilite/langdefscanner.ll" +{ buffer_escape( langdef_text ) ; } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 161 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 162 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 163 "../../../lib/srchilite/langdefscanner.ll" +{ + return WRONG_BACKREFERENCE ; + } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 166 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 167 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(INITIAL) ; langdef_lval.string = flush_buffer() ; DEB2("STRINGDEF",langdef_lval.string); return STRINGDEF; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 168 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 39: +/* rule 39 can match eol */ +YY_RULE_SETUP +#line 169 "../../../lib/srchilite/langdefscanner.ll" +{ DEB("NEWLINE"); ++(parsestruct->line) ; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 171 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(REGEXP_STATE) ; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 172 "../../../lib/srchilite/langdefscanner.ll" +{ buffer_escape( langdef_text ) ; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 173 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 43: +YY_RULE_SETUP +#line 174 "../../../lib/srchilite/langdefscanner.ll" +{ + return WRONG_BACKREFERENCE ; + } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 177 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( "'" ) ; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 178 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(INITIAL) ; langdef_lval.stringdef = flush_buffer_preproc() ; DEB2("REGEXPDEF",langdef_lval.string); return REGEXPDEF; } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 179 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 47: +/* rule 47 can match eol */ +YY_RULE_SETUP +#line 180 "../../../lib/srchilite/langdefscanner.ll" +{ DEB("NEWLINE"); ++(parsestruct->line) ; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 182 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(REGEXP_NOPREPROC_STATE) ; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 183 "../../../lib/srchilite/langdefscanner.ll" +{ buffer_escape( langdef_text ) ; } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 184 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 185 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( "'" ) ; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 186 "../../../lib/srchilite/langdefscanner.ll" +{ BEGIN(INITIAL) ; langdef_lval.string = flush_buffer() ; DEB2("REGEXPNOPREPROCDEF",langdef_lval.string); return REGEXPNOPREPROC; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 187 "../../../lib/srchilite/langdefscanner.ll" +{ buffer( langdef_text ) ; } + YY_BREAK +case 54: +/* rule 54 can match eol */ +YY_RULE_SETUP +#line 188 "../../../lib/srchilite/langdefscanner.ll" +{ DEB("NEWLINE"); ++(parsestruct->line) ; } + YY_BREAK +case 55: +/* rule 55 can match eol */ +YY_RULE_SETUP +#line 190 "../../../lib/srchilite/langdefscanner.ll" +{ DEB("NEWLINE"); ++(parsestruct->line) ; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 192 "../../../lib/srchilite/langdefscanner.ll" +{ langdef_lval.level = atoi(langdef_text); return LEVEL ; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 194 "../../../lib/srchilite/langdefscanner.ll" +{ return langdef_text[0] ; } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 196 "../../../lib/srchilite/langdefscanner.ll" +ECHO; + YY_BREAK +#line 1287 "langdefscanner.cc" + + 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_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed langdef_in at a new source and called + * langdef_lex(). 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_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = langdef_in; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->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 ( langdef_wrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * langdef_text, 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_LVALUE->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 langdef_lex */ + +/* 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 (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (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_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((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. */ + langdef_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_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->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; + langdef_restart(langdef_in ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) langdef_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + 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 >= 164 ) + 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 ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + 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 >= 164 ) + 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 == 163); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up langdef_text */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#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_LVALUE->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. */ + langdef_restart(langdef_in ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( langdef_wrap( ) ) + 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 langdef_text */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void langdef_restart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + langdef_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + langdef__create_buffer(langdef_in,YY_BUF_SIZE ); + } + + langdef__init_buffer(YY_CURRENT_BUFFER,input_file ); + langdef__load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void langdef__switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * langdef_pop_buffer_state(); + * langdef_push_buffer_state(new_buffer); + */ + langdef_ensure_buffer_stack (); + 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_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + langdef__load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (langdef_wrap()) processing, but the only time this flag + * is looked at is after langdef_wrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void langdef__load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + langdef_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE langdef__create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) langdef_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in langdef__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 *) langdef_alloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in langdef__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + langdef__init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with langdef__create_buffer() + * + */ + void langdef__delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + langdef_free((void *) b->yy_ch_buf ); + + langdef_free((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a langdef_restart() or at EOF. + */ + static void langdef__init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + langdef__flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then langdef__init_buffer was _probably_ + * called from langdef_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void langdef__flush_buffer (YY_BUFFER_STATE b ) +{ + 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 ) + langdef__load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void langdef_push_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + langdef_ensure_buffer_stack(); + + /* This block is copied from langdef__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from langdef__switch_to_buffer. */ + langdef__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void langdef_pop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + langdef__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + langdef__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void langdef_ensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)langdef_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in langdef_ensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)langdef_realloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in langdef_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE langdef__scan_buffer (char * base, yy_size_t size ) +{ + 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) langdef_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in langdef__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; + + langdef__switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to langdef_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * langdef__scan_bytes() instead. + */ +YY_BUFFER_STATE langdef__scan_string (yyconst char * yystr ) +{ + + return langdef__scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to langdef_lex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE langdef__scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) langdef_alloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in langdef__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = langdef__scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in langdef__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; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (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 langdef_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + langdef_text[langdef_leng] = (yy_hold_char); \ + (yy_c_buf_p) = langdef_text + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '0円'; \ + langdef_leng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int langdef_get_lineno (void) +{ + + return langdef_lineno; +} + +/** Get the input stream. + * + */ +FILE *langdef_get_in (void) +{ + return langdef_in; +} + +/** Get the output stream. + * + */ +FILE *langdef_get_out (void) +{ + return langdef_out; +} + +/** Get the length of the current token. + * + */ +int langdef_get_leng (void) +{ + return langdef_leng; +} + +/** Get the current token. + * + */ + +char *langdef_get_text (void) +{ + return langdef_text; +} + +/** Set the current line number. + * @param line_number + * + */ +void langdef_set_lineno (int line_number ) +{ + + langdef_lineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see langdef__switch_to_buffer + */ +void langdef_set_in (FILE * in_str ) +{ + langdef_in = in_str ; +} + +void langdef_set_out (FILE * out_str ) +{ + langdef_out = out_str ; +} + +int langdef_get_debug (void) +{ + return langdef__flex_debug; +} + +void langdef_set_debug (int bdebug ) +{ + langdef__flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from langdef_lex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + langdef_in = stdin; + langdef_out = stdout; +#else + langdef_in = (FILE *) 0; + langdef_out = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * langdef_lex_init() + */ + return 0; +} + +/* langdef_lex_destroy is for both reentrant and non-reentrant scanners. */ +int langdef_lex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + langdef__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + langdef_pop_buffer_state(); + } + + /* Destroy the stack itself. */ + langdef_free((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * langdef_lex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *langdef_alloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *langdef_realloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void langdef_free (void * ptr ) +{ + free( (char *) ptr ); /* see langdef_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 196 "../../../lib/srchilite/langdefscanner.ll" + + + +void buffer(const char *s) +{ + buff << s; +} + +void buffer_escape(const char *s) +{ + buff << "\\" << s; +} + +const std::string *flush_buffer() +{ + const std::string *ret = stringTable->newString(buff.str()); + buff.str(""); + return ret; +} + +srchilite::StringDef *flush_buffer_preproc() +{ + srchilite::StringDef *sd = + new srchilite::StringDef + (srchilite::RegexPreProcessor::preprocess(buff.str()), buff.str()); + buff.str(""); + return sd; +} + +void _open_file_to_scan(const string &path, const string &name) +{ + langdef_in = srchilite::open_data_file_stream(path, name); +} + +void open_include_file(const char *name) +{ + string file_name = name; + string path = parsestruct->path; + + if (! srchilite::contains_path(name) && + srchilite::contains_path(parsestruct->file_name)) + path = srchilite::get_file_path(parsestruct->file_name); + + parsestructstack.push(parsestruct); + parsestruct = srchilite::ParseStructPtr(new srchilite::ParseStruct(path, file_name)); + _open_file_to_scan(path.c_str(), file_name.c_str()); +} + +void close_include_file() +{ + parsestruct = parsestructstack.top(); + parsestructstack.pop(); +} + +namespace srchilite { + +void open_file_to_scan(const string &path, const string &name) +{ + stringTable = new StringTable; + _open_file_to_scan(path, name); + langdef_restart(langdef_in); +} + +void clear_langdefscanner() { + delete stringTable; + langdef_lex_destroy(); +} + +void close_langdefinputfile() { + // also close possible open files due to inclusions + do { + if (langdef_in) + fclose(langdef_in); + langdef_pop_buffer_state(); + } while ( YY_CURRENT_BUFFER ); +} + +} + diff --git a/lib/srchilite/outlangdefparser.cc b/lib/srchilite/outlangdefparser.cc new file mode 100644 index 0000000..f020778 --- /dev/null +++ b/lib/srchilite/outlangdefparser.cc @@ -0,0 +1,1993 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by 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 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse outlangdef_parse +#define yylex outlangdef_lex +#define yyerror outlangdef_error +#define yylval outlangdef_lval +#define yychar outlangdef_char +#define yydebug outlangdef_debug +#define yynerrs outlangdef_nerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BEGIN_T = 258, + END_T = 259, + DOC_TEMPLATE_T = 260, + NODOC_TEMPLATE_T = 261, + STYLE_TEMPLATE_T = 262, + STYLE_SEPARATOR_T = 263, + BOLD_T = 264, + ITALICS_T = 265, + UNDERLINE_T = 266, + COLOR_T = 267, + BG_COLOR_T = 268, + FIXED_T = 269, + NOTFIXED_T = 270, + COLORMAP_T = 271, + DEFAULT_T = 272, + ONESTYLE_T = 273, + TRANSLATIONS_T = 274, + EXTENSION_T = 275, + ANCHOR_T = 276, + REFERENCE_T = 277, + INLINE_REFERENCE_T = 278, + POSTLINE_REFERENCE_T = 279, + POSTDOC_REFERENCE_T = 280, + KEY = 281, + STRINGDEF = 282, + REGEXDEF = 283, + LINE_PREFIX_T = 284, + LINENUM_T = 285, + WRONG_INCLUDE_FILE = 286 + }; +#endif +/* Tokens. */ +#define BEGIN_T 258 +#define END_T 259 +#define DOC_TEMPLATE_T 260 +#define NODOC_TEMPLATE_T 261 +#define STYLE_TEMPLATE_T 262 +#define STYLE_SEPARATOR_T 263 +#define BOLD_T 264 +#define ITALICS_T 265 +#define UNDERLINE_T 266 +#define COLOR_T 267 +#define BG_COLOR_T 268 +#define FIXED_T 269 +#define NOTFIXED_T 270 +#define COLORMAP_T 271 +#define DEFAULT_T 272 +#define ONESTYLE_T 273 +#define TRANSLATIONS_T 274 +#define EXTENSION_T 275 +#define ANCHOR_T 276 +#define REFERENCE_T 277 +#define INLINE_REFERENCE_T 278 +#define POSTLINE_REFERENCE_T 279 +#define POSTDOC_REFERENCE_T 280 +#define KEY 281 +#define STRINGDEF 282 +#define REGEXDEF 283 +#define LINE_PREFIX_T 284 +#define LINENUM_T 285 +#define WRONG_INCLUDE_FILE 286 + + + + +/* Copy the first part of user declarations. */ +#line 1 "../../../lib/srchilite/outlangdefparser.yy" + +/* + * Copyright (C) 1999-2007 Lorenzo Bettini <http://www.lorenzobettini.it> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <iostream> +#include <string> + +#include "parsestruct.h" +#include "outlangdefscanner.h" +#include "outlangdefparserfun.h" +#include "textstyles.h" +#include "parserexception.h" +#include "ioexception.h" + +using std::cerr; +using std::string; + +using namespace srchilite; + +static void yyerror( const char *s ) ; +static void yyerror( const string &s ) ; + +/// the buffer for storing errors +static string errorBuffer; + +TextStylesPtr textstyles; +string start_doc, end_doc; +ColorMapPtr colorMap; +CharTranslatorPtr charTranslator; + +const char *reference_vars[] = {"linenum", "infilename", "infile", "outfile", 0}; +const char *anchor_vars[] = {"linenum", "infilename", "infile", 0}; + +/// used to record that the error is due to an included file not found +static bool includedFileNotFound = false; + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 58 "../../../lib/srchilite/outlangdefparser.yy" +{ + int tok ; /* command */ + bool booloption ; + const std::string * string ; /* string : id, ... */ + int flag ; +} +/* Line 187 of yacc.c. */ +#line 230 "outlangdefparser.cc" + 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 216 of yacc.c. */ +#line 243 "outlangdefparser.cc" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# 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 +{ + yytype_int16 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 (yytype_int16) + 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 \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (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 (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 56 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 76 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 32 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 10 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 36 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 69 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 286 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 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, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 5, 8, 10, 15, 20, 23, 26, + 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, + 59, 62, 65, 68, 71, 74, 76, 78, 80, 84, + 87, 89, 92, 95, 99, 102, 104 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 33, 0, -1, 34, -1, 34, 35, -1, 35, -1, + 5, 27, 27, 4, -1, 6, 27, 27, 4, -1, + 7, 27, -1, 8, 27, -1, 9, 27, -1, 10, + 27, -1, 11, 27, -1, 14, 27, -1, 15, 27, + -1, 12, 27, -1, 13, 27, -1, 18, 27, -1, + 20, 27, -1, 21, 27, -1, 29, 27, -1, 30, + 27, -1, 22, 27, -1, 23, 27, -1, 24, 27, + -1, 25, 27, -1, 36, -1, 39, -1, 31, -1, + 16, 37, 4, -1, 37, 38, -1, 38, -1, 27, + 27, -1, 17, 27, -1, 19, 40, 4, -1, 40, + 41, -1, 41, -1, 28, 28, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 74, 74, 77, 78, 81, 88, 95, 101, 107, + 113, 119, 125, 131, 137, 143, 149, 155, 161, 167, + 173, 179, 190, 196, 202, 208, 213, 217, 227, 230, + 232, 235, 242, 249, 252, 254, 257 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[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", "BEGIN_T", "END_T", "DOC_TEMPLATE_T", + "NODOC_TEMPLATE_T", "STYLE_TEMPLATE_T", "STYLE_SEPARATOR_T", "BOLD_T", + "ITALICS_T", "UNDERLINE_T", "COLOR_T", "BG_COLOR_T", "FIXED_T", + "NOTFIXED_T", "COLORMAP_T", "DEFAULT_T", "ONESTYLE_T", "TRANSLATIONS_T", + "EXTENSION_T", "ANCHOR_T", "REFERENCE_T", "INLINE_REFERENCE_T", + "POSTLINE_REFERENCE_T", "POSTDOC_REFERENCE_T", "KEY", "STRINGDEF", + "REGEXDEF", "LINE_PREFIX_T", "LINENUM_T", "WRONG_INCLUDE_FILE", + "$accept", "outputlang", "outputlangdefs", "outputlangdef", "colormap", + "colormapentries", "colormapentry", "chartranslator", "translations", + "translation", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 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 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 32, 33, 34, 34, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 35, 35, 35, 35, 35, 35, 35, 35, 36, 37, + 37, 38, 38, 39, 40, 40, 41 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 2, 1, 4, 4, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 1, 1, 3, 2, + 1, 2, 2, 3, 2, 1, 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 yytype_uint8 yydefact[] = +{ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 0, 2, 4, 25, 26, 0, + 0, 7, 8, 9, 10, 11, 14, 15, 12, 13, + 0, 0, 0, 30, 16, 0, 0, 35, 17, 18, + 21, 22, 23, 24, 19, 20, 1, 3, 0, 0, + 32, 31, 28, 29, 36, 33, 34, 5, 6 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 24, 25, 26, 27, 42, 43, 28, 46, 47 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -6 +static const yytype_int8 yypact[] = +{ + -5, -4, 0, 1, 2, 3, 4, 6, 10, 11, + 12, 13, 5, 14, 7, 15, 16, 18, 19, 20, + 21, 22, 23, -6, 51, -5, -6, -6, -6, 25, + 26, -6, -6, -6, -6, -6, -6, -6, -6, -6, + 27, 28, 17, -6, -6, 29, 8, -6, -6, -6, + -6, -6, -6, -6, -6, -6, -6, -6, 52, 54, + -6, -6, -6, -6, -6, -6, -6, -6, -6 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -6, -6, -6, 34, -6, -6, 24, -6, -6, 30 +}; + +/* 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 yytype_uint8 yytable[] = +{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 65, 13, 14, 15, 16, 17, 18, 19, + 20, 62, 40, 29, 21, 22, 23, 30, 31, 32, + 33, 34, 41, 35, 40, 45, 45, 36, 37, 38, + 39, 44, 48, 49, 41, 50, 51, 52, 53, 54, + 55, 56, 58, 59, 60, 61, 67, 64, 68, 57, + 0, 0, 0, 0, 0, 0, 63, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 66 +}; + +static const yytype_int8 yycheck[] = +{ + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 4, 18, 19, 20, 21, 22, 23, 24, + 25, 4, 17, 27, 29, 30, 31, 27, 27, 27, + 27, 27, 27, 27, 17, 28, 28, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 0, 27, 27, 27, 27, 4, 28, 4, 25, + -1, -1, -1, -1, -1, -1, 42, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 46 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 18, 19, 20, 21, 22, 23, 24, + 25, 29, 30, 31, 33, 34, 35, 36, 39, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 17, 27, 37, 38, 27, 28, 40, 41, 27, 27, + 27, 27, 27, 27, 27, 27, 0, 35, 27, 27, + 27, 27, 4, 38, 28, 4, 41, 4, 4 +}; + +#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 (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; 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 (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, 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 + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# 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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '0円') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '0円'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '0円'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '0円') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + 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 */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* 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. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + 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; + yytype_int16 *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 (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + 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 + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead 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); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + 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 5: +#line 82 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->docTemplate = DocTemplate(*(yyvsp[(2) - (4)].string), *(yyvsp[(3) - (4)].string)); + delete (yyvsp[(2) - (4)].string); + delete (yyvsp[(3) - (4)].string); +} + break; + + case 6: +#line 89 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->noDocTemplate = DocTemplate(*(yyvsp[(2) - (4)].string), *(yyvsp[(3) - (4)].string)); + delete (yyvsp[(2) - (4)].string); + delete (yyvsp[(3) - (4)].string); +} + break; + + case 7: +#line 96 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->starting_template = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 8: +#line 102 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->style_separator = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 9: +#line 108 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->bold = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 10: +#line 114 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->italics = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 11: +#line 120 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->underline = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 12: +#line 126 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->fixed = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 13: +#line 132 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->notfixed = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 14: +#line 138 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->color = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 15: +#line 144 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->bg_color = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 16: +#line 150 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->onestyle = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 17: +#line 156 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->file_extension = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 18: +#line 162 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->refstyle.anchor = TextStyle(*(yyvsp[(2) - (2)].string), anchor_vars); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 19: +#line 168 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->line_prefix = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 20: +#line 174 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->linenum = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 21: +#line 180 "../../../lib/srchilite/outlangdefparser.yy" + { + if (textstyles->refstyle.inline_reference.empty()) + textstyles->refstyle.inline_reference = TextStyle(*(yyvsp[(2) - (2)].string), reference_vars); + if (textstyles->refstyle.postline_reference.empty()) + textstyles->refstyle.postline_reference = TextStyle(*(yyvsp[(2) - (2)].string), reference_vars); + if (textstyles->refstyle.postdoc_reference.empty()) + textstyles->refstyle.postdoc_reference = TextStyle(*(yyvsp[(2) - (2)].string), reference_vars); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 22: +#line 191 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->refstyle.inline_reference = TextStyle(*(yyvsp[(2) - (2)].string), reference_vars); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 23: +#line 197 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->refstyle.postline_reference = TextStyle(*(yyvsp[(2) - (2)].string), reference_vars); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 24: +#line 203 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->refstyle.postdoc_reference = TextStyle(*(yyvsp[(2) - (2)].string), reference_vars); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 25: +#line 209 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->colorMap = colorMap; +} + break; + + case 26: +#line 214 "../../../lib/srchilite/outlangdefparser.yy" + { + textstyles->charTranslator = charTranslator; +} + break; + + case 27: +#line 217 "../../../lib/srchilite/outlangdefparser.yy" + { + // this token is used by the scanner to signal an error + // in opening an include file + includedFileNotFound = true; + yyerror("cannot open include file " + *(yyvsp[(1) - (1)].string)); + delete (yyvsp[(1) - (1)].string); + YYERROR; + } + break; + + case 31: +#line 236 "../../../lib/srchilite/outlangdefparser.yy" + { + (*colorMap)[*(yyvsp[(1) - (2)].string)] = *(yyvsp[(2) - (2)].string); + delete (yyvsp[(1) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 32: +#line 243 "../../../lib/srchilite/outlangdefparser.yy" + { + colorMap->setDefault(*(yyvsp[(2) - (2)].string)); + delete (yyvsp[(2) - (2)].string); +} + break; + + case 36: +#line 258 "../../../lib/srchilite/outlangdefparser.yy" + { + charTranslator->set_translation(*(yyvsp[(1) - (2)].string), *(yyvsp[(2) - (2)].string)); + delete (yyvsp[(1) - (2)].string); + delete (yyvsp[(2) - (2)].string); +} + break; + + +/* Line 1267 of yacc.c. */ +#line 1709 "outlangdefparser.cc" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + 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 + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + 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; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 264 "../../../lib/srchilite/outlangdefparser.yy" + + +extern int outlangdef_lex_destroy (void); + +void +yyerror( const char *s ) +{ + errorBuffer = s; +} + +void +yyerror( const string &s ) +{ + yyerror(s.c_str()); +} + +namespace srchilite { + +TextStylesPtr +parse_outlang_def() +{ + return parse_outlang_def("", "stdin"); +} + +TextStylesPtr +parse_outlang_def(const char *path, const char *name) +{ + includedFileNotFound = false; + outlang_parsestruct = ParseStructPtr(new ParseStruct(path, name)); + textstyles = TextStylesPtr(new TextStyles); + colorMap = ColorMapPtr(new ColorMap); + charTranslator = CharTranslatorPtr(new CharTranslator); + + errorBuffer = ""; + int result = 1; + bool fileNotFound = false; + + try { + if (strcmp(name, "stdin") != 0) + open_outlang_file_to_scan(path, name); + } catch (IOException &e) { + errorBuffer = e.message; + fileNotFound = true; + } + + if (!fileNotFound) + result = outlangdef_parse(); + + if (result != 0 && ! fileNotFound) { + // make sure the input file is closed + close_outlangdefinputfile(); + // close it before clearing the scanner + } + + // release scanner memory + clear_outlangdefscanner (); + + if (result != 0 || errorBuffer.size()) { + if (fileNotFound || includedFileNotFound) { + throw ParserException(errorBuffer); + } else { + ParserException e(errorBuffer, outlang_parsestruct.get()); + throw e; + } + } + + return textstyles; +} + +} + diff --git a/lib/srchilite/outlangdefparser.h b/lib/srchilite/outlangdefparser.h new file mode 100644 index 0000000..eab073e --- /dev/null +++ b/lib/srchilite/outlangdefparser.h @@ -0,0 +1,125 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BEGIN_T = 258, + END_T = 259, + DOC_TEMPLATE_T = 260, + NODOC_TEMPLATE_T = 261, + STYLE_TEMPLATE_T = 262, + STYLE_SEPARATOR_T = 263, + BOLD_T = 264, + ITALICS_T = 265, + UNDERLINE_T = 266, + COLOR_T = 267, + BG_COLOR_T = 268, + FIXED_T = 269, + NOTFIXED_T = 270, + COLORMAP_T = 271, + DEFAULT_T = 272, + ONESTYLE_T = 273, + TRANSLATIONS_T = 274, + EXTENSION_T = 275, + ANCHOR_T = 276, + REFERENCE_T = 277, + INLINE_REFERENCE_T = 278, + POSTLINE_REFERENCE_T = 279, + POSTDOC_REFERENCE_T = 280, + KEY = 281, + STRINGDEF = 282, + REGEXDEF = 283, + LINE_PREFIX_T = 284, + LINENUM_T = 285, + WRONG_INCLUDE_FILE = 286 + }; +#endif +/* Tokens. */ +#define BEGIN_T 258 +#define END_T 259 +#define DOC_TEMPLATE_T 260 +#define NODOC_TEMPLATE_T 261 +#define STYLE_TEMPLATE_T 262 +#define STYLE_SEPARATOR_T 263 +#define BOLD_T 264 +#define ITALICS_T 265 +#define UNDERLINE_T 266 +#define COLOR_T 267 +#define BG_COLOR_T 268 +#define FIXED_T 269 +#define NOTFIXED_T 270 +#define COLORMAP_T 271 +#define DEFAULT_T 272 +#define ONESTYLE_T 273 +#define TRANSLATIONS_T 274 +#define EXTENSION_T 275 +#define ANCHOR_T 276 +#define REFERENCE_T 277 +#define INLINE_REFERENCE_T 278 +#define POSTLINE_REFERENCE_T 279 +#define POSTDOC_REFERENCE_T 280 +#define KEY 281 +#define STRINGDEF 282 +#define REGEXDEF 283 +#define LINE_PREFIX_T 284 +#define LINENUM_T 285 +#define WRONG_INCLUDE_FILE 286 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 58 "../../../lib/srchilite/outlangdefparser.yy" +{ + int tok ; /* command */ + bool booloption ; + const std::string * string ; /* string : id, ... */ + int flag ; +} +/* Line 1489 of yacc.c. */ +#line 118 "outlangdefparser.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE outlangdef_lval; + diff --git a/lib/srchilite/outlangdefscanner.cc b/lib/srchilite/outlangdefscanner.cc new file mode 100644 index 0000000..fcd822e --- /dev/null +++ b/lib/srchilite/outlangdefscanner.cc @@ -0,0 +1,2458 @@ +#line 2 "outlangdefscanner.cc" + +#line 4 "outlangdefscanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer outlangdef__create_buffer +#define yy_delete_buffer outlangdef__delete_buffer +#define yy_flex_debug outlangdef__flex_debug +#define yy_init_buffer outlangdef__init_buffer +#define yy_flush_buffer outlangdef__flush_buffer +#define yy_load_buffer_state outlangdef__load_buffer_state +#define yy_switch_to_buffer outlangdef__switch_to_buffer +#define yyin outlangdef_in +#define yyleng outlangdef_leng +#define yylex outlangdef_lex +#define yylineno outlangdef_lineno +#define yyout outlangdef_out +#define yyrestart outlangdef_restart +#define yytext outlangdef_text +#define yywrap outlangdef_wrap +#define yyalloc outlangdef_alloc +#define yyrealloc outlangdef_realloc +#define yyfree outlangdef_free + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* 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 outlangdef_restart(outlangdef_in ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int outlangdef_leng; + +extern FILE *outlangdef_in, *outlangdef_out; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up outlangdef_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up outlangdef_text again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + 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; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via outlangdef_restart()), so that the user can continue scanning by + * just pointing outlangdef_in at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when outlangdef_text is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int outlangdef_leng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow outlangdef_wrap()'s to do buffer switches + * instead of setting up a fresh outlangdef_in. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void outlangdef_restart (FILE *input_file ); +void outlangdef__switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE outlangdef__create_buffer (FILE *file,int size ); +void outlangdef__delete_buffer (YY_BUFFER_STATE b ); +void outlangdef__flush_buffer (YY_BUFFER_STATE b ); +void outlangdef_push_buffer_state (YY_BUFFER_STATE new_buffer ); +void outlangdef_pop_buffer_state (void ); + +static void outlangdef_ensure_buffer_stack (void ); +static void outlangdef__load_buffer_state (void ); +static void outlangdef__init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER outlangdef__flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE outlangdef__scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE outlangdef__scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE outlangdef__scan_bytes (yyconst char *bytes,int len ); + +void *outlangdef_alloc (yy_size_t ); +void *outlangdef_realloc (void *,yy_size_t ); +void outlangdef_free (void * ); + +#define yy_new_buffer outlangdef__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + outlangdef_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + outlangdef__create_buffer(outlangdef_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + outlangdef_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + outlangdef__create_buffer(outlangdef_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define outlangdef_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *outlangdef_in = (FILE *) 0, *outlangdef_out = (FILE *) 0; + +typedef int yy_state_type; + +extern int outlangdef_lineno; + +int outlangdef_lineno = 1; + +extern char *outlangdef_text; +#define yytext_ptr outlangdef_text + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up outlangdef_text. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + outlangdef_leng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '0円'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 57 +#define YY_END_OF_BUFFER 58 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[282] = + { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 58, 56, 1, 55, + 2, 37, 3, 36, 35, 34, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 4, 5, 2, 42, 43, 2, 42, 41, + 42, 57, 2, 57, 1, 44, 3, 50, 57, 54, + 2, 53, 54, 49, 2, 49, 48, 45, 49, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 40, 39, 0, 0, 0, 52, 51, 47, 46, 33, + + 33, 33, 33, 33, 33, 33, 30, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 0, 32, 30, 33, 33, 33, 10, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 38, 33, 29, 33, 17, + 33, 33, 33, 14, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 21, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 16, + 33, 18, 33, 33, 33, 33, 11, 27, 33, 33, + + 33, 33, 33, 33, 33, 33, 33, 33, 33, 15, + 33, 33, 31, 33, 33, 33, 13, 19, 33, 33, + 33, 33, 33, 33, 33, 33, 20, 33, 33, 33, + 33, 33, 25, 33, 33, 33, 12, 33, 33, 26, + 33, 33, 33, 33, 33, 33, 7, 33, 33, 33, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 28, 33, 6, 33, 33, 33, 8, 33, 33, 33, + 9, 33, 33, 33, 22, 33, 33, 24, 33, 23, + 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 1, 6, 7, 8, 1, 1, 9, 10, + 11, 12, 13, 14, 1, 15, 1, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 1, 1, 1, + 17, 1, 18, 1, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 20, 21, 22, 23, 24, 1, 25, 26, 27, 28, + + 29, 30, 31, 32, 33, 19, 19, 34, 35, 36, + 37, 38, 19, 39, 40, 41, 42, 19, 19, 43, + 44, 19, 45, 46, 47, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[48] = + { 0, + 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 3, 1, 1, 3, 1, + 1, 1, 1, 4, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[291] = + { 0, + 0, 0, 45, 47, 49, 53, 56, 57, 73, 101, + 62, 64, 128, 173, 82, 87, 369, 370, 370, 370, + 370, 370, 370, 370, 370, 370, 0, 332, 80, 330, + 35, 54, 333, 58, 332, 327, 327, 325, 332, 319, + 320, 322, 370, 370, 370, 370, 370, 370, 370, 370, + 75, 370, 370, 0, 370, 370, 370, 370, 321, 370, + 370, 370, 91, 370, 370, 370, 370, 370, 92, 0, + 329, 324, 327, 319, 318, 321, 323, 321, 307, 304, + 87, 321, 309, 87, 315, 303, 312, 297, 315, 311, + 370, 370, 0, 332, 309, 370, 370, 370, 370, 304, + + 302, 297, 305, 295, 306, 289, 0, 300, 299, 293, + 293, 291, 295, 286, 292, 281, 279, 290, 284, 281, + 287, 0, 370, 370, 278, 278, 279, 0, 273, 269, + 281, 273, 280, 265, 270, 272, 84, 277, 270, 261, + 67, 262, 271, 259, 259, 370, 258, 0, 259, 260, + 260, 258, 252, 0, 263, 261, 262, 246, 248, 245, + 242, 240, 246, 249, 252, 83, 246, 245, 0, 239, + 252, 235, 237, 241, 244, 248, 231, 235, 240, 239, + 238, 232, 238, 228, 227, 233, 232, 235, 226, 0, + 220, 0, 223, 219, 114, 216, 0, 0, 224, 218, + + 224, 222, 226, 220, 221, 209, 209, 176, 180, 0, + 190, 178, 370, 184, 179, 173, 0, 0, 171, 185, + 179, 182, 168, 172, 175, 162, 0, 172, 158, 166, + 170, 159, 0, 158, 158, 153, 0, 160, 158, 0, + 157, 150, 143, 146, 145, 133, 0, 129, 126, 137, + 135, 123, 122, 122, 132, 131, 120, 129, 120, 127, + 0, 119, 0, 125, 114, 113, 0, 120, 109, 115, + 0, 113, 110, 99, 0, 100, 100, 0, 97, 0, + 370, 220, 224, 228, 232, 236, 238, 242, 122, 66 + } ; + +static yyconst flex_int16_t yy_def[291] = + { 0, + 281, 1, 282, 282, 283, 283, 284, 284, 284, 284, + 285, 285, 286, 286, 284, 284, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 288, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 281, 281, 289, 288, 281, 281, 281, 281, 281, 287, + + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 290, 281, 281, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 281, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 281, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, + 0, 281, 281, 281, 281, 281, 281, 281, 281, 281 + } ; + +static yyconst flex_int16_t yy_nxt[418] = + { 0, + 18, 19, 20, 21, 19, 22, 23, 18, 18, 18, + 18, 18, 24, 25, 18, 18, 26, 18, 27, 18, + 18, 18, 18, 27, 28, 29, 30, 31, 32, 33, + 27, 27, 34, 35, 27, 36, 37, 38, 39, 40, + 41, 42, 27, 27, 18, 18, 18, 44, 45, 44, + 45, 47, 48, 49, 50, 47, 48, 49, 50, 53, + 53, 54, 54, 76, 52, 61, 52, 61, 146, 51, + 62, 77, 62, 51, 55, 20, 53, 55, 56, 57, + 91, 58, 63, 55, 63, 53, 55, 56, 55, 78, + 53, 55, 56, 81, 163, 92, 79, 98, 82, 96, + + 164, 59, 55, 20, 53, 55, 56, 57, 72, 58, + 73, 97, 99, 110, 114, 213, 74, 93, 213, 158, + 111, 159, 186, 187, 122, 280, 279, 115, 278, 59, + 52, 65, 66, 67, 277, 68, 276, 68, 68, 68, + 68, 275, 68, 274, 273, 68, 272, 68, 69, 68, + 68, 271, 270, 269, 268, 267, 266, 265, 264, 263, + 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, + 252, 251, 68, 68, 68, 52, 65, 66, 67, 250, + 68, 249, 68, 68, 68, 68, 248, 68, 247, 246, + 68, 245, 68, 69, 68, 68, 244, 243, 242, 241, + + 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, + 230, 229, 228, 227, 226, 225, 224, 68, 68, 68, + 43, 43, 43, 43, 46, 46, 46, 46, 52, 52, + 52, 52, 60, 60, 60, 60, 64, 64, 64, 64, + 70, 70, 94, 223, 94, 94, 222, 221, 220, 219, + 218, 217, 216, 215, 214, 212, 211, 210, 209, 208, + 207, 206, 205, 204, 203, 202, 201, 200, 199, 198, + 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, + 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, + 175, 174, 173, 172, 171, 170, 169, 168, 167, 166, + + 165, 162, 161, 160, 157, 156, 155, 154, 153, 152, + 151, 150, 149, 148, 147, 145, 144, 143, 142, 141, + 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, + 130, 129, 128, 127, 126, 125, 124, 123, 121, 120, + 119, 118, 117, 116, 113, 112, 109, 108, 107, 106, + 105, 104, 103, 102, 101, 100, 95, 90, 89, 88, + 87, 86, 85, 84, 83, 80, 75, 71, 281, 17, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281 + } ; + +static yyconst flex_int16_t yy_chk[418] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, + 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, + 8, 7, 8, 31, 11, 11, 12, 12, 290, 5, + 11, 31, 12, 6, 9, 9, 9, 9, 9, 9, + 51, 9, 11, 15, 12, 15, 15, 15, 16, 32, + 16, 16, 16, 34, 141, 51, 32, 69, 34, 63, + + 141, 9, 10, 10, 10, 10, 10, 10, 29, 10, + 29, 63, 69, 81, 84, 195, 29, 51, 195, 137, + 81, 137, 166, 166, 289, 279, 277, 84, 276, 10, + 13, 13, 13, 13, 274, 13, 273, 13, 13, 13, + 13, 272, 13, 270, 269, 13, 268, 13, 13, 13, + 13, 266, 265, 264, 262, 260, 259, 258, 257, 256, + 255, 254, 253, 252, 251, 250, 249, 248, 246, 245, + 244, 243, 13, 13, 13, 14, 14, 14, 14, 242, + 14, 241, 14, 14, 14, 14, 239, 14, 238, 236, + 14, 235, 14, 14, 14, 14, 234, 232, 231, 230, + + 229, 228, 226, 225, 224, 223, 222, 221, 220, 219, + 216, 215, 214, 212, 211, 209, 208, 14, 14, 14, + 282, 282, 282, 282, 283, 283, 283, 283, 284, 284, + 284, 284, 285, 285, 285, 285, 286, 286, 286, 286, + 287, 287, 288, 207, 288, 288, 206, 205, 204, 203, + 202, 201, 200, 199, 196, 194, 193, 191, 189, 188, + 187, 186, 185, 184, 183, 182, 181, 180, 179, 178, + 177, 176, 175, 174, 173, 172, 171, 170, 168, 167, + 165, 164, 163, 162, 161, 160, 159, 158, 157, 156, + 155, 153, 152, 151, 150, 149, 147, 145, 144, 143, + + 142, 140, 139, 138, 136, 135, 134, 133, 132, 131, + 130, 129, 127, 126, 125, 121, 120, 119, 118, 117, + 116, 115, 114, 113, 112, 111, 110, 109, 108, 106, + 105, 104, 103, 102, 101, 100, 95, 94, 90, 89, + 88, 87, 86, 85, 83, 82, 80, 79, 78, 77, + 76, 75, 74, 73, 72, 71, 59, 42, 41, 40, + 39, 38, 37, 36, 35, 33, 30, 28, 17, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + + 281, 281, 281, 281, 281, 281, 281, 281, 281, 281, + 281, 281, 281, 281, 281, 281, 281 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int outlangdef__flex_debug; +int outlangdef__flex_debug = 0; + +/* 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 *outlangdef_text; +#line 1 "../../../lib/srchilite/outlangdefscanner.ll" +#line 2 "../../../lib/srchilite/outlangdefscanner.ll" +/* + * Copyright (C) 1999-2005, Lorenzo Bettini, http://www.lorenzobettini.it + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <sstream> +#include "outlangdefparser.h" +#include "outlangdefscanner.h" +#include "fileutil.h" +#include "ioexception.h" + +#include <stack> +#include <stdlib.h> + +using namespace srchilite; + +//#define DEBUG_SCANNER +#ifdef DEBUG_SCANNER +#include <iostream> // for debug +#define DEB(s) std::cerr << s << std::endl; +#define DEB2(s,s2) std::cerr << s << ": " << s2 << std::endl; +#else +#define DEB(s) +#define DEB2(s,s2) +#endif + +#define PUSH(s) yy_push_state(s); +#define POP() yy_pop_state(); + +static std::ostringstream buff; + +static void buffer(const char *s); +static void buffer(const char c); +static void buffer_escape(const char *c); +static const std::string *flush_buffer(); +static void open_include_file(const char *file); +static void close_include_file(); + +ParseStructPtr outlang_parsestruct; + +typedef std::stack<ParseStructPtr> ParseStructStack; +static ParseStructStack parsestructstack; + + +#line 724 "outlangdefscanner.cc" + +#define INITIAL 0 +#define COMMENT_STATE 1 +#define STRING_STATE 2 +#define INCLUDE_STATE 3 +#define TRANSLATION_STATE 4 +#define REGEX_STATE 5 +#define LITERAL_STATE 6 +#define TRANSLATED_STATE 7 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int outlangdef_lex_destroy (void ); + +int outlangdef_get_debug (void ); + +void outlangdef_set_debug (int debug_flag ); + +YY_EXTRA_TYPE outlangdef_get_extra (void ); + +void outlangdef_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *outlangdef_get_in (void ); + +void outlangdef_set_in (FILE * in_str ); + +FILE *outlangdef_get_out (void ); + +void outlangdef_set_out (FILE * out_str ); + +int outlangdef_get_leng (void ); + +char *outlangdef_get_text (void ); + +int outlangdef_get_lineno (void ); + +void outlangdef_set_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int outlangdef_wrap (void ); +#else +extern int outlangdef_wrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + + static int yy_start_stack_ptr = 0; + static int yy_start_stack_depth = 0; + static int *yy_start_stack = NULL; + + static void yy_push_state (int new_state ); + + static void yy_pop_state (void ); + + static int yy_top_state (void ); + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#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 do { if (fwrite( outlangdef_text, outlangdef_leng, 1, outlangdef_out )) {} } while (0) +#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_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( outlangdef_in )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( outlangdef_in ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, outlangdef_in))==0 && ferror(outlangdef_in)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(outlangdef_in); \ + } \ + }\ +\ + +#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 + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int outlangdef_lex (void); + +#define YY_DECL int outlangdef_lex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after outlangdef_text and outlangdef_leng + * 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 + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 77 "../../../lib/srchilite/outlangdefscanner.ll" + + +#line 931 "outlangdefscanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! outlangdef_in ) + outlangdef_in = stdin; + + if ( ! outlangdef_out ) + outlangdef_out = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + outlangdef_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + outlangdef__create_buffer(outlangdef_in,YY_BUF_SIZE ); + } + + outlangdef__load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of outlangdef_text. */ + *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 >= 282 ) + 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] != 370 ); + +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 79 "../../../lib/srchilite/outlangdefscanner.ll" +{} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 81 "../../../lib/srchilite/outlangdefscanner.ll" +{} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 83 "../../../lib/srchilite/outlangdefscanner.ll" +{ PUSH(COMMENT_STATE); } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 84 "../../../lib/srchilite/outlangdefscanner.ll" +{} + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 85 "../../../lib/srchilite/outlangdefscanner.ll" +{ ++(outlang_parsestruct->line); POP(); } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 87 "../../../lib/srchilite/outlangdefscanner.ll" +{ return NODOC_TEMPLATE_T ; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 88 "../../../lib/srchilite/outlangdefscanner.ll" +{ return DOC_TEMPLATE_T ; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 89 "../../../lib/srchilite/outlangdefscanner.ll" +{ return STYLE_TEMPLATE_T ; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 90 "../../../lib/srchilite/outlangdefscanner.ll" +{ return STYLE_SEPARATOR_T ; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 91 "../../../lib/srchilite/outlangdefscanner.ll" +{ return BOLD_T ; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 92 "../../../lib/srchilite/outlangdefscanner.ll" +{ return ITALICS_T ; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 93 "../../../lib/srchilite/outlangdefscanner.ll" +{ return UNDERLINE_T ; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 94 "../../../lib/srchilite/outlangdefscanner.ll" +{ return NOTFIXED_T ; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 95 "../../../lib/srchilite/outlangdefscanner.ll" +{ return FIXED_T ; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 96 "../../../lib/srchilite/outlangdefscanner.ll" +{ return COLORMAP_T ; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 97 "../../../lib/srchilite/outlangdefscanner.ll" +{ return BG_COLOR_T ; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 98 "../../../lib/srchilite/outlangdefscanner.ll" +{ return COLOR_T ; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 99 "../../../lib/srchilite/outlangdefscanner.ll" +{ return DEFAULT_T ; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 100 "../../../lib/srchilite/outlangdefscanner.ll" +{ return ONESTYLE_T ; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 101 "../../../lib/srchilite/outlangdefscanner.ll" +{ return EXTENSION_T ; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 102 "../../../lib/srchilite/outlangdefscanner.ll" +{ return ANCHOR_T ; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 103 "../../../lib/srchilite/outlangdefscanner.ll" +{ return INLINE_REFERENCE_T ; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 104 "../../../lib/srchilite/outlangdefscanner.ll" +{ return POSTLINE_REFERENCE_T ; } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 105 "../../../lib/srchilite/outlangdefscanner.ll" +{ return POSTDOC_REFERENCE_T ; } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 106 "../../../lib/srchilite/outlangdefscanner.ll" +{ return REFERENCE_T ; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 107 "../../../lib/srchilite/outlangdefscanner.ll" +{ return LINE_PREFIX_T; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 108 "../../../lib/srchilite/outlangdefscanner.ll" +{ return LINENUM_T; } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 109 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(TRANSLATION_STATE); return TRANSLATIONS_T ; } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 110 "../../../lib/srchilite/outlangdefscanner.ll" +{ return BEGIN_T ; } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 111 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(INITIAL); return END_T ; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 113 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(INCLUDE_STATE); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 114 "../../../lib/srchilite/outlangdefscanner.ll" +{ + char *file_name = &outlangdef_text[1]; + file_name[strlen(file_name)-1] = '0円'; + + try { + open_include_file(file_name); + } catch (IOException &e) { + outlangdef_lval.string = new std::string(e.filename); + return WRONG_INCLUDE_FILE; + } + + outlangdef_push_buffer_state(outlangdef__create_buffer(outlangdef_in,YY_BUF_SIZE)); + + BEGIN(INITIAL); +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT_STATE): +case YY_STATE_EOF(STRING_STATE): +case YY_STATE_EOF(INCLUDE_STATE): +case YY_STATE_EOF(TRANSLATION_STATE): +case YY_STATE_EOF(REGEX_STATE): +case YY_STATE_EOF(LITERAL_STATE): +case YY_STATE_EOF(TRANSLATED_STATE): +#line 130 "../../../lib/srchilite/outlangdefscanner.ll" +{ + fclose(outlangdef_in); + outlangdef_in = 0; + outlangdef_pop_buffer_state(); + + if ( !YY_CURRENT_BUFFER ) + { + yyterminate(); + } + else + close_include_file(); +} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 143 "../../../lib/srchilite/outlangdefscanner.ll" +{ DEB2("KEY",outlangdef_text); outlangdef_lval.string = new std::string(outlangdef_text) ; return KEY ; } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 144 "../../../lib/srchilite/outlangdefscanner.ll" +{ return '=' ; } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 145 "../../../lib/srchilite/outlangdefscanner.ll" +{ return ',' ; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 146 "../../../lib/srchilite/outlangdefscanner.ll" +{ return '+' ; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 148 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(STRING_STATE) ; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 149 "../../../lib/srchilite/outlangdefscanner.ll" +{ + string s = &outlangdef_text[1]; + s = "0" + s; + int i = strtol(s.c_str(), (char **)NULL, 0); + buffer( (char)i ) ; +} + YY_BREAK +case 39: +YY_RULE_SETUP +#line 155 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 156 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( "\"" ) ; } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 157 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(INITIAL) ; outlangdef_lval.string = flush_buffer() ; DEB2("STRINGDEF",outlangdef_lval.string); return STRINGDEF; } + YY_BREAK +case 42: +YY_RULE_SETUP +#line 158 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 43: +/* rule 43 can match eol */ +YY_RULE_SETUP +#line 159 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( "\n" ) ; } + YY_BREAK +case 44: +YY_RULE_SETUP +#line 161 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(LITERAL_STATE) ; } + YY_BREAK +case 45: +YY_RULE_SETUP +#line 162 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer_escape( outlangdef_text ) ; } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 163 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 47: +YY_RULE_SETUP +#line 164 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 48: +YY_RULE_SETUP +#line 165 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(TRANSLATION_STATE) ; outlangdef_lval.string = flush_buffer() ; DEB2("STRINGDEF",loutlangdef_lval.string); return REGEXDEF; } + YY_BREAK +case 49: +YY_RULE_SETUP +#line 166 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 50: +YY_RULE_SETUP +#line 168 "../../../lib/srchilite/outlangdefscanner.ll" +{ BEGIN(REGEX_STATE) ; } + YY_BREAK +case 51: +YY_RULE_SETUP +#line 169 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 52: +YY_RULE_SETUP +#line 170 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( "'" ) ; } + YY_BREAK +case 53: +YY_RULE_SETUP +#line 171 "../../../lib/srchilite/outlangdefscanner.ll" +{ + BEGIN(TRANSLATED_STATE) ; + // entering TRANSLATED_STATE makes sure that 'regex' is used only + // for specifying the sequence to be translated, and not the translated sequence + outlangdef_lval.string = flush_buffer() ; + DEB2("STRINGDEF",outlangdef_lval.string); return REGEXDEF; +} + YY_BREAK +case 54: +YY_RULE_SETUP +#line 178 "../../../lib/srchilite/outlangdefscanner.ll" +{ buffer( outlangdef_text ) ; } + YY_BREAK +case 55: +/* rule 55 can match eol */ +YY_RULE_SETUP +#line 180 "../../../lib/srchilite/outlangdefscanner.ll" +{ DEB("NEWLINE"); ++(outlang_parsestruct->line) ; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 182 "../../../lib/srchilite/outlangdefscanner.ll" +{ return outlangdef_text[0] ; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 184 "../../../lib/srchilite/outlangdefscanner.ll" +ECHO; + YY_BREAK +#line 1349 "outlangdefscanner.cc" + + 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_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed outlangdef_in at a new source and called + * outlangdef_lex(). 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_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = outlangdef_in; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->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 ( outlangdef_wrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * outlangdef_text, 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_LVALUE->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 outlangdef_lex */ + +/* 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 (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (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_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((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. */ + outlangdef_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_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->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; + outlangdef_restart(outlangdef_in ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) outlangdef_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + 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 >= 282 ) + 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 ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + 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 >= 282 ) + 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 == 281); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up outlangdef_text */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#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_LVALUE->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. */ + outlangdef_restart(outlangdef_in ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( outlangdef_wrap( ) ) + 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 outlangdef_text */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void outlangdef_restart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + outlangdef_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + outlangdef__create_buffer(outlangdef_in,YY_BUF_SIZE ); + } + + outlangdef__init_buffer(YY_CURRENT_BUFFER,input_file ); + outlangdef__load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void outlangdef__switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * outlangdef_pop_buffer_state(); + * outlangdef_push_buffer_state(new_buffer); + */ + outlangdef_ensure_buffer_stack (); + 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_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + outlangdef__load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (outlangdef_wrap()) processing, but the only time this flag + * is looked at is after outlangdef_wrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void outlangdef__load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + outlangdef_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE outlangdef__create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) outlangdef_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in outlangdef__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 *) outlangdef_alloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in outlangdef__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + outlangdef__init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with outlangdef__create_buffer() + * + */ + void outlangdef__delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + outlangdef_free((void *) b->yy_ch_buf ); + + outlangdef_free((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a outlangdef_restart() or at EOF. + */ + static void outlangdef__init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + outlangdef__flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then outlangdef__init_buffer was _probably_ + * called from outlangdef_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void outlangdef__flush_buffer (YY_BUFFER_STATE b ) +{ + 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 ) + outlangdef__load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void outlangdef_push_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + outlangdef_ensure_buffer_stack(); + + /* This block is copied from outlangdef__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from outlangdef__switch_to_buffer. */ + outlangdef__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void outlangdef_pop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + outlangdef__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + outlangdef__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void outlangdef_ensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)outlangdef_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in outlangdef_ensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)outlangdef_realloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in outlangdef_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE outlangdef__scan_buffer (char * base, yy_size_t size ) +{ + 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) outlangdef_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in outlangdef__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; + + outlangdef__switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to outlangdef_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * outlangdef__scan_bytes() instead. + */ +YY_BUFFER_STATE outlangdef__scan_string (yyconst char * yystr ) +{ + + return outlangdef__scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to outlangdef_lex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE outlangdef__scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) outlangdef_alloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in outlangdef__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = outlangdef__scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in outlangdef__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; +} + + static void yy_push_state (int new_state ) +{ + 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 *) outlangdef_alloc(new_size ); + + else + (yy_start_stack) = (int *) outlangdef_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); +} + + static void yy_pop_state (void) +{ + if ( --(yy_start_stack_ptr) < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN((yy_start_stack)[(yy_start_stack_ptr)]); +} + + static int yy_top_state (void) +{ + return (yy_start_stack)[(yy_start_stack_ptr) - 1]; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (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 outlangdef_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + outlangdef_text[outlangdef_leng] = (yy_hold_char); \ + (yy_c_buf_p) = outlangdef_text + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '0円'; \ + outlangdef_leng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int outlangdef_get_lineno (void) +{ + + return outlangdef_lineno; +} + +/** Get the input stream. + * + */ +FILE *outlangdef_get_in (void) +{ + return outlangdef_in; +} + +/** Get the output stream. + * + */ +FILE *outlangdef_get_out (void) +{ + return outlangdef_out; +} + +/** Get the length of the current token. + * + */ +int outlangdef_get_leng (void) +{ + return outlangdef_leng; +} + +/** Get the current token. + * + */ + +char *outlangdef_get_text (void) +{ + return outlangdef_text; +} + +/** Set the current line number. + * @param line_number + * + */ +void outlangdef_set_lineno (int line_number ) +{ + + outlangdef_lineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see outlangdef__switch_to_buffer + */ +void outlangdef_set_in (FILE * in_str ) +{ + outlangdef_in = in_str ; +} + +void outlangdef_set_out (FILE * out_str ) +{ + outlangdef_out = out_str ; +} + +int outlangdef_get_debug (void) +{ + return outlangdef__flex_debug; +} + +void outlangdef_set_debug (int bdebug ) +{ + outlangdef__flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from outlangdef_lex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + + (yy_start_stack_ptr) = 0; + (yy_start_stack_depth) = 0; + (yy_start_stack) = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + outlangdef_in = stdin; + outlangdef_out = stdout; +#else + outlangdef_in = (FILE *) 0; + outlangdef_out = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * outlangdef_lex_init() + */ + return 0; +} + +/* outlangdef_lex_destroy is for both reentrant and non-reentrant scanners. */ +int outlangdef_lex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + outlangdef__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + outlangdef_pop_buffer_state(); + } + + /* Destroy the stack itself. */ + outlangdef_free((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Destroy the start condition stack. */ + outlangdef_free((yy_start_stack) ); + (yy_start_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * outlangdef_lex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *outlangdef_alloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *outlangdef_realloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void outlangdef_free (void * ptr ) +{ + free( (char *) ptr ); /* see outlangdef_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 184 "../../../lib/srchilite/outlangdefscanner.ll" + + + +void buffer(const char *s) +{ + buff << s; +} + +void buffer(const char s) +{ + buff << s; +} + +void buffer_escape(const char *s) +{ + buff << "\\" << s; +} + +const std::string *flush_buffer() +{ + const std::string *ret = new std::string(buff.str()); + buff.str(""); + return ret; +} + +void open_include_file(const char *name) +{ + string file_name = name; + string path = outlang_parsestruct->path; + + if (! contains_path(name) && + contains_path(outlang_parsestruct->file_name)) + path = get_file_path(outlang_parsestruct->file_name); + + parsestructstack.push(outlang_parsestruct); + outlang_parsestruct = ParseStructPtr(new ParseStruct(path, file_name)); + open_outlang_file_to_scan(path.c_str(), file_name.c_str()); +} + +void close_include_file() +{ + outlang_parsestruct = parsestructstack.top(); + parsestructstack.pop(); +} + + +namespace srchilite { + +void open_outlang_file_to_scan(const string &path, const string &name) +{ + outlangdef_in = open_data_file_stream(path, name); +} + +void clear_outlangdefscanner() { + //delete stringTable; + outlangdef_lex_destroy(); +} + +void close_outlangdefinputfile() { + // also close possible open files due to inclusions + do { + if (outlangdef_in) + fclose(outlangdef_in); + outlangdef_pop_buffer_state(); + } while ( YY_CURRENT_BUFFER ); +} + +} + diff --git a/lib/srchilite/srchilite.pro b/lib/srchilite/srchilite.pro new file mode 100644 index 0000000..82f50bb --- /dev/null +++ b/lib/srchilite/srchilite.pro @@ -0,0 +1,104 @@ +include(../../defines.pri) + +TEMPLATE = lib + +# save information about the library: +CONFIG += create_prl + +TARGET = $$LIBRARY_NAME + +LIBS += $$ADDITIONAL_LIBRARIES + +HEADERS = parsestyles.h \ + stringdef.h langelem.h \ + statelangelem.h langelems.h langdefparserfun.h outlangdefparserfun.h \ + tostringcollection.h regexpreprocessor.h \ + langdefscanner.h outlangdefscanner.h parsestruct.h langmap.h statestartlangelem.h \ + stringlistlangelem.h delimitedlangelem.h vardefinitions.h textstyle.h \ + textstyles.h textstylebuilder.h doctemplate.h substfun.h \ + parserinfo.h readtags.h fileinfo.h linebuffer.h preformatter.h \ + langelemsprinter.h languageinfer.h stopwatch.h stylekey.h \ + namedsubexpslangelem.h refposition.h \ + highlightrule.h highlighttoken.h highlightrulefactory.h highlightstate.h \ + regexhighlightrule.h regexrulefactory.h \ + highlightstateprinter.h sourcehighlighter.h matchingparameters.h \ + formatter.h formattermanager.h \ + highlightstatebuilder.h highlightbuilderexception.h \ + wordtokenizer.h ctagscollector.h formatterparams.h ctagsformatter.h \ + sourcefilehighlighter.h linenumgenerator.h \ + textstyleformatter.h formatterfactory.h textstyleformatterfactory.h \ + langdefmanager.h sourcehighlight.h \ + textstyleformattercollection.h \ + ioexception.h parserexception.h stringtable.h \ + eventgenerator.h highlightevent.h highlighteventlistener.h \ + debuglistener.h ctagsmanager.h bufferedoutput.h lineranges.h regexranges.h \ + colors.h \ + keys.h styleparser.h stylecssparser.h \ + fileutil.h \ + chartranslator.h \ + docgenerator.h \ + copyright.h reportbugs.h \ + srcuntabifier.h colormap.h \ + langdefparser.h outlangdefparser.h \ + stylefileparser.h \ + settings.h \ + versions.h \ + verbosity.h \ + sourcehighlightutils.h utils.h \ + instances.h + +SOURCES += \ + fileutil.cc \ + substfun.cpp \ + stopwatch.cpp utils.cpp \ + ioexception.cpp \ + settings.cpp \ + versions.cpp \ + verbosity.cpp \ + sourcehighlight.cpp styleparser.cc \ + stylescanner.cc outlangdefparser.cc \ + stylecssparser.cc stylecssscanner.cc outlangdefscanner.cc \ + debuglistener.cpp langmap.cpp stylefileparser.cpp \ + langelem.cpp statelangelem.cpp \ + langelems.cpp statestartlangelem.cpp stringlistlangelem.cpp \ + delimitedlangelem.cpp langelemsprinter.cpp \ + namedsubexpslangelem.cpp stringdef.cpp \ + highlightrule.cpp highlighttoken.cpp \ + highlightstate.cpp highlightrulefactory.cpp highlightstateprinter.cpp \ + sourcehighlighter.cpp sourcefilehighlighter.cpp \ + linenumgenerator.cpp lineranges.cpp regexranges.cpp \ + formatter.cpp formattermanager.cpp \ + textstyle.cpp textstyleformatter.cpp bufferedoutput.cpp \ + preformatter.cpp wordtokenizer.cpp ctagscollector.cpp readtags.c ctagsformatter.cpp \ + srcuntabifier.cpp textstyleformatterfactory.cpp \ + docgenerator.cc doctemplate.cpp chartranslator.cc \ + textstylebuilder.cpp fileinfo.cpp ctagsmanager.cpp \ + regexhighlightrule.cpp regexrulefactory.cpp \ + regexpreprocessor.cpp \ + highlightstatebuilder.cpp \ + highlightbuilderexception.cpp langdefmanager.cpp \ + $$PWD/langdefparser.cc $$PWD/langdefscanner.cc \ + languageinfer.cpp \ + parserexception.cpp \ + stringtable.cpp vardefinitions.cpp \ + sourcehighlightutils.cpp \ + instances.cpp \ + langelemsprinter_dbtab.cc \ + highlightstatebuilder_dbtab.cc + +contains(COMPILER, msvc) { +# custom implementation of dirent.h functions +SOURCES += ../compat/compat_dirent.cpp +INCLUDEPATH += ../compat +DEPENDPATH += ../compat +} + +DESTDIR = ../../lib + +target.path = /lib + +headers.files = $$HEADERS +headers.path = /include/srchilite + +INSTALLS += target headers + diff --git a/lib/srchilite/stylecssparser.cc b/lib/srchilite/stylecssparser.cc new file mode 100644 index 0000000..ecaf691 --- /dev/null +++ b/lib/srchilite/stylecssparser.cc @@ -0,0 +1,1872 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by 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 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse stylecsssc_parse +#define yylex stylecsssc_lex +#define yyerror stylecsssc_error +#define yylval stylecsssc_lval +#define yychar stylecsssc_char +#define yydebug stylecsssc_debug +#define yynerrs stylecsssc_nerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BOLD = 258, + ITALICS = 259, + UNDERLINE = 260, + FIXED = 261, + NOTFIXED = 262, + NOREF = 263, + KEY = 264, + COLOR = 265, + BG_COLOR = 266, + STRINGDEF = 267, + BG_STRINGDEF = 268 + }; +#endif +/* Tokens. */ +#define BOLD 258 +#define ITALICS 259 +#define UNDERLINE 260 +#define FIXED 261 +#define NOTFIXED 262 +#define NOREF 263 +#define KEY 264 +#define COLOR 265 +#define BG_COLOR 266 +#define STRINGDEF 267 +#define BG_STRINGDEF 268 + + + + +/* Copy the first part of user declarations. */ +#line 1 "../../../lib/srchilite/stylecssparser.yy" + +/* + * Copyright (C) 1999-2007 Lorenzo Bettini <http://www.lorenzobettini.it> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <iostream> +#include <string> + +#include "formatterfactory.h" +#include "colors.h" +#include "keys.h" +#include "parsestyles.h" +#include "fileutil.h" +#include "stylekey.h" +#include "utils.h" +#include "parserexception.h" + +using std::cerr; + +using namespace srchilite; + +extern int line; + +static int yyparse() ; +static void yyerror( const char *s ) ; + +// line is defined in styleparser + +// to generate the formatter for each language element +static FormatterFactory *formatterFactory; + +static void updateBgColor(const std::string &c); + +// for the background color of the entire output +static string bodyBgColor; + +extern int stylecsssc_lex() ; +extern FILE *stylecsssc_in ; +extern int stylecsssc_lex_destroy (void); + +/// the global pointer to style constant for a specific element +static StyleConstantsPtr currentStyleConstants; +/// the global pointer to the current color +static string currentColor; +/// the global pointer to the current bg color +static string currentBGColor; + +/// where we store possible errors +static string errorBuffer; + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 70 "../../../lib/srchilite/stylecssparser.yy" +{ + int tok ; /* command */ + const std::string * string ; /* string : id, ... */ + srchilite::StyleConstant flag ; + srchilite::StyleConstants *styleconstants; + srchilite::KeyList *keylist; +} +/* Line 187 of yacc.c. */ +#line 207 "stylecssparser.cc" + 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 216 of yacc.c. */ +#line 220 "stylecssparser.cc" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# 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 +{ + yytype_int16 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 (yytype_int16) + 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 \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (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 (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 7 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 15 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 16 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 12 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 25 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 28 + +/* 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 yytype_uint8 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, 15, 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 yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 6, 9, 11, 13, 14, 19, + 23, 25, 26, 29, 31, 33, 35, 37, 39, 41, + 43, 45, 47, 49, 51, 53 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 17, 0, -1, -1, 18, -1, 18, 19, -1, 19, + -1, 20, -1, -1, 22, 21, 23, 14, -1, 22, + 15, 9, -1, 9, -1, -1, 23, 24, -1, 25, + -1, 26, -1, 27, -1, 10, -1, 12, -1, 11, + -1, 13, -1, 3, -1, 4, -1, 5, -1, 6, + -1, 7, -1, 8, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 90, 90, 91, 94, 95, 98, 102, 101, 143, + 149, 157, 158, 161, 162, 163, 166, 171, 178, 183, + 190, 191, 192, 193, 194, 195 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[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", "BOLD", "ITALICS", "UNDERLINE", "FIXED", + "NOTFIXED", "NOREF", "KEY", "COLOR", "BG_COLOR", "STRINGDEF", + "BG_STRINGDEF", "';'", "','", "$accept", "stylefile", "statements", + "statement", "option", "@1", "keylist", "optionspecs", "optionspec", + "color", "bgcolor", "styleconstant", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 59, 44 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 16, 17, 17, 18, 18, 19, 21, 20, 22, + 22, 23, 23, 24, 24, 24, 25, 25, 26, 26, + 27, 27, 27, 27, 27, 27 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 2, 1, 1, 0, 4, 3, + 1, 0, 2, 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 yytype_uint8 yydefact[] = +{ + 2, 10, 0, 3, 5, 6, 7, 1, 4, 0, + 11, 9, 0, 20, 21, 22, 23, 24, 25, 16, + 18, 17, 19, 8, 12, 13, 14, 15 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 3, 4, 5, 10, 6, 12, 24, 25, + 26, 27 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -4 +static const yytype_int8 yypact[] = +{ + 3, -4, 6, 3, -4, -4, -2, -4, -4, 5, + -4, -4, -3, -4, -4, -4, -4, -4, -4, -4, + -4, -4, -4, -4, -4, -4, -4, -4 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -4, -4, -4, 12, -4, -4, -4, -4, -4, -4, + -4, -4 +}; + +/* 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 yytype_uint8 yytable[] = +{ + 13, 14, 15, 16, 17, 18, 7, 19, 20, 21, + 22, 23, 1, 9, 11, 8 +}; + +static const yytype_uint8 yycheck[] = +{ + 3, 4, 5, 6, 7, 8, 0, 10, 11, 12, + 13, 14, 9, 15, 9, 3 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 9, 17, 18, 19, 20, 22, 0, 19, 15, + 21, 9, 23, 3, 4, 5, 6, 7, 8, 10, + 11, 12, 13, 14, 24, 25, 26, 27 +}; + +#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 (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; 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 (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, 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 + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# 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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '0円') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '0円'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '0円'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '0円') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + case 9: /* "KEY" */ +#line 83 "../../../lib/srchilite/stylecssparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1125 "stylecssparser.cc" + break; + case 10: /* "COLOR" */ +#line 83 "../../../lib/srchilite/stylecssparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1133 "stylecssparser.cc" + break; + case 11: /* "BG_COLOR" */ +#line 83 "../../../lib/srchilite/stylecssparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1141 "stylecssparser.cc" + break; + case 12: /* "STRINGDEF" */ +#line 83 "../../../lib/srchilite/stylecssparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1149 "stylecssparser.cc" + break; + case 22: /* "keylist" */ +#line 83 "../../../lib/srchilite/stylecssparser.yy" + { + if ((yyvaluep->keylist)) + delete (yyvaluep->keylist); +}; +#line 1157 "stylecssparser.cc" + break; + + 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 */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* 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. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + 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; + yytype_int16 *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 (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + 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 + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead 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); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + 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 90 "../../../lib/srchilite/stylecssparser.yy" + { /* allow empty files */ } + break; + + case 7: +#line 102 "../../../lib/srchilite/stylecssparser.yy" + { + //printSequence( 1ドル ) ; + //printMessage_noln( ": " ) ; + currentStyleConstants = StyleConstantsPtr(new StyleConstants); + currentColor = ""; + currentBGColor = ""; + } + break; + + case 8: +#line 110 "../../../lib/srchilite/stylecssparser.yy" + { + KeyType key; + KeyList *keylist = (yyvsp[(1) - (4)].keylist); + for (KeyList::const_iterator it = keylist->begin(); it != keylist->end(); ++it) { + key = *it; + // check whether it's the body specification + if (Utils::tolower(key) == "body") { + updateBgColor(currentBGColor); + + // notice that for text style specification for the body, the background + // is assumed for the entire document and not for the normal text + // following the semantics of css + + // avoid adding an empty style definition for normal + if (currentColor != "" || currentStyleConstants->size()) { + if (!formatterFactory->createFormatter(NORMAL, currentColor, "", currentStyleConstants)) { + errorBuffer = "already defined " NORMAL; + delete keylist; + YYERROR; + } + } + } else { + if (!formatterFactory->createFormatter(key, currentColor, currentBGColor, currentStyleConstants)) { + errorBuffer = "already defined " + key; + delete keylist; + YYERROR; + } + } + } + delete keylist; + } + break; + + case 9: +#line 144 "../../../lib/srchilite/stylecssparser.yy" + { + (yyvsp[(1) - (3)].keylist)->push_back(*(yyvsp[(3) - (3)].string)); + (yyval.keylist) = (yyvsp[(1) - (3)].keylist); + delete (yyvsp[(3) - (3)].string); + } + break; + + case 10: +#line 150 "../../../lib/srchilite/stylecssparser.yy" + { + (yyval.keylist) = new KeyList; + (yyval.keylist)->push_back(*(yyvsp[(1) - (1)].string)); + delete (yyvsp[(1) - (1)].string); + } + break; + + case 11: +#line 157 "../../../lib/srchilite/stylecssparser.yy" + {} + break; + + case 16: +#line 167 "../../../lib/srchilite/stylecssparser.yy" + { + currentColor = *(yyvsp[(1) - (1)].string); + delete (yyvsp[(1) - (1)].string); + } + break; + + case 17: +#line 172 "../../../lib/srchilite/stylecssparser.yy" + { + currentColor = *(yyvsp[(1) - (1)].string); + delete (yyvsp[(1) - (1)].string); + } + break; + + case 18: +#line 179 "../../../lib/srchilite/stylecssparser.yy" + { + currentBGColor = *(yyvsp[(1) - (1)].string); + delete (yyvsp[(1) - (1)].string); + } + break; + + case 19: +#line 184 "../../../lib/srchilite/stylecssparser.yy" + { + currentBGColor = *(yyvsp[(1) - (1)].string); + delete (yyvsp[(1) - (1)].string); + } + break; + + case 20: +#line 190 "../../../lib/srchilite/stylecssparser.yy" + { currentStyleConstants->push_back(ISBOLD); } + break; + + case 21: +#line 191 "../../../lib/srchilite/stylecssparser.yy" + { currentStyleConstants->push_back(ISITALIC); } + break; + + case 22: +#line 192 "../../../lib/srchilite/stylecssparser.yy" + { currentStyleConstants->push_back(ISUNDERLINE); } + break; + + case 23: +#line 193 "../../../lib/srchilite/stylecssparser.yy" + { currentStyleConstants->push_back(ISFIXED); } + break; + + case 24: +#line 194 "../../../lib/srchilite/stylecssparser.yy" + { currentStyleConstants->push_back(ISNOTFIXED); } + break; + + case 25: +#line 195 "../../../lib/srchilite/stylecssparser.yy" + { currentStyleConstants->push_back(ISNOREF); } + break; + + +/* Line 1267 of yacc.c. */ +#line 1603 "stylecssparser.cc" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + 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 + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + 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; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 198 "../../../lib/srchilite/stylecssparser.yy" + + +// string current_file; defined in styleparser + +extern string current_file; + +void +yyerror( const char *s ) +{ + errorBuffer = s; +} + +void updateBgColor(const std::string &c) +{ + if (bodyBgColor != "") + yyerror("bgcolor already defined"); + else + bodyBgColor = c; +} + +namespace srchilite { + +void parseCssStyles(const string &path, const string &name, FormatterFactory *genFactory, + string &bodyBgColor_) +{ + formatterFactory = genFactory; + errorBuffer = ""; + int result = 1; + line = 1; + + // opens the file for yylex + stylecsssc_in = open_data_file_stream(path, name); + + if (contains_path(name)) + current_file = name; + else + current_file = (path.size() ? path + "/" : "") + name; + + bodyBgColor = ""; + + result = yyparse() ; + + bodyBgColor_ = bodyBgColor; + + fclose(stylecsssc_in); + + // release scanner memory + stylecsssc_lex_destroy(); + + if (result != 0 || errorBuffer.size()) { + throw ParserException(errorBuffer, current_file, line); + } +} + +} + diff --git a/lib/srchilite/stylecssparser.h b/lib/srchilite/stylecssparser.h new file mode 100644 index 0000000..048969c --- /dev/null +++ b/lib/srchilite/stylecssparser.h @@ -0,0 +1,90 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BOLD = 258, + ITALICS = 259, + UNDERLINE = 260, + FIXED = 261, + NOTFIXED = 262, + NOREF = 263, + KEY = 264, + COLOR = 265, + BG_COLOR = 266, + STRINGDEF = 267, + BG_STRINGDEF = 268 + }; +#endif +/* Tokens. */ +#define BOLD 258 +#define ITALICS 259 +#define UNDERLINE 260 +#define FIXED 261 +#define NOTFIXED 262 +#define NOREF 263 +#define KEY 264 +#define COLOR 265 +#define BG_COLOR 266 +#define STRINGDEF 267 +#define BG_STRINGDEF 268 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 70 "../../../lib/srchilite/stylecssparser.yy" +{ + int tok ; /* command */ + const std::string * string ; /* string : id, ... */ + srchilite::StyleConstant flag ; + srchilite::StyleConstants *styleconstants; + srchilite::KeyList *keylist; +} +/* Line 1489 of yacc.c. */ +#line 83 "stylecssparser.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE stylecsssc_lval; + diff --git a/lib/srchilite/stylecssscanner.cc b/lib/srchilite/stylecssscanner.cc new file mode 100644 index 0000000..c0d4d8f --- /dev/null +++ b/lib/srchilite/stylecssscanner.cc @@ -0,0 +1,2306 @@ +#line 2 "stylecssscanner.cc" + +#line 4 "stylecssscanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer stylecsssc__create_buffer +#define yy_delete_buffer stylecsssc__delete_buffer +#define yy_flex_debug stylecsssc__flex_debug +#define yy_init_buffer stylecsssc__init_buffer +#define yy_flush_buffer stylecsssc__flush_buffer +#define yy_load_buffer_state stylecsssc__load_buffer_state +#define yy_switch_to_buffer stylecsssc__switch_to_buffer +#define yyin stylecsssc_in +#define yyleng stylecsssc_leng +#define yylex stylecsssc_lex +#define yylineno stylecsssc_lineno +#define yyout stylecsssc_out +#define yyrestart stylecsssc_restart +#define yytext stylecsssc_text +#define yywrap stylecsssc_wrap +#define yyalloc stylecsssc_alloc +#define yyrealloc stylecsssc_realloc +#define yyfree stylecsssc_free + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* 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 stylecsssc_restart(stylecsssc_in ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int stylecsssc_leng; + +extern FILE *stylecsssc_in, *stylecsssc_out; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up stylecsssc_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up stylecsssc_text again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + 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; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via stylecsssc_restart()), so that the user can continue scanning by + * just pointing stylecsssc_in at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when stylecsssc_text is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int stylecsssc_leng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow stylecsssc_wrap()'s to do buffer switches + * instead of setting up a fresh stylecsssc_in. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void stylecsssc_restart (FILE *input_file ); +void stylecsssc__switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE stylecsssc__create_buffer (FILE *file,int size ); +void stylecsssc__delete_buffer (YY_BUFFER_STATE b ); +void stylecsssc__flush_buffer (YY_BUFFER_STATE b ); +void stylecsssc_push_buffer_state (YY_BUFFER_STATE new_buffer ); +void stylecsssc_pop_buffer_state (void ); + +static void stylecsssc_ensure_buffer_stack (void ); +static void stylecsssc__load_buffer_state (void ); +static void stylecsssc__init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER stylecsssc__flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE stylecsssc__scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE stylecsssc__scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE stylecsssc__scan_bytes (yyconst char *bytes,int len ); + +void *stylecsssc_alloc (yy_size_t ); +void *stylecsssc_realloc (void *,yy_size_t ); +void stylecsssc_free (void * ); + +#define yy_new_buffer stylecsssc__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + stylecsssc_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + stylecsssc__create_buffer(stylecsssc_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + stylecsssc_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + stylecsssc__create_buffer(stylecsssc_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define stylecsssc_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *stylecsssc_in = (FILE *) 0, *stylecsssc_out = (FILE *) 0; + +typedef int yy_state_type; + +extern int stylecsssc_lineno; + +int stylecsssc_lineno = 1; + +extern char *stylecsssc_text; +#define yytext_ptr stylecsssc_text + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up stylecsssc_text. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + stylecsssc_leng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '0円'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 31 +#define YY_END_OF_BUFFER 32 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[274] = + { 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, 32, 30, 1, 8, 2, 1, + 9, 30, 30, 31, 1, 2, 1, 31, 4, 1, + 5, 2, 1, 4, 6, 11, 7, 12, 29, 1, + 2, 1, 29, 29, 29, 29, 29, 27, 1, 1, + 15, 28, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 20, 20, 22, 22, 24, 24, 26, 26, 1, + 1, 3, 0, 7, 0, 0, 0, 0, 15, 15, + + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 20, 3, 22, 3, 24, 3, 26, 3, + 0, 0, 0, 0, 0, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 14, 15, 15, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 17, 18, 18, 10, 0, 0, 0, 0, 15, 15, + 15, 15, 15, 15, 15, 15, 18, 18, 18, 18, + 18, 18, 18, 18, 0, 13, 0, 0, 15, 15, + 15, 15, 15, 15, 15, 18, 18, 18, 18, 18, + + 18, 18, 0, 0, 0, 0, 0, 15, 15, 15, + 15, 18, 18, 18, 18, 0, 0, 0, 0, 0, + 15, 15, 15, 15, 18, 18, 18, 18, 0, 0, + 0, 0, 0, 15, 15, 15, 18, 18, 18, 0, + 0, 0, 0, 0, 15, 15, 18, 18, 0, 0, + 21, 0, 0, 15, 15, 18, 18, 0, 23, 19, + 0, 15, 18, 0, 0, 0, 0, 0, 0, 0, + 25, 16, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 1, 1, 6, 1, 1, 1, 1, 1, + 1, 7, 1, 8, 9, 10, 11, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 13, 14, 1, + 1, 1, 1, 1, 15, 16, 15, 17, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 18, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 19, 15, + 1, 1, 1, 1, 20, 1, 21, 22, 23, 24, + + 25, 26, 27, 28, 29, 15, 30, 31, 32, 33, + 34, 35, 15, 36, 37, 38, 39, 15, 40, 41, + 42, 15, 43, 1, 44, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[45] = + { 0, + 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, + 1, 4, 2, 2, 4, 4, 4, 4, 4, 5, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[290] = + { 0, + 0, 21, 4, 16, 31, 36, 46, 50, 61, 105, + 148, 191, 235, 0, 279, 0, 322, 335, 348, 361, + 374, 387, 400, 413, 541, 542, 538, 542, 542, 534, + 542, 531, 10, 542, 535, 542, 531, 528, 542, 532, + 542, 542, 528, 525, 542, 542, 0, 542, 542, 529, + 542, 525, 522, 507, 493, 492, 500, 542, 522, 518, + 0, 542, 45, 480, 500, 484, 483, 17, 493, 492, + 491, 0, 46, 473, 493, 477, 476, 49, 486, 485, + 484, 0, 501, 0, 500, 0, 499, 0, 498, 502, + 498, 542, 62, 0, 479, 470, 467, 458, 0, 59, + + 55, 474, 454, 62, 464, 447, 389, 399, 401, 390, + 0, 64, 61, 399, 383, 71, 391, 377, 373, 384, + 386, 375, 0, 0, 0, 0, 0, 0, 0, 0, + 78, 369, 363, 358, 357, 371, 368, 359, 344, 350, + 352, 339, 355, 340, 341, 335, 0, 338, 337, 344, + 335, 331, 317, 323, 325, 312, 322, 312, 314, 308, + 0, 311, 310, 542, 307, 296, 322, 321, 299, 300, + 201, 99, 200, 205, 200, 196, 198, 199, 193, 100, + 192, 197, 192, 188, 185, 542, 97, 196, 181, 187, + 180, 190, 187, 186, 170, 171, 177, 171, 181, 180, + + 179, 163, 167, 179, 161, 173, 172, 66, 152, 165, + 165, 67, 149, 162, 161, 145, 151, 140, 152, 157, + 143, 142, 152, 151, 139, 137, 147, 144, 135, 138, + 135, 138, 130, 138, 141, 128, 135, 137, 124, 132, + 124, 129, 119, 110, 120, 111, 118, 109, 132, 98, + 542, 101, 117, 100, 105, 98, 103, 106, 542, 542, + 90, 100, 99, 68, 70, 60, 26, 25, 25, 9, + 542, 542, 542, 427, 432, 437, 442, 447, 452, 457, + 462, 467, 469, 472, 474, 478, 483, 488, 493 + } ; + +static yyconst flex_int16_t yy_def[290] = + { 0, + 274, 274, 275, 275, 276, 276, 275, 275, 277, 277, + 278, 278, 273, 13, 273, 15, 279, 279, 280, 280, + 281, 281, 282, 282, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 283, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 284, 273, 284, 284, 284, 284, 284, 284, 284, 284, + 284, 285, 285, 285, 285, 285, 285, 285, 285, 285, + 285, 286, 286, 287, 287, 288, 288, 289, 289, 273, + 273, 273, 273, 283, 273, 273, 273, 273, 284, 284, + + 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, + 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, + 285, 285, 286, 286, 287, 287, 288, 288, 289, 289, + 273, 273, 273, 273, 273, 284, 284, 284, 284, 284, + 284, 284, 284, 284, 284, 284, 284, 284, 284, 285, + 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, + 285, 285, 285, 273, 273, 273, 273, 273, 284, 284, + 284, 284, 284, 284, 284, 284, 285, 285, 285, 285, + 285, 285, 285, 285, 273, 273, 273, 273, 284, 284, + 284, 284, 284, 284, 284, 285, 285, 285, 285, 285, + + 285, 285, 273, 273, 273, 273, 273, 284, 284, 284, + 284, 285, 285, 285, 285, 273, 273, 273, 273, 273, + 284, 284, 284, 284, 285, 285, 285, 285, 273, 273, + 273, 273, 273, 284, 284, 284, 285, 285, 285, 273, + 273, 273, 273, 273, 284, 284, 285, 285, 273, 273, + 273, 273, 273, 284, 284, 285, 285, 273, 273, 273, + 273, 284, 285, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 0, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273 + } ; + +static yyconst flex_int16_t yy_nxt[587] = + { 0, + 273, 27, 28, 29, 30, 35, 28, 36, 37, 31, + 32, 273, 273, 273, 38, 33, 273, 35, 28, 36, + 37, 33, 27, 28, 29, 30, 38, 93, 273, 273, + 31, 32, 40, 41, 42, 43, 33, 40, 41, 42, + 43, 44, 33, 93, 272, 106, 44, 35, 28, 36, + 37, 35, 28, 36, 37, 107, 38, 271, 270, 269, + 38, 34, 35, 28, 36, 37, 34, 34, 45, 34, + 46, 38, 34, 34, 34, 100, 112, 118, 131, 136, + 101, 113, 142, 138, 150, 131, 143, 119, 139, 152, + 268, 156, 221, 225, 153, 157, 164, 137, 267, 222, + + 226, 266, 151, 48, 34, 34, 35, 28, 36, 37, + 34, 34, 45, 34, 46, 38, 34, 34, 34, 164, + 190, 197, 204, 161, 147, 191, 198, 265, 264, 263, + 161, 262, 147, 205, 192, 199, 206, 261, 260, 259, + 258, 257, 256, 255, 254, 253, 252, 48, 34, 50, + 28, 51, 52, 251, 250, 249, 161, 248, 53, 247, + 147, 246, 245, 244, 243, 242, 241, 240, 239, 54, + 55, 161, 238, 56, 237, 236, 147, 235, 234, 233, + 232, 231, 230, 229, 161, 57, 228, 227, 147, 224, + 223, 58, 50, 28, 51, 52, 220, 219, 218, 217, + + 216, 53, 161, 161, 161, 215, 214, 213, 212, 147, + 147, 147, 54, 55, 211, 210, 56, 209, 208, 207, + 203, 202, 201, 200, 161, 161, 196, 161, 57, 195, + 194, 193, 147, 147, 58, 34, 59, 28, 36, 60, + 61, 34, 34, 34, 34, 38, 61, 62, 62, 61, + 61, 61, 61, 61, 34, 61, 63, 64, 65, 61, + 61, 66, 61, 61, 61, 61, 61, 61, 67, 68, + 69, 61, 70, 61, 61, 61, 71, 34, 34, 34, + 59, 28, 36, 60, 72, 34, 34, 34, 34, 38, + 72, 62, 62, 72, 72, 72, 72, 72, 34, 72, + + 73, 74, 75, 72, 72, 76, 72, 72, 72, 72, + 72, 72, 77, 78, 79, 72, 80, 72, 72, 72, + 81, 34, 34, 59, 28, 36, 60, 189, 147, 188, + 187, 186, 83, 185, 62, 62, 59, 28, 36, 60, + 184, 161, 183, 161, 182, 83, 181, 62, 62, 59, + 28, 36, 60, 161, 180, 161, 179, 178, 85, 161, + 62, 62, 59, 28, 36, 60, 177, 176, 147, 175, + 147, 85, 174, 62, 62, 59, 28, 36, 60, 173, + 147, 172, 147, 171, 87, 170, 62, 62, 59, 28, + 36, 60, 147, 169, 168, 167, 166, 87, 165, 62, + + 62, 59, 28, 36, 60, 163, 162, 161, 160, 159, + 89, 158, 62, 62, 59, 28, 36, 60, 155, 154, + 149, 148, 147, 89, 146, 62, 62, 26, 26, 26, + 26, 26, 34, 34, 34, 34, 34, 39, 39, 39, + 39, 39, 47, 47, 47, 47, 47, 49, 49, 49, + 49, 49, 82, 82, 82, 82, 82, 84, 84, 84, + 84, 84, 86, 86, 86, 86, 86, 88, 88, 88, + 88, 88, 94, 94, 99, 99, 111, 111, 123, 145, + 123, 123, 123, 125, 144, 125, 125, 125, 127, 141, + 127, 127, 127, 129, 140, 129, 129, 129, 135, 134, + + 133, 132, 91, 90, 130, 128, 126, 124, 122, 121, + 120, 117, 116, 115, 114, 110, 109, 108, 105, 104, + 103, 102, 91, 90, 98, 97, 96, 95, 92, 91, + 90, 92, 91, 90, 92, 91, 90, 92, 91, 90, + 273, 25, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273 + } ; + +static yyconst flex_int16_t yy_chk[587] = + { 0, + 0, 1, 1, 1, 1, 3, 3, 3, 3, 1, + 1, 0, 0, 0, 3, 1, 0, 4, 4, 4, + 4, 1, 2, 2, 2, 2, 4, 33, 0, 0, + 2, 2, 5, 5, 5, 5, 2, 6, 6, 6, + 6, 5, 2, 33, 270, 68, 6, 7, 7, 7, + 7, 8, 8, 8, 8, 68, 7, 269, 268, 267, + 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 63, 73, 78, 93, 100, + 63, 73, 104, 101, 112, 93, 104, 78, 101, 113, + 266, 116, 208, 212, 113, 116, 131, 100, 265, 208, + + 212, 264, 112, 9, 9, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 131, + 172, 180, 187, 263, 262, 172, 180, 261, 258, 257, + 256, 255, 254, 187, 172, 180, 187, 253, 252, 250, + 249, 248, 247, 246, 245, 244, 243, 10, 10, 11, + 11, 11, 11, 242, 241, 240, 239, 238, 11, 237, + 236, 235, 234, 233, 232, 231, 230, 229, 228, 11, + 11, 227, 226, 11, 225, 224, 223, 222, 221, 220, + 219, 218, 217, 216, 215, 11, 214, 213, 211, 210, + 209, 11, 12, 12, 12, 12, 207, 206, 205, 204, + + 203, 12, 202, 201, 200, 199, 198, 197, 196, 195, + 194, 193, 12, 12, 192, 191, 12, 190, 189, 188, + 185, 184, 183, 182, 181, 179, 178, 177, 12, 176, + 175, 174, 173, 171, 12, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 17, 17, 17, 17, 170, 169, 168, + 167, 166, 17, 165, 17, 17, 18, 18, 18, 18, + 163, 162, 160, 159, 158, 18, 157, 18, 18, 19, + 19, 19, 19, 156, 155, 154, 153, 152, 19, 151, + 19, 19, 20, 20, 20, 20, 150, 149, 148, 146, + 145, 20, 144, 20, 20, 21, 21, 21, 21, 143, + 142, 141, 140, 139, 21, 138, 21, 21, 22, 22, + 22, 22, 137, 136, 135, 134, 133, 22, 132, 22, + + 22, 23, 23, 23, 23, 122, 121, 120, 119, 118, + 23, 117, 23, 23, 24, 24, 24, 24, 115, 114, + 110, 109, 108, 24, 107, 24, 24, 274, 274, 274, + 274, 274, 275, 275, 275, 275, 275, 276, 276, 276, + 276, 276, 277, 277, 277, 277, 277, 278, 278, 278, + 278, 278, 279, 279, 279, 279, 279, 280, 280, 280, + 280, 280, 281, 281, 281, 281, 281, 282, 282, 282, + 282, 282, 283, 283, 284, 284, 285, 285, 286, 106, + 286, 286, 286, 287, 105, 287, 287, 287, 288, 103, + 288, 288, 288, 289, 102, 289, 289, 289, 98, 97, + + 96, 95, 91, 90, 89, 87, 85, 83, 81, 80, + 79, 77, 76, 75, 74, 71, 70, 69, 67, 66, + 65, 64, 60, 59, 57, 56, 55, 54, 53, 52, + 50, 44, 43, 40, 38, 37, 35, 32, 30, 27, + 25, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273, 273, 273, 273, 273, + 273, 273, 273, 273, 273, 273 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int stylecsssc__flex_debug; +int stylecsssc__flex_debug = 0; + +/* 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 *stylecsssc_text; +#line 1 "../../../lib/srchilite/stylecssscanner.ll" +#line 2 "../../../lib/srchilite/stylecssscanner.ll" +/* + * Copyright (C) 1999-2007 Lorenzo Bettini, http://www.lorenzobettini.it + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdlib.h> +#include <string.h> + +#include "stylekey.h" + +#include "formatterfactory.h" +#include "stylecssparser.h" +#include <sstream> +#include "parsestyles.h" + +using namespace srchilite; + +static std::ostringstream buff; + +extern int line ; + +//#define DEBUG_SCANNER +#ifdef DEBUG_SCANNER +#include <iostream> // for debug +#define DEB(s) std::cerr << s << std::endl; +#define DEB2(s,s2) std::cerr << s << ": " << s2 << std::endl; +#else +#define DEB(s) +#define DEB2(s,s2) +#endif + + +#line 747 "stylecssscanner.cc" + +#define INITIAL 0 +#define COMMENT_STATE 1 +#define MULTI_COMMENT_STATE 2 +#define STRING_STATE 3 +#define CSS_SELECTOR 4 +#define CSS_PROPERTIES 5 +#define CSS_COLOR 6 +#define CSS_BG_COLOR 7 +#define CSS_FONT_WEIGHT 8 +#define CSS_FONT_STYLE 9 +#define CSS_FONT_FAMILY 10 +#define CSS_TEXT_DECORATION 11 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int stylecsssc_lex_destroy (void ); + +int stylecsssc_get_debug (void ); + +void stylecsssc_set_debug (int debug_flag ); + +YY_EXTRA_TYPE stylecsssc_get_extra (void ); + +void stylecsssc_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *stylecsssc_get_in (void ); + +void stylecsssc_set_in (FILE * in_str ); + +FILE *stylecsssc_get_out (void ); + +void stylecsssc_set_out (FILE * out_str ); + +int stylecsssc_get_leng (void ); + +char *stylecsssc_get_text (void ); + +int stylecsssc_get_lineno (void ); + +void stylecsssc_set_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int stylecsssc_wrap (void ); +#else +extern int stylecsssc_wrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#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 do { if (fwrite( stylecsssc_text, stylecsssc_leng, 1, stylecsssc_out )) {} } while (0) +#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_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( stylecsssc_in )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( stylecsssc_in ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, stylecsssc_in))==0 && ferror(stylecsssc_in)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(stylecsssc_in); \ + } \ + }\ +\ + +#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 + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int stylecsssc_lex (void); + +#define YY_DECL int stylecsssc_lex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after stylecsssc_text and stylecsssc_leng + * 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 + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 65 "../../../lib/srchilite/stylecssscanner.ll" + + +#line 948 "stylecssscanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! stylecsssc_in ) + stylecsssc_in = stdin; + + if ( ! stylecsssc_out ) + stylecsssc_out = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + stylecsssc_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + stylecsssc__create_buffer(stylecsssc_in,YY_BUF_SIZE ); + } + + stylecsssc__load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of stylecsssc_text. */ + *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 >= 274 ) + 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] != 542 ); + +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 67 "../../../lib/srchilite/stylecssscanner.ll" +{} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 69 "../../../lib/srchilite/stylecssscanner.ll" +{} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 71 "../../../lib/srchilite/stylecssscanner.ll" +{ BEGIN(MULTI_COMMENT_STATE); } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 72 "../../../lib/srchilite/stylecssscanner.ll" +{} + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 73 "../../../lib/srchilite/stylecssscanner.ll" +{ ++line; BEGIN(INITIAL); } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 76 "../../../lib/srchilite/stylecssscanner.ll" +{ return ',' ; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 77 "../../../lib/srchilite/stylecssscanner.ll" +{ stylecsssc_lval.string = new std::string(stylecsssc_text) ; return KEY ; } + YY_BREAK +case 8: +/* rule 8 can match eol */ +YY_RULE_SETUP +#line 79 "../../../lib/srchilite/stylecssscanner.ll" +{ ++line ; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 81 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_SELECTOR) ; + DEB("CSS SELECTOR"); +} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 85 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_SELECTOR) ; + DEB("BODY CSS SELECTOR"); + stylecsssc_lval.string = new std::string(stylecsssc_text) ; + return KEY; +} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 92 "../../../lib/srchilite/stylecssscanner.ll" +{ + // in case of comma separated selectors + DEB("CSS SELECTOR"); +} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 96 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + DEB("CSS PROPERTIES"); +} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 100 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_COLOR); + DEB("CSS COLOR"); +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 104 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + stylecsssc_lval.string = new std::string(stylecsssc_text) ; + DEB2("CSS COLOR", stylecsssc_text); + return COLOR ; +} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 110 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + DEB2("CSS COLOR", stylecsssc_text); + /* + we need to add the " in order to make source-highlight realize + that this is a direct color specification + */ + stylecsssc_lval.string = new std::string("\"" + std::string(stylecsssc_text) + "\""); + return STRINGDEF; +} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 120 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_BG_COLOR); + DEB("CSS BACKGROUND COLOR"); +} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 124 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + stylecsssc_lval.string = new std::string(stylecsssc_text) ; + DEB2("CSS BG COLOR", stylecsssc_text); + return BG_COLOR ; +} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 130 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + DEB2("CSS BG COLOR", stylecsssc_text); + /* + we need to add the " in order to make source-highlight realize + that this is a direct color specification + */ + stylecsssc_lval.string = new std::string("\"" + std::string(stylecsssc_text) + "\""); + return BG_STRINGDEF; +} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 140 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_FONT_WEIGHT); + DEB("CSS FONT WEIGHT"); +} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 144 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + if (strcmp(stylecsssc_text, "bold") == 0) { + DEB("CSS BOLD"); + stylecsssc_lval.flag = srchilite::ISBOLD ; + return BOLD ; + } + DEB2("discarding not handled value", stylecsssc_text); +} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 153 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_FONT_STYLE); + DEB("CSS FONT STYLE"); +} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 157 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + if (strcmp(stylecsssc_text, "italic") == 0) { + DEB("CSS ITALIC"); + stylecsssc_lval.flag = srchilite::ISITALIC ; + return ITALICS ; + } + DEB2("discarding not handled value", stylecsssc_text); +} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 166 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_FONT_FAMILY); + DEB("CSS FONT FAMILY"); +} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 170 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + if (strcmp(stylecsssc_text, "monospace") == 0) { + DEB("CSS FIXED"); + stylecsssc_lval.flag = srchilite::ISFIXED ; + return FIXED ; + } + DEB2("discarding not handled value", stylecsssc_text); +} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 179 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_TEXT_DECORATION); + DEB("CSS TEXT DECORATION"); +} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 183 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(CSS_PROPERTIES); + if (strcmp(stylecsssc_text, "underline") == 0) { + DEB("CSS UNDERLINE"); + stylecsssc_lval.flag = srchilite::ISUNDERLINE ; + return UNDERLINE ; + } + DEB2("discarding not handled value", stylecsssc_text); +} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 192 "../../../lib/srchilite/stylecssscanner.ll" +{ + BEGIN(INITIAL); + DEB("CSS END PROPERTIES"); + /* + we must return ; since this is the terminator of a style option + so we simulate it in case of css files + */ + return ';' ; +} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 201 "../../../lib/srchilite/stylecssscanner.ll" +{ + /* discard other characters */ + DEB2("CSS discarding", stylecsssc_text); +} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 205 "../../../lib/srchilite/stylecssscanner.ll" +{ + /* discard other properties */ + DEB2("CSS PROPERTIES discarding", stylecsssc_text); +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 210 "../../../lib/srchilite/stylecssscanner.ll" +{ return stylecsssc_text[0] ; } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 212 "../../../lib/srchilite/stylecssscanner.ll" +ECHO; + YY_BREAK +#line 1294 "stylecssscanner.cc" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT_STATE): +case YY_STATE_EOF(MULTI_COMMENT_STATE): +case YY_STATE_EOF(STRING_STATE): +case YY_STATE_EOF(CSS_SELECTOR): +case YY_STATE_EOF(CSS_PROPERTIES): +case YY_STATE_EOF(CSS_COLOR): +case YY_STATE_EOF(CSS_BG_COLOR): +case YY_STATE_EOF(CSS_FONT_WEIGHT): +case YY_STATE_EOF(CSS_FONT_STYLE): +case YY_STATE_EOF(CSS_FONT_FAMILY): +case YY_STATE_EOF(CSS_TEXT_DECORATION): + 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_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed stylecsssc_in at a new source and called + * stylecsssc_lex(). 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_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = stylecsssc_in; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->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 ( stylecsssc_wrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * stylecsssc_text, 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_LVALUE->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 stylecsssc_lex */ + +/* 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 (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (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_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((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. */ + stylecsssc_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_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->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; + stylecsssc_restart(stylecsssc_in ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) stylecsssc_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + 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 >= 274 ) + 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 ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + 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 >= 274 ) + 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 == 273); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up stylecsssc_text */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#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_LVALUE->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. */ + stylecsssc_restart(stylecsssc_in ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( stylecsssc_wrap( ) ) + 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 stylecsssc_text */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void stylecsssc_restart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + stylecsssc_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + stylecsssc__create_buffer(stylecsssc_in,YY_BUF_SIZE ); + } + + stylecsssc__init_buffer(YY_CURRENT_BUFFER,input_file ); + stylecsssc__load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void stylecsssc__switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * stylecsssc_pop_buffer_state(); + * stylecsssc_push_buffer_state(new_buffer); + */ + stylecsssc_ensure_buffer_stack (); + 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_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + stylecsssc__load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (stylecsssc_wrap()) processing, but the only time this flag + * is looked at is after stylecsssc_wrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void stylecsssc__load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + stylecsssc_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE stylecsssc__create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) stylecsssc_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in stylecsssc__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 *) stylecsssc_alloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in stylecsssc__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + stylecsssc__init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with stylecsssc__create_buffer() + * + */ + void stylecsssc__delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + stylecsssc_free((void *) b->yy_ch_buf ); + + stylecsssc_free((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a stylecsssc_restart() or at EOF. + */ + static void stylecsssc__init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + stylecsssc__flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then stylecsssc__init_buffer was _probably_ + * called from stylecsssc_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void stylecsssc__flush_buffer (YY_BUFFER_STATE b ) +{ + 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 ) + stylecsssc__load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void stylecsssc_push_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + stylecsssc_ensure_buffer_stack(); + + /* This block is copied from stylecsssc__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from stylecsssc__switch_to_buffer. */ + stylecsssc__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void stylecsssc_pop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + stylecsssc__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + stylecsssc__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void stylecsssc_ensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)stylecsssc_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in stylecsssc_ensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)stylecsssc_realloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in stylecsssc_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE stylecsssc__scan_buffer (char * base, yy_size_t size ) +{ + 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) stylecsssc_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in stylecsssc__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; + + stylecsssc__switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to stylecsssc_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * stylecsssc__scan_bytes() instead. + */ +YY_BUFFER_STATE stylecsssc__scan_string (yyconst char * yystr ) +{ + + return stylecsssc__scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to stylecsssc_lex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE stylecsssc__scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) stylecsssc_alloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in stylecsssc__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = stylecsssc__scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in stylecsssc__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; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (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 stylecsssc_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + stylecsssc_text[stylecsssc_leng] = (yy_hold_char); \ + (yy_c_buf_p) = stylecsssc_text + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '0円'; \ + stylecsssc_leng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int stylecsssc_get_lineno (void) +{ + + return stylecsssc_lineno; +} + +/** Get the input stream. + * + */ +FILE *stylecsssc_get_in (void) +{ + return stylecsssc_in; +} + +/** Get the output stream. + * + */ +FILE *stylecsssc_get_out (void) +{ + return stylecsssc_out; +} + +/** Get the length of the current token. + * + */ +int stylecsssc_get_leng (void) +{ + return stylecsssc_leng; +} + +/** Get the current token. + * + */ + +char *stylecsssc_get_text (void) +{ + return stylecsssc_text; +} + +/** Set the current line number. + * @param line_number + * + */ +void stylecsssc_set_lineno (int line_number ) +{ + + stylecsssc_lineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see stylecsssc__switch_to_buffer + */ +void stylecsssc_set_in (FILE * in_str ) +{ + stylecsssc_in = in_str ; +} + +void stylecsssc_set_out (FILE * out_str ) +{ + stylecsssc_out = out_str ; +} + +int stylecsssc_get_debug (void) +{ + return stylecsssc__flex_debug; +} + +void stylecsssc_set_debug (int bdebug ) +{ + stylecsssc__flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from stylecsssc_lex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + stylecsssc_in = stdin; + stylecsssc_out = stdout; +#else + stylecsssc_in = (FILE *) 0; + stylecsssc_out = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * stylecsssc_lex_init() + */ + return 0; +} + +/* stylecsssc_lex_destroy is for both reentrant and non-reentrant scanners. */ +int stylecsssc_lex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + stylecsssc__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + stylecsssc_pop_buffer_state(); + } + + /* Destroy the stack itself. */ + stylecsssc_free((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * stylecsssc_lex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *stylecsssc_alloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *stylecsssc_realloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void stylecsssc_free (void * ptr ) +{ + free( (char *) ptr ); /* see stylecsssc_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 212 "../../../lib/srchilite/stylecssscanner.ll" + + + + diff --git a/lib/srchilite/styleparser.cc b/lib/srchilite/styleparser.cc new file mode 100644 index 0000000..5f920e4 --- /dev/null +++ b/lib/srchilite/styleparser.cc @@ -0,0 +1,1923 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by 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 + +/* Bison version. */ +#define YYBISON_VERSION "2.3" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse stylesc_parse +#define yylex stylesc_lex +#define yyerror stylesc_error +#define yylval stylesc_lval +#define yychar stylesc_char +#define yydebug stylesc_debug +#define yynerrs stylesc_nerrs + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BOLD = 258, + ITALICS = 259, + UNDERLINE = 260, + FIXED = 261, + NOTFIXED = 262, + NOREF = 263, + KEY = 264, + COLOR = 265, + BG_COLOR = 266, + STRINGDEF = 267, + BG_T = 268, + BODY_BG_COLOR = 269 + }; +#endif +/* Tokens. */ +#define BOLD 258 +#define ITALICS 259 +#define UNDERLINE 260 +#define FIXED 261 +#define NOTFIXED 262 +#define NOREF 263 +#define KEY 264 +#define COLOR 265 +#define BG_COLOR 266 +#define STRINGDEF 267 +#define BG_T 268 +#define BODY_BG_COLOR 269 + + + + +/* Copy the first part of user declarations. */ +#line 1 "../../../lib/srchilite/styleparser.yy" + +/* + * Copyright (C) 1999-2007 Lorenzo Bettini <http://www.lorenzobettini.it> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <iostream> +#include <string> + +#include "formatterfactory.h" +#include "colors.h" +#include "keys.h" +#include "parsestyles.h" +#include "fileutil.h" +#include "stylekey.h" +#include "parserexception.h" +#include "settings.h" + +using std::cerr; +using std::string; + +using namespace srchilite; + +static int yyparse() ; +static void yyerror( const char *s ) ; +static void yyerror( const string &s ) ; + +int line = 1 ; + +extern int stylesc_lex() ; +extern FILE *stylesc_in ; +extern int stylesc_lex_destroy (void); + +static string bodyBgColor; + +static void updateBgColor(const std::string *); + +// to generate the formatter for each language element +static FormatterFactory *formatterFactory; + +/// where we store possible errors +static string errorBuffer; + + + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 62 "../../../lib/srchilite/styleparser.yy" +{ + int tok ; /* command */ + const std::string * string ; /* string : id, ... */ + srchilite::StyleConstant flag ; + srchilite::StyleConstants *styleconstants; + srchilite::KeyList *keylist; +} +/* Line 187 of yacc.c. */ +#line 201 "styleparser.cc" + 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 216 of yacc.c. */ +#line 214 "styleparser.cc" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# 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 +{ + yytype_int16 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 (yytype_int16) + 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 \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (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 (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 11 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 24 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 18 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 13 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 29 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 38 + +/* 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 yytype_uint8 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, 16, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 17, 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 yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 6, 9, 11, 13, 15, 16, + 23, 27, 29, 30, 32, 34, 35, 39, 43, 47, + 51, 52, 54, 58, 60, 62, 64, 66, 68, 70 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 19, 0, -1, -1, 20, -1, 20, 21, -1, 21, + -1, 22, -1, 27, -1, -1, 24, 25, 26, 23, + 28, 15, -1, 24, 16, 9, -1, 9, -1, -1, + 10, -1, 12, -1, -1, 13, 17, 10, -1, 13, + 17, 12, -1, 14, 10, 15, -1, 14, 12, 15, + -1, -1, 29, -1, 29, 16, 30, -1, 30, -1, + 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, + 8, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 86, 86, 87, 90, 91, 94, 95, 99, 98, + 134, 140, 148, 149, 150, 153, 154, 155, 158, 159, + 162, 163, 166, 167, 170, 171, 172, 173, 174, 175 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[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", "BOLD", "ITALICS", "UNDERLINE", "FIXED", + "NOTFIXED", "NOREF", "KEY", "COLOR", "BG_COLOR", "STRINGDEF", "BG_T", + "BODY_BG_COLOR", "';'", "','", "':'", "$accept", "stylefile", + "statements", "statement", "option", "@1", "keylist", "color", "bgcolor", + "bodybgcolor", "stylevalues", "values", "value", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 59, 44, 58 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 18, 19, 19, 20, 20, 21, 21, 23, 22, + 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, + 28, 28, 29, 29, 30, 30, 30, 30, 30, 30 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 2, 1, 1, 1, 0, 6, + 3, 1, 0, 1, 1, 0, 3, 3, 3, 3, + 0, 1, 3, 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 yytype_uint8 yydefact[] = +{ + 2, 11, 0, 0, 3, 5, 6, 12, 7, 0, + 0, 1, 4, 13, 14, 0, 15, 18, 19, 10, + 0, 8, 0, 20, 16, 17, 24, 25, 26, 27, + 28, 29, 0, 21, 23, 9, 0, 22 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 3, 4, 5, 6, 23, 7, 16, 21, 8, + 32, 33, 34 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -14 +static const yytype_int8 yypact[] = +{ + 5, -14, -9, 16, 5, -14, -14, -10, -14, -11, + 2, -14, -14, -14, -14, -4, 7, -14, -14, -14, + 1, -14, 3, 4, -14, -14, -14, -14, -14, -14, + -14, -14, 6, 8, -14, -14, 4, -14 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -14, -14, -14, 18, -14, -14, -14, -14, -14, -14, + -14, -14, -13 +}; + +/* 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 yytype_uint8 yytable[] = +{ + 13, 9, 14, 10, 17, 19, 15, 26, 27, 28, + 29, 30, 31, 24, 1, 25, 11, 18, 22, 2, + 20, 35, 12, 37, 36 +}; + +static const yytype_uint8 yycheck[] = +{ + 10, 10, 12, 12, 15, 9, 16, 3, 4, 5, + 6, 7, 8, 10, 9, 12, 0, 15, 17, 14, + 13, 15, 4, 36, 16 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 9, 14, 19, 20, 21, 22, 24, 27, 10, + 12, 0, 21, 10, 12, 16, 25, 15, 15, 9, + 13, 26, 17, 23, 10, 12, 3, 4, 5, 6, + 7, 8, 28, 29, 30, 15, 16, 30 +}; + +#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 (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +#else +static void +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; 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 (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, 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 + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# 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. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '0円') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '0円'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '0円'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '0円') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + case 9: /* "KEY" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1126 "styleparser.cc" + break; + case 10: /* "COLOR" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1134 "styleparser.cc" + break; + case 11: /* "BG_COLOR" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1142 "styleparser.cc" + break; + case 12: /* "STRINGDEF" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1150 "styleparser.cc" + break; + case 24: /* "keylist" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->keylist)) + delete (yyvaluep->keylist); +}; +#line 1158 "styleparser.cc" + break; + case 25: /* "color" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1166 "styleparser.cc" + break; + case 26: /* "bgcolor" */ +#line 79 "../../../lib/srchilite/styleparser.yy" + { + if ((yyvaluep->string)) + delete (yyvaluep->string); +}; +#line 1174 "styleparser.cc" + break; + + 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 */ + + + +/* The look-ahead symbol. */ +int yychar; + +/* The semantic value of the look-ahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + + int yystate; + int yyn; + int yyresult; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + + /* 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. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + 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; + yytype_int16 *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 (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + 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 + look-ahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to look-ahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a look-ahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead 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); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + if (yyn == YYFINAL) + YYACCEPT; + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the look-ahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + 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 86 "../../../lib/srchilite/styleparser.yy" + { /* allow empty files */ } + break; + + case 8: +#line 99 "../../../lib/srchilite/styleparser.yy" + { + //printSequence( 1ドル ) ; + //printMessage_noln( ": " ) ; + //printMessage_noln( (2ドル ? *2ドル : "") ) ; + //printMessage_noln( " bg: " ) ; + //printMessage_noln( (3ドル ? *3ドル : "") ) ; + } + break; + + case 9: +#line 107 "../../../lib/srchilite/styleparser.yy" + { + KeyType key; + KeyList *keylist = (yyvsp[(1) - (6)].keylist); + StyleConstantsPtr stylevalues = StyleConstantsPtr((yyvsp[(5) - (6)].styleconstants)); + for (KeyList::const_iterator it = keylist->begin(); it != keylist->end(); ++it) { + key = *it; + if (!formatterFactory->createFormatter(key, ((yyvsp[(2) - (6)].string) ? *(yyvsp[(2) - (6)].string) : ""), ((yyvsp[(3) - (6)].string) ? *(yyvsp[(3) - (6)].string) : ""), stylevalues)) { + errorBuffer = "already defined " + *it; + //yyerror(alreadydef); + + delete keylist; + if ((yyvsp[(2) - (6)].string)) + delete (yyvsp[(2) - (6)].string); + if ((yyvsp[(3) - (6)].string)) + delete (yyvsp[(3) - (6)].string); + + YYERROR; + } + } + delete keylist; + if ((yyvsp[(2) - (6)].string)) + delete (yyvsp[(2) - (6)].string); + if ((yyvsp[(3) - (6)].string)) + delete (yyvsp[(3) - (6)].string); + } + break; + + case 10: +#line 135 "../../../lib/srchilite/styleparser.yy" + { + (yyvsp[(1) - (3)].keylist)->push_back(*(yyvsp[(3) - (3)].string)); + (yyval.keylist) = (yyvsp[(1) - (3)].keylist); + delete (yyvsp[(3) - (3)].string); + } + break; + + case 11: +#line 141 "../../../lib/srchilite/styleparser.yy" + { + (yyval.keylist) = new KeyList; + (yyval.keylist)->push_back(*(yyvsp[(1) - (1)].string)); + delete (yyvsp[(1) - (1)].string); + } + break; + + case 12: +#line 148 "../../../lib/srchilite/styleparser.yy" + { (yyval.string) = 0; } + break; + + case 13: +#line 149 "../../../lib/srchilite/styleparser.yy" + { (yyval.string) = (yyvsp[(1) - (1)].string);} + break; + + case 14: +#line 150 "../../../lib/srchilite/styleparser.yy" + { (yyval.string) = (yyvsp[(1) - (1)].string); } + break; + + case 15: +#line 153 "../../../lib/srchilite/styleparser.yy" + { (yyval.string) = 0; } + break; + + case 16: +#line 154 "../../../lib/srchilite/styleparser.yy" + { (yyval.string) = (yyvsp[(3) - (3)].string);} + break; + + case 17: +#line 155 "../../../lib/srchilite/styleparser.yy" + { (yyval.string) = (yyvsp[(3) - (3)].string); } + break; + + case 18: +#line 158 "../../../lib/srchilite/styleparser.yy" + { updateBgColor((yyvsp[(2) - (3)].string)); } + break; + + case 19: +#line 159 "../../../lib/srchilite/styleparser.yy" + { updateBgColor((yyvsp[(2) - (3)].string)); } + break; + + case 20: +#line 162 "../../../lib/srchilite/styleparser.yy" + { (yyval.styleconstants) = 0 ; } + break; + + case 21: +#line 163 "../../../lib/srchilite/styleparser.yy" + { (yyval.styleconstants) = (yyvsp[(1) - (1)].styleconstants); } + break; + + case 22: +#line 166 "../../../lib/srchilite/styleparser.yy" + { (yyval.styleconstants) = (yyvsp[(1) - (3)].styleconstants); (yyval.styleconstants)->push_back((yyvsp[(3) - (3)].flag)) ; } + break; + + case 23: +#line 167 "../../../lib/srchilite/styleparser.yy" + { (yyval.styleconstants) = new StyleConstants; (yyval.styleconstants)->push_back((yyvsp[(1) - (1)].flag)); } + break; + + case 24: +#line 170 "../../../lib/srchilite/styleparser.yy" + { (yyval.flag) = ISBOLD ; } + break; + + case 25: +#line 171 "../../../lib/srchilite/styleparser.yy" + { (yyval.flag) = ISITALIC ; } + break; + + case 26: +#line 172 "../../../lib/srchilite/styleparser.yy" + { (yyval.flag) = ISUNDERLINE ; } + break; + + case 27: +#line 173 "../../../lib/srchilite/styleparser.yy" + { (yyval.flag) = ISFIXED ; } + break; + + case 28: +#line 174 "../../../lib/srchilite/styleparser.yy" + { (yyval.flag) = ISNOTFIXED ; } + break; + + case 29: +#line 175 "../../../lib/srchilite/styleparser.yy" + { (yyval.flag) = ISNOREF ; } + break; + + +/* Line 1267 of yacc.c. */ +#line 1637 "styleparser.cc" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + 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 + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse look-ahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse look-ahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + 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; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + if (yyn == YYFINAL) + YYACCEPT; + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#ifndef yyoverflow +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + +#line 178 "../../../lib/srchilite/styleparser.yy" + + +string current_file; + +namespace srchilite { + +void +parseStyles(const string &name, FormatterFactory *genFactory, + string &bodyBgColor_) { + parseStyles(Settings::retrieveDataDir(), name, genFactory, bodyBgColor_); +} + +void +parseStyles(const string &path, const string &name, FormatterFactory *genFactory, + string &bodyBgColor_) +{ + formatterFactory = genFactory; + errorBuffer = ""; + int result = 1; + line = 1; + + // opens the file for yylex + stylesc_in = open_data_file_stream(path, name); + + if (contains_path(name)) + current_file = name; + else + current_file = (path.size() ? path + "/" : "") + name; + + bodyBgColor = ""; + + result = yyparse() ; + + bodyBgColor_ = bodyBgColor; + + fclose(stylesc_in); + + // free scanner memory + stylesc_lex_destroy(); + + if (result != 0 || errorBuffer.size()) { + throw ParserException(errorBuffer, current_file, line); + } +} + +} + +void +yyerror( const char *s ) +{ + errorBuffer = s; +} + +void yyerror(const string &s) { + yyerror(s.c_str()); +} + +void parseStyleError(const std::string &error) +{ + yyerror(error); +} + +void updateBgColor(const std::string *c) +{ + if (bodyBgColor != "") + yyerror("bgcolor already defined"); + else + bodyBgColor = *c; + + // we don't need it anymore + delete c; +} + diff --git a/lib/srchilite/styleparser.h b/lib/srchilite/styleparser.h new file mode 100644 index 0000000..8094eef --- /dev/null +++ b/lib/srchilite/styleparser.h @@ -0,0 +1,92 @@ +/* A Bison parser, made by GNU Bison 2.3. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + BOLD = 258, + ITALICS = 259, + UNDERLINE = 260, + FIXED = 261, + NOTFIXED = 262, + NOREF = 263, + KEY = 264, + COLOR = 265, + BG_COLOR = 266, + STRINGDEF = 267, + BG_T = 268, + BODY_BG_COLOR = 269 + }; +#endif +/* Tokens. */ +#define BOLD 258 +#define ITALICS 259 +#define UNDERLINE 260 +#define FIXED 261 +#define NOTFIXED 262 +#define NOREF 263 +#define KEY 264 +#define COLOR 265 +#define BG_COLOR 266 +#define STRINGDEF 267 +#define BG_T 268 +#define BODY_BG_COLOR 269 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 62 "../../../lib/srchilite/styleparser.yy" +{ + int tok ; /* command */ + const std::string * string ; /* string : id, ... */ + srchilite::StyleConstant flag ; + srchilite::StyleConstants *styleconstants; + srchilite::KeyList *keylist; +} +/* Line 1489 of yacc.c. */ +#line 85 "styleparser.h" + YYSTYPE; +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 +#endif + +extern YYSTYPE stylesc_lval; + diff --git a/lib/srchilite/stylescanner.cc b/lib/srchilite/stylescanner.cc new file mode 100644 index 0000000..551a3d2 --- /dev/null +++ b/lib/srchilite/stylescanner.cc @@ -0,0 +1,2040 @@ +#line 2 "stylescanner.cc" + +#line 4 "stylescanner.cc" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer stylesc__create_buffer +#define yy_delete_buffer stylesc__delete_buffer +#define yy_flex_debug stylesc__flex_debug +#define yy_init_buffer stylesc__init_buffer +#define yy_flush_buffer stylesc__flush_buffer +#define yy_load_buffer_state stylesc__load_buffer_state +#define yy_switch_to_buffer stylesc__switch_to_buffer +#define yyin stylesc_in +#define yyleng stylesc_leng +#define yylex stylesc_lex +#define yylineno stylesc_lineno +#define yyout stylesc_out +#define yyrestart stylesc_restart +#define yytext stylesc_text +#define yywrap stylesc_wrap +#define yyalloc stylesc_alloc +#define yyrealloc stylesc_realloc +#define yyfree stylesc_free + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* 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 stylesc_restart(stylesc_in ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int stylesc_leng; + +extern FILE *stylesc_in, *stylesc_out; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up stylesc_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up stylesc_text again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + 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; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via stylesc_restart()), so that the user can continue scanning by + * just pointing stylesc_in at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when stylesc_text is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int stylesc_leng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow stylesc_wrap()'s to do buffer switches + * instead of setting up a fresh stylesc_in. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void stylesc_restart (FILE *input_file ); +void stylesc__switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE stylesc__create_buffer (FILE *file,int size ); +void stylesc__delete_buffer (YY_BUFFER_STATE b ); +void stylesc__flush_buffer (YY_BUFFER_STATE b ); +void stylesc_push_buffer_state (YY_BUFFER_STATE new_buffer ); +void stylesc_pop_buffer_state (void ); + +static void stylesc_ensure_buffer_stack (void ); +static void stylesc__load_buffer_state (void ); +static void stylesc__init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER stylesc__flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE stylesc__scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE stylesc__scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE stylesc__scan_bytes (yyconst char *bytes,int len ); + +void *stylesc_alloc (yy_size_t ); +void *stylesc_realloc (void *,yy_size_t ); +void stylesc_free (void * ); + +#define yy_new_buffer stylesc__create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + stylesc_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + stylesc__create_buffer(stylesc_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + stylesc_ensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + stylesc__create_buffer(stylesc_in,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +#define stylesc_wrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +FILE *stylesc_in = (FILE *) 0, *stylesc_out = (FILE *) 0; + +typedef int yy_state_type; + +extern int stylesc_lineno; + +int stylesc_lineno = 1; + +extern char *stylesc_text; +#define yytext_ptr stylesc_text + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up stylesc_text. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + stylesc_leng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '0円'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 27 +#define YY_END_OF_BUFFER 28 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[122] = + { 0, + 0, 0, 0, 0, 0, 0, 28, 26, 1, 25, + 2, 1, 19, 15, 26, 17, 16, 18, 9, 18, + 18, 12, 18, 10, 18, 18, 18, 18, 18, 11, + 18, 18, 4, 1, 5, 2, 1, 23, 1, 24, + 2, 1, 22, 23, 1, 1, 3, 18, 8, 18, + 18, 18, 18, 18, 13, 18, 18, 18, 18, 18, + 18, 18, 18, 21, 20, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 6, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 14, 18, + + 18, 18, 18, 18, 18, 18, 18, 7, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, + 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 1, 6, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 7, 1, 1, 8, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 10, 11, 1, + 1, 1, 1, 1, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 1, 13, 1, 1, 12, 1, 14, 15, 16, 17, + + 18, 19, 20, 21, 22, 12, 23, 24, 12, 25, + 26, 27, 12, 28, 12, 29, 30, 12, 31, 12, + 32, 12, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[33] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, + 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2 + } ; + +static yyconst flex_int16_t yy_base[125] = + { 0, + 0, 0, 31, 35, 39, 51, 156, 157, 153, 157, + 157, 149, 157, 157, 145, 157, 157, 0, 38, 120, + 137, 0, 122, 0, 41, 121, 29, 130, 129, 0, + 125, 127, 157, 142, 157, 157, 138, 157, 140, 157, + 157, 136, 157, 55, 138, 134, 157, 0, 122, 33, + 24, 123, 108, 51, 0, 107, 120, 108, 104, 114, + 116, 107, 104, 157, 157, 101, 110, 107, 104, 92, + 97, 98, 88, 101, 100, 92, 93, 88, 0, 90, + 84, 88, 87, 87, 88, 83, 55, 82, 87, 85, + 80, 85, 76, 75, 71, 75, 70, 79, 0, 78, + + 77, 63, 65, 51, 62, 73, 73, 0, 61, 60, + 64, 63, 62, 65, 53, 58, 49, 48, 52, 31, + 157, 83, 85, 46 + } ; + +static yyconst flex_int16_t yy_def[125] = + { 0, + 121, 1, 122, 122, 123, 123, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 121, 121, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, + 0, 121, 121, 121 + } ; + +static yyconst flex_int16_t yy_nxt[190] = + { 0, + 8, 9, 10, 11, 12, 13, 14, 15, 8, 16, + 17, 18, 8, 18, 19, 20, 21, 18, 22, 23, + 18, 24, 18, 18, 25, 26, 27, 28, 29, 30, + 31, 32, 34, 35, 36, 37, 34, 35, 36, 37, + 39, 40, 41, 42, 43, 69, 67, 48, 79, 70, + 58, 44, 39, 40, 41, 42, 43, 49, 59, 55, + 64, 50, 68, 44, 73, 51, 56, 65, 74, 96, + 109, 120, 79, 119, 97, 118, 110, 79, 117, 116, + 115, 79, 98, 33, 33, 38, 38, 114, 113, 79, + 112, 111, 108, 79, 79, 79, 107, 106, 105, 104, + + 103, 102, 79, 101, 100, 99, 79, 79, 95, 79, + 94, 93, 92, 79, 91, 79, 90, 89, 88, 79, + 87, 79, 86, 85, 79, 84, 83, 82, 81, 80, + 79, 78, 77, 76, 75, 72, 71, 66, 46, 45, + 46, 45, 46, 45, 63, 62, 61, 60, 57, 54, + 53, 52, 47, 46, 45, 121, 7, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121 + } ; + +static yyconst flex_int16_t yy_chk[190] = + { 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, 3, 3, 3, 3, 4, 4, 4, 4, + 5, 5, 5, 5, 5, 51, 50, 124, 120, 51, + 27, 5, 6, 6, 6, 6, 6, 19, 27, 25, + 44, 19, 50, 6, 54, 19, 25, 44, 54, 87, + 104, 119, 118, 117, 87, 116, 104, 115, 114, 113, + 112, 111, 87, 122, 122, 123, 123, 110, 109, 107, + 106, 105, 103, 102, 101, 100, 98, 97, 96, 95, + + 94, 93, 92, 91, 90, 89, 88, 86, 85, 84, + 83, 82, 81, 80, 78, 77, 76, 75, 74, 73, + 72, 71, 70, 69, 68, 67, 66, 63, 62, 61, + 60, 59, 58, 57, 56, 53, 52, 49, 46, 45, + 42, 39, 37, 34, 32, 31, 29, 28, 26, 23, + 21, 20, 15, 12, 9, 7, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, + 121, 121, 121, 121, 121, 121, 121, 121, 121 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int stylesc__flex_debug; +int stylesc__flex_debug = 0; + +/* 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 *stylesc_text; +#line 1 "../../../lib/srchilite/stylescanner.ll" +#line 2 "../../../lib/srchilite/stylescanner.ll" +/* + * Copyright (C) 1999-2007 Lorenzo Bettini, http://www.lorenzobettini.it + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include <stdlib.h> + +#include "stylekey.h" + +#include "formatterfactory.h" +#include "styleparser.h" +#include <sstream> +#include "parsestyles.h" + +using namespace srchilite; + +static std::ostringstream buff; + +extern int line ; + +//#define DEBUG_SCANNER +#ifdef DEBUG_SCANNER +#include <iostream> // for debug +#define DEB(s) std::cerr << s << std::endl; +#define DEB2(s,s2) std::cerr << s << ": " << s2 << std::endl; +#else +#define DEB(s) +#define DEB2(s,s2) +#endif + + +static void buffer(const char *s); +static const std::string *flush_buffer(); + + +#line 611 "stylescanner.cc" + +#define INITIAL 0 +#define COMMENT_STATE 1 +#define STRING_STATE 2 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int stylesc_lex_destroy (void ); + +int stylesc_get_debug (void ); + +void stylesc_set_debug (int debug_flag ); + +YY_EXTRA_TYPE stylesc_get_extra (void ); + +void stylesc_set_extra (YY_EXTRA_TYPE user_defined ); + +FILE *stylesc_get_in (void ); + +void stylesc_set_in (FILE * in_str ); + +FILE *stylesc_get_out (void ); + +void stylesc_set_out (FILE * out_str ); + +int stylesc_get_leng (void ); + +char *stylesc_get_text (void ); + +int stylesc_get_lineno (void ); + +void stylesc_set_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int stylesc_wrap (void ); +#else +extern int stylesc_wrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#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 do { if (fwrite( stylesc_text, stylesc_leng, 1, stylesc_out )) {} } while (0) +#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_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( stylesc_in )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( stylesc_in ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, stylesc_in))==0 && ferror(stylesc_in)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(stylesc_in); \ + } \ + }\ +\ + +#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 + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int stylesc_lex (void); + +#define YY_DECL int stylesc_lex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after stylesc_text and stylesc_leng + * 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 + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 66 "../../../lib/srchilite/stylescanner.ll" + + +#line 803 "stylescanner.cc" + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! stylesc_in ) + stylesc_in = stdin; + + if ( ! stylesc_out ) + stylesc_out = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + stylesc_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + stylesc__create_buffer(stylesc_in,YY_BUF_SIZE ); + } + + stylesc__load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of stylesc_text. */ + *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 >= 122 ) + 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] != 157 ); + +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 68 "../../../lib/srchilite/stylescanner.ll" +{} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 70 "../../../lib/srchilite/stylescanner.ll" +{} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 72 "../../../lib/srchilite/stylescanner.ll" +{ BEGIN(COMMENT_STATE); } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 73 "../../../lib/srchilite/stylescanner.ll" +{} + YY_BREAK +case 5: +/* rule 5 can match eol */ +YY_RULE_SETUP +#line 74 "../../../lib/srchilite/stylescanner.ll" +{ ++line; BEGIN(INITIAL); } + YY_BREAK +case 6: +YY_RULE_SETUP +#line 76 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.string = new std::string(stylesc_text) ; return COLOR ; } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 78 "../../../lib/srchilite/stylescanner.ll" +{ return BODY_BG_COLOR ; } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 80 "../../../lib/srchilite/stylescanner.ll" +{ return BG_T ; } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 82 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.flag = ISBOLD ; return BOLD ; } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 83 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.flag = ISITALIC ; return ITALICS ; } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 84 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.flag = ISUNDERLINE ; return UNDERLINE ; } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 85 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.flag = ISFIXED; return FIXED; } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 86 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.flag = ISNOTFIXED; return NOTFIXED; } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 87 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.flag = ISNOREF; return NOREF; } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 89 "../../../lib/srchilite/stylescanner.ll" +{ return ',' ; } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 90 "../../../lib/srchilite/stylescanner.ll" +{ return ';' ; } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 91 "../../../lib/srchilite/stylescanner.ll" +{ return ':' ; } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 93 "../../../lib/srchilite/stylescanner.ll" +{ stylesc_lval.string = new std::string(stylesc_text) ; return KEY ; } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 95 "../../../lib/srchilite/stylescanner.ll" +{ BEGIN(STRING_STATE); DEB("STRING_STATE"); buffer( stylesc_text ) ; } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 96 "../../../lib/srchilite/stylescanner.ll" +{ buffer( stylesc_text ) ; } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 97 "../../../lib/srchilite/stylescanner.ll" +{ buffer( "\"" ) ; } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 98 "../../../lib/srchilite/stylescanner.ll" +{ BEGIN(INITIAL) ; buffer( stylesc_text ) ; DEB("END STRING_STATE"); stylesc_lval.string = flush_buffer() ; return STRINGDEF; } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 99 "../../../lib/srchilite/stylescanner.ll" +{ buffer( stylesc_text ) ; } + YY_BREAK +case 24: +/* rule 24 can match eol */ +YY_RULE_SETUP +#line 100 "../../../lib/srchilite/stylescanner.ll" +{ buffer( "\n" ) ; } + YY_BREAK +case 25: +/* rule 25 can match eol */ +YY_RULE_SETUP +#line 102 "../../../lib/srchilite/stylescanner.ll" +{ ++line ; } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 104 "../../../lib/srchilite/stylescanner.ll" +{ /* anything else will generate a parsing error */ return stylesc_text[0] ; } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 106 "../../../lib/srchilite/stylescanner.ll" +ECHO; + YY_BREAK +#line 1024 "stylescanner.cc" +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(COMMENT_STATE): +case YY_STATE_EOF(STRING_STATE): + 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_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed stylesc_in at a new source and called + * stylesc_lex(). 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_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = stylesc_in; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->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 ( stylesc_wrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * stylesc_text, 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_LVALUE->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 stylesc_lex */ + +/* 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 (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (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_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((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. */ + stylesc_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_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->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; + stylesc_restart(stylesc_in ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) stylesc_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + 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 >= 122 ) + 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 ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + 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 >= 122 ) + 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 == 121); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up stylesc_text */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->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; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#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_LVALUE->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. */ + stylesc_restart(stylesc_in ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( stylesc_wrap( ) ) + 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 stylesc_text */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void stylesc_restart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + stylesc_ensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + stylesc__create_buffer(stylesc_in,YY_BUF_SIZE ); + } + + stylesc__init_buffer(YY_CURRENT_BUFFER,input_file ); + stylesc__load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void stylesc__switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * stylesc_pop_buffer_state(); + * stylesc_push_buffer_state(new_buffer); + */ + stylesc_ensure_buffer_stack (); + 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_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + stylesc__load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (stylesc_wrap()) processing, but the only time this flag + * is looked at is after stylesc_wrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void stylesc__load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + stylesc_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE stylesc__create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) stylesc_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in stylesc__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 *) stylesc_alloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in stylesc__create_buffer()" ); + + b->yy_is_our_buffer = 1; + + stylesc__init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with stylesc__create_buffer() + * + */ + void stylesc__delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + stylesc_free((void *) b->yy_ch_buf ); + + stylesc_free((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a stylesc_restart() or at EOF. + */ + static void stylesc__init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + stylesc__flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then stylesc__init_buffer was _probably_ + * called from stylesc_restart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void stylesc__flush_buffer (YY_BUFFER_STATE b ) +{ + 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 ) + stylesc__load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void stylesc_push_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + stylesc_ensure_buffer_stack(); + + /* This block is copied from stylesc__switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from stylesc__switch_to_buffer. */ + stylesc__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void stylesc_pop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + stylesc__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + stylesc__load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void stylesc_ensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)stylesc_alloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in stylesc_ensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)stylesc_realloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in stylesc_ensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE stylesc__scan_buffer (char * base, yy_size_t size ) +{ + 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) stylesc_alloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in stylesc__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; + + stylesc__switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to stylesc_lex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * stylesc__scan_bytes() instead. + */ +YY_BUFFER_STATE stylesc__scan_string (yyconst char * yystr ) +{ + + return stylesc__scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to stylesc_lex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE stylesc__scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) stylesc_alloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in stylesc__scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = stylesc__scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in stylesc__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; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (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 stylesc_text. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + stylesc_text[stylesc_leng] = (yy_hold_char); \ + (yy_c_buf_p) = stylesc_text + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '0円'; \ + stylesc_leng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int stylesc_get_lineno (void) +{ + + return stylesc_lineno; +} + +/** Get the input stream. + * + */ +FILE *stylesc_get_in (void) +{ + return stylesc_in; +} + +/** Get the output stream. + * + */ +FILE *stylesc_get_out (void) +{ + return stylesc_out; +} + +/** Get the length of the current token. + * + */ +int stylesc_get_leng (void) +{ + return stylesc_leng; +} + +/** Get the current token. + * + */ + +char *stylesc_get_text (void) +{ + return stylesc_text; +} + +/** Set the current line number. + * @param line_number + * + */ +void stylesc_set_lineno (int line_number ) +{ + + stylesc_lineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see stylesc__switch_to_buffer + */ +void stylesc_set_in (FILE * in_str ) +{ + stylesc_in = in_str ; +} + +void stylesc_set_out (FILE * out_str ) +{ + stylesc_out = out_str ; +} + +int stylesc_get_debug (void) +{ + return stylesc__flex_debug; +} + +void stylesc_set_debug (int bdebug ) +{ + stylesc__flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from stylesc_lex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + stylesc_in = stdin; + stylesc_out = stdout; +#else + stylesc_in = (FILE *) 0; + stylesc_out = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * stylesc_lex_init() + */ + return 0; +} + +/* stylesc_lex_destroy is for both reentrant and non-reentrant scanners. */ +int stylesc_lex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + stylesc__delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + stylesc_pop_buffer_state(); + } + + /* Destroy the stack itself. */ + stylesc_free((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * stylesc_lex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *stylesc_alloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *stylesc_realloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void stylesc_free (void * ptr ) +{ + free( (char *) ptr ); /* see stylesc_realloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 106 "../../../lib/srchilite/stylescanner.ll" + + + +void buffer(const char *s) +{ + DEB2("BUFFERING ", s); + buff << s; +} + +const std::string *flush_buffer() +{ + const std::string *ret = new std::string(buff.str()); + buff.str(""); + return ret; +} + + |