File indexing completed on 2024-04-28 15:22:49
0001 #!/usr/bin/perl 0002 0003 open(IN, "flex -t tokenizer.flex|") or die "no flex?\n"; 0004 open(OUT, ">tokenizer.cpp") or die $!; 0005 0006 print OUT <<STOP; 0007 /* 0008 * This file is part of the DOM implementation for KDE. 0009 * 0010 * Copyright 2003 Lars Knoll (knoll\@kde.org) 0011 * 0012 * This library is free software; you can redistribute it and/or 0013 * modify it under the terms of the GNU Library General Public 0014 * License as published by the Free Software Foundation; either 0015 * version 2 of the License, or (at your option) any later version. 0016 * 0017 * This library is distributed in the hope that it will be useful, 0018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0020 * Library General Public License for more details. 0021 * 0022 * You should have received a copy of the GNU Library General Public License 0023 * along with this library; see the file COPYING.LIB. If not, write to 0024 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0025 * Boston, MA 02110-1301, USA. 0026 */ 0027 0028 /* This file is mostly data generated by flex. Unfortunately flex 0029 can't handle 16bit strings directly, so we just copy the part of 0030 the code we need and modify it to our needs. 0031 0032 Most of the defines below are to make sure we can easily use the 0033 flex generated code, using as little editing as possible. 0034 0035 The flex syntax to generate the lexer are more or less directly 0036 copied from the CSS2.1 specs, with some fixes for comments and 0037 the important symbol. 0038 0039 To regenerate, run flex on tokenizer.flex. After this, copy the 0040 data tables and the YY_DECL method over to this file. Remove the 0041 init code from YY_DECL and change the YY_END_OF_BUFFER to only call 0042 yyterminate(). 0043 0044 */ 0045 0046 // --------- begin generated code ------------------- 0047 0048 STOP 0049 print OUT<<STOP; 0050 0051 #include "parser.h" 0052 0053 #define INITIAL 0 0054 #define mediaquery 1 0055 #define at_rule 2 0056 #define block 3 0057 0058 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ 0059 0060 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 0061 #include <inttypes.h> 0062 typedef int8_t flex_int8_t; 0063 typedef uint8_t flex_uint8_t; 0064 typedef int16_t flex_int16_t; 0065 typedef uint16_t flex_uint16_t; 0066 typedef int32_t flex_int32_t; 0067 typedef uint32_t flex_uint32_t; 0068 #else 0069 typedef signed char flex_int8_t; 0070 typedef short int flex_int16_t; 0071 typedef int flex_int32_t; 0072 typedef unsigned char flex_uint8_t; 0073 typedef unsigned short int flex_uint16_t; 0074 typedef unsigned int flex_uint32_t; 0075 #endif /* ! C99 */ 0076 STOP 0077 0078 while (<IN>) { 0079 /YY_NUM_RULES/../yy_last_accepting/ 0080 and !/yy_last_accepting/ and print OUT; 0081 /^YY_DECL/ and print OUT and last; 0082 } 0083 0084 while (<IN>) { 0085 s/char/unsigned short/; 0086 print OUT; 0087 last if /yy_act/; 0088 } 0089 0090 while (<IN>) { 0091 last if /while \( 1 \)/; 0092 } 0093 0094 print OUT; 0095 while (<IN>) { 0096 next if /^yy_match:/; 0097 next if /^do_action:/; 0098 last if /YY_END_OF_BUFFER/; 0099 print OUT; 0100 print OUT "case YY_END_OF_BUFFER:\n" if /^case YY_STATE_EOF\(INITIAL\):/; 0101 } 0102 0103 while (<IN>) { 0104 last if /default:/; 0105 } 0106 0107 print OUT; 0108 while (<IN>) { 0109 print OUT; 0110 last if /end of yylex/; 0111 }