📄 parser.cpp
字号:
/* A Bison parser, made from parser.y
by GNU Bison version 1.28 */
#define YYBISON 1 /* Identify Bison output. */
#define yyparse cssyyparse
#define yylex cssyylex
#define yyerror cssyyerror
#define yylval cssyylval
#define yychar cssyychar
#define yydebug cssyydebug
#define yynerrs cssyynerrs
#define WHITESPACE 257
#define SGML_CD 258
#define INCLUDES 259
#define DASHMATCH 260
#define BEGINSWITH 261
#define ENDSWITH 262
#define CONTAINS 263
#define STRING 264
#define IDENT 265
#define HASH 266
#define IMPORT_SYM 267
#define PAGE_SYM 268
#define MEDIA_SYM 269
#define FONT_FACE_SYM 270
#define CHARSET_SYM 271
#define NAMESPACE_SYM 272
#define KHTML_RULE_SYM 273
#define KHTML_DECLS_SYM 274
#define KHTML_VALUE_SYM 275
#define IMPORTANT_SYM 276
#define QEMS 277
#define EMS 278
#define EXS 279
#define PXS 280
#define CMS 281
#define MMS 282
#define INS 283
#define PTS 284
#define PCS 285
#define DEGS 286
#define RADS 287
#define GRADS 288
#define MSECS 289
#define SECS 290
#define HERZ 291
#define KHERZ 292
#define DIMEN 293
#define PERCENTAGE 294
#define NUMBER 295
#define URI 296
#define FUNCTION 297
#define UNICODERANGE 298
#line 1 "parser.y"
/*
* This file is part of the KDE libraries
* Copyright (C) 2002-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <string.h>
#include <stdlib.h>
#include <dom/dom_string.h>
#include <xml/dom_docimpl.h>
#include <css/css_ruleimpl.h>
#include <css/css_stylesheetimpl.h>
#include <css/css_valueimpl.h>
#include <misc/htmlhashes.h>
#include "cssparser.h"
#include "xml_namespace_table.h"
#include <assert.h>
#include <kdebug.h>
// #define CSS_DEBUG
using namespace DOM;
//
// The following file defines the function
// const struct props *findProp(const char *word, int len)
//
// with 'props->id' a CSS property in the range from CSS_PROP_MIN to
// (and including) CSS_PROP_TOTAL-1
// turn off inlining to void warning with newer gcc
#undef __inline
#define __inline
#include "cssproperties.c"
#include "cssvalues.c"
#undef __inline
#ifdef __OOM__
#include <allocs.h>
#endif
int DOM::getPropertyID(const char *tagStr, int len)
{
const struct props *propsPtr = findProp(tagStr, len);
if (!propsPtr)
return 0;
return propsPtr->id;
}
static inline int getValueID(const char *tagStr, int len)
{
const struct css_value *val = findValue(tagStr, len);
if (!val)
return 0;
return val->id;
}
#define YYDEBUG 0
#define YYMAXDEPTH 0
#define YYPARSE_PARAM parser
#line 86 "parser.y"
typedef union {
CSSRuleImpl *rule;
CSSSelector *selector;
bool ok;
MediaListImpl *mediaList;
CSSMediaRuleImpl *mediaRule;
CSSRuleListImpl *ruleList;
ParseString string;
float val;
int prop_id;
int attribute;
int element;
CSSSelector::Relation relation;
bool b;
char tok;
Value value;
ValueList *valueList;
} YYSTYPE;
#line 105 "parser.y"
static inline int cssyyerror(const char *x ) {
#ifdef CSS_DEBUG
qDebug( x );
#else
Q_UNUSED( x );
#endif
return 1;
}
static int cssyylex( YYSTYPE *yylval ) {
return CSSParser::current()->lex( yylval );
}
#include <stdio.h>
#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif
#define YYFINAL 312
#define YYFLAG -32768
#define YYNTBASE 63
#define YYTRANSLATE(x) ((unsigned)(x) <= 298 ? yytranslate[x] : 117)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 61, 2, 2, 2, 2, 2,
59, 55, 52, 51, 54, 14, 60, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 13, 50, 2,
58, 53, 2, 62, 2, 2, 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, 57, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 48, 56, 49, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 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, 3, 4, 5, 6,
7, 8, 9, 10, 11, 12, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47
};
#if YYDEBUG != 0
static const short yyprhs[] = { 0,
0, 6, 9, 12, 15, 22, 28, 34, 35, 38,
39, 42, 45, 46, 52, 56, 60, 61, 65, 66,
70, 71, 75, 77, 79, 81, 83, 85, 87, 89,
96, 100, 104, 111, 115, 119, 120, 123, 125, 127,
128, 130, 131, 133, 138, 141, 149, 150, 154, 157,
161, 165, 169, 173, 176, 179, 180, 182, 184, 190,
192, 197, 200, 202, 206, 209, 210, 212, 214, 217,
221, 224, 229, 235, 240, 242, 244, 246, 249, 252,
254, 256, 258, 260, 263, 266, 271, 280, 287, 298,
300, 302, 304, 306, 308, 310, 312, 314, 317, 321,
328, 330, 333, 335, 339, 341, 345, 350, 354, 360,
365, 370, 377, 383, 386, 393, 395, 399, 402, 405,
406, 408, 412, 415, 418, 421, 422, 424, 427, 430,
433, 436, 440, 443, 446, 448, 451, 453, 456, 459,
462, 465, 468, 471, 474, 477, 480, 483, 486, 489,
492, 495, 498, 501, 504, 507, 513, 517, 520, 524,
528, 530, 533, 539, 543, 545
};
static const short yyrhs[] = { 69,
68, 70, 71, 72, 0, 64, 67, 0, 65, 67,
0, 66, 67, 0, 22, 48, 67, 87, 67, 49,
0, 23, 48, 67, 101, 49, 0, 24, 48, 67,
106, 49, 0, 0, 67, 3, 0, 0, 68, 4,
0, 68, 3, 0, 0, 20, 67, 10, 67, 50,
0, 20, 1, 115, 0, 20, 1, 50, 0, 0,
70, 74, 68, 0, 0, 71, 75, 68, 0, 0,
72, 73, 68, 0, 87, 0, 80, 0, 83, 0,
84, 0, 114, 0, 112, 0, 113, 0, 16, 67,
77, 67, 78, 50, 0, 16, 1, 115, 0, 16,
1, 50, 0, 21, 67, 76, 77, 67, 50, 0,
21, 1, 115, 0, 21, 1, 50, 0, 0, 11,
3, 0, 10, 0, 45, 0, 0, 79, 0, 0,
82, 0, 79, 51, 67, 82, 0, 79, 1, 0,
18, 67, 79, 48, 67, 81, 49, 0, 0, 81,
87, 67, 0, 11, 67, 0, 17, 1, 115, 0,
17, 1, 50, 0, 19, 1, 115, 0, 19, 1,
50, 0, 52, 67, 0, 53, 67, 0, 0, 54,
0, 52, 0, 88, 48, 67, 101, 49, 0, 89,
0, 88, 51, 67, 89, 0, 88, 1, 0, 91,
0, 89, 85, 91, 0, 89, 1, 0, 0, 55,
0, 11, 0, 92, 67, 0, 92, 93, 67, 0,
93, 67, 0, 90, 56, 92, 67, 0, 90, 56,
92, 93, 67, 0, 90, 56, 93, 67, 0, 11,
0, 55, 0, 94, 0, 93, 94, 0, 93, 1,
0, 12, 0, 95, 0, 97, 0, 100, 0, 14,
11, 0, 11, 67, 0, 15, 67, 96, 57, 0,
15, 67, 96, 98, 67, 99, 67, 57, 0, 15,
67, 90, 56, 96, 57, 0, 15, 67, 90, 56,
96, 98, 67, 99, 67, 57, 0, 58, 0, 5,
0, 6, 0, 7, 0, 8, 0, 9, 0, 11,
0, 10, 0, 13, 11, 0, 13, 13, 11, 0,
13, 46, 67, 91, 67, 59, 0, 103, 0, 102,
103, 0, 102, 0, 1, 116, 1, 0, 1, 0,
103, 50, 67, 0, 103, 116, 50, 67, 0, 1,
50, 67, 0, 1, 116, 1, 50, 67, 0, 102,
103, 50, 67, 0, 102, 1, 50, 67, 0, 102,
1, 116, 1, 50, 67, 0, 104, 13, 67, 106,
105, 0, 104, 1, 0, 104, 13, 67, 1, 106,
105, 0, 105, 0, 104, 13, 67, 0, 11, 67,
0, 25, 67, 0, 0, 108, 0, 106, 107, 108,
0, 106, 1, 0, 60, 67, 0, 51, 67, 0,
0, 109, 0, 86, 109, 0, 10, 67, 0, 11,
67, 0, 42, 67, 0, 86, 42, 67, 0, 45,
67, 0, 47, 67, 0, 111, 0, 61, 67, 0,
110, 0, 44, 67, 0, 43, 67, 0, 29, 67,
0, 30, 67, 0, 31, 67, 0, 32, 67, 0,
33, 67, 0, 34, 67, 0, 35, 67, 0, 36,
67, 0, 37, 67, 0, 38, 67, 0, 39, 67,
0, 40, 67, 0, 41, 67, 0, 27, 67, 0,
26, 67, 0, 28, 67, 0, 46, 67, 106, 59,
67, 0, 46, 67, 1, 0, 12, 67, 0, 62,
1, 115, 0, 62, 1, 50, 0, 74, 0, 1,
115, 0, 48, 1, 116, 1, 49, 0, 48, 1,
49, 0, 115, 0, 116, 1, 115, 0
};
#endif
#if YYDEBUG != 0
static const short yyrline[] = { 0,
237, 239, 240, 241, 244, 251, 257, 282, 284, 287,
289, 290, 293, 295, 300, 301, 304, 306, 316, 318,
321, 323, 333, 335, 336, 337, 338, 339, 340, 343,
356, 359, 364, 373, 374, 377, 379, 382, 384, 387,
391, 395, 399, 403, 408, 414, 428, 430, 439, 461,
465, 470, 474, 479, 481, 482, 485, 487, 490, 509,
521, 535, 541, 545, 574, 580, 582, 583, 586, 591,
596, 601, 608, 617, 628, 645, 650, 654, 664, 670,
680, 681, 682, 685, 697, 717, 723, 729, 737, 748,
752, 755, 758, 761, 764, 769, 771, 774, 788, 795,
804, 808, 813, 816, 822, 830, 834, 837, 843, 849,
854, 860, 868, 891, 895, 903, 908, 915, 922, 924,
927, 932, 945, 951, 955, 958, 963, 965, 966, 967,
974, 975, 976, 977, 978, 979, 981, 986, 988, 989,
990, 991, 992, 993, 994, 995, 996, 997, 998, 999,
1000, 1001, 1002, 1003, 1004, 1008, 1016, 1031, 1038, 1045,
1053, 1063, 1089, 1091, 1094, 1096
};
#endif
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
static const char * const yytname[] = { "$","error","$undefined.","WHITESPACE",
"SGML_CD","INCLUDES","DASHMATCH","BEGINSWITH","ENDSWITH","CONTAINS","STRING",
"IDENT","HASH","':'","'.'","'['","IMPORT_SYM","PAGE_SYM","MEDIA_SYM","FONT_FACE_SYM",
"CHARSET_SYM","NAMESPACE_SYM","KHTML_RULE_SYM","KHTML_DECLS_SYM","KHTML_VALUE_SYM",
"IMPORTANT_SYM","QEMS","EMS","EXS","PXS","CMS","MMS","INS","PTS","PCS","DEGS",
"RADS","GRADS","MSECS","SECS","HERZ","KHERZ","DIMEN","PERCENTAGE","NUMBER","URI",
"FUNCTION","UNICODERANGE","'{'","'}'","';'","','","'+'","'>'","'-'","'*'","'|'",
"']'","'='","')'","'/'","'#'","'@'","stylesheet","khtml_rule","khtml_decls",
"khtml_value","maybe_space","maybe_sgml","maybe_charset","import_list","namespace_list",
"rule_list","rule","import","namespace","maybe_ns_prefix","string_or_uri","maybe_media_list",
"media_list","media","ruleset_list","medium","page","font_face","combinator",
"unary_operator","ruleset","selector_list","selector","namespace_selector","simple_selector",
"element_name","specifier_list","specifier","class","attrib_id","attrib","match",
"ident_or_string","pseudo","declaration_list","decl_list","declaration","property",
"prio","expr","operator","term","unary_term","function","hexcolor","invalid_at",
"invalid_import","invalid_rule","invalid_block","invalid_block_list", NULL
};
#endif
static const short yyr1[] = { 0,
63, 63, 63, 63, 64, 65, 66, 67, 67, 68,
68, 68, 69, 69, 69, 69, 70, 70, 71, 71,
72, 72, 73, 73, 73, 73, 73, 73, 73, 74,
74, 74, 75, 75, 75, 76, 76, 77, 77, 78,
78, 79, 79, 79, 79, 80, 81, 81, 82, 83,
83, 84, 84, 85, 85, 85, 86, 86, 87, 88,
88, 88, 89, 89, 89, 90, 90, 90, 91, 91,
91, 91, 91, 91, 92, 92, 93, 93, 93, 94,
94, 94, 94, 95, 96, 97, 97, 97, 97, 98,
98, 98, 98, 98, 98, 99, 99, 100, 100, 100,
101, 101, 101, 101, 101, 102, 102, 102, 102, 102,
102, 102, 103, 103, 103, 103, 103, 104, 105, 105,
106, 106, 106, 107, 107, 107, 108, 108, 108, 108,
108, 108, 108, 108, 108, 108, 108, 109, 109, 109,
109, 109, 109, 109, 109, 109, 109, 109, 109, 109,
109, 109, 109, 109, 109, 110, 110, 111, 112, 112,
113, 114, 115, 115, 116, 116
};
static const short yyr2[] = { 0,
5, 2, 2, 2, 6, 5, 5, 0, 2, 0,
2, 2, 0, 5, 3, 3, 0, 3, 0, 3,
0, 3, 1, 1, 1, 1, 1, 1, 1, 6,
3, 3, 6, 3, 3, 0, 2, 1, 1, 0,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -