File indexing completed on 2024-04-21 04:36:12
0001 #!/usr/bin/env ruby 0002 0003 ################################################################################ 0004 # This file is part of KDevelop-PG-Qt. # 0005 # Copyright Ⓒ 2011 Jonathan Schmidt-Dominé <devel@the-user.org> # 0006 # # 0007 # This library is free software; you can redistribute it and/or # 0008 # modify it under the terms of the GNU Library General Public License as # 0009 # published by the Free Software Foundation; either version 2 of the License, # 0010 # or (at your option) any later version. # 0011 # # 0012 # This library is distributed in the hope that it will be useful, but WITHOUT # 0013 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # 0014 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public # 0015 # License for more details. # 0016 # # 0017 # You should have received a copy of the GNU Library General Public License # 0018 # along with this library; see the file COPYING.LIB. If not, write to the # 0019 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 0020 # 02110-1301, USA. # 0021 ################################################################################ 0022 0023 puts <<-code 0024 // This file is generated by generate-get-utf8-tubles.rb 0025 // WARNING! All changes made in this file will be lost! 0026 0027 template<template<CharEncoding> class CharSet> 0028 NFA<CharSet<Latin1> > getUtf8Tuples(typename Codec2Int<Latin1>::Result from0, typename Codec2Int<Latin1>::Result to0) 0029 { 0030 return NFA<CharSet<Latin1> >(CharSet<Latin1>::range(from0, to0)); 0031 } 0032 code 0033 0034 for numranges in 2..4 0035 puts <<-code 0036 template<template<CharEncoding> class CharSet> 0037 NFA<CharSet<Latin1> > getUtf8Tuples(typename Codec2Int<Latin1>::Result from0, typename Codec2Int<Latin1>::Result to0 0038 code 0039 for i in 1..(numranges-1) 0040 print ", typename Codec2Int<Latin1>::Result from#{i}, typename Codec2Int<Latin1>::Result to#{i}" 0041 end 0042 puts <<-code 0043 ) 0044 { 0045 typedef typename Codec2Int<Latin1>::Result Int; 0046 if(from0 == to0) 0047 { 0048 auto tuples = NFA<CharSet<Latin1> >(CharSet<Latin1>(from0)); 0049 tuples <<= getUtf8Tuples<CharSet>(from1, to1 0050 code 0051 for i in 2..(numranges-1) 0052 print ", from#{i}, to#{i}" 0053 end 0054 puts <<-code 0055 ); 0056 return tuples; 0057 } 0058 else 0059 { 0060 NFA<CharSet<Latin1> > tuples; 0061 auto firstTuples = NFA<CharSet<Latin1> >(CharSet<Latin1>(from0)); 0062 firstTuples <<= getUtf8Tuples<CharSet>(from1, Int(0x80 + (1<<6)) 0063 code 0064 for i in 2..(numranges-1) 0065 print ", from#{i}, to#{i}" 0066 end 0067 puts <<-code 0068 ); 0069 tuples |= firstTuples; 0070 auto midTuples = NFA<CharSet<Latin1> >(CharSet<Latin1>::range(from0 + 1, to0)); 0071 midTuples <<= getUtf8Tuples<CharSet>(Int(0x80), Int(0x80 + (1<<6)) 0072 code 0073 for i in 2..(numranges-1) 0074 print ", from#{i}, to#{i}" 0075 end 0076 puts <<-code 0077 ); 0078 tuples |= midTuples; 0079 auto lastTuples = NFA<CharSet<Latin1> >(CharSet<Latin1>(to0)); 0080 lastTuples <<= getUtf8Tuples<CharSet>(Int(0x80), to1 0081 code 0082 for i in 2..(numranges-1) 0083 print ", from#{i}, to#{i}" 0084 end 0085 puts <<-code 0086 ); 0087 tuples |= lastTuples; 0088 return tuples; 0089 } 0090 } 0091 code 0092 end