gitee.com/curryzheng/dm@v0.0.1/parser/zv.go (about) 1 /* 2 * Copyright (c) 2000-2018, 达梦数据库有限公司. 3 * All rights reserved. 4 */ 5 package parser 6 7 import ( 8 "io" 9 "strconv" 10 "unicode/utf8" 11 ) 12 13 const ( 14 YYEOF = -1 /** This character denotes the end of file */ 15 ZZ_BUFFERSIZE = 16384 /** initial size of the lookahead buffer */ 16 /** lexical states */ 17 YYINITIAL = 0 18 xc = 2 19 xq = 4 20 xdq = 6 21 xsb = 8 22 xbin = 10 23 xhex = 12 24 xhint = 14 25 xq2 = 16 26 xq2_2 = 18 27 ) 28 29 /** 30 * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l 31 * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l 32 * at the beginning of a line 33 * l is of the form l = 2*k, k a non negative integer 34 */ 35 var ZZ_LEXSTATE []int = []int{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 4, 4, 7, 7, 8, 8} 36 37 /** 38 * Translates characters to character classes 39 */ 40 var ZZ_CMAP_PACKED []rune = []rune{0011, 0000, 0001, 0026, 0001, 0025, 0001, 0030, 0001, 0026, 0001, 0025, 0022, 0000, 0001, 0026, 0001, 0017, 0001, 0002, 41 0002, 0012, 0002, 0017, 0001, 0001, 0002, 0017, 0001, 0004, 0001, 0023, 0001, 0017, 0001, 0027, 0001, 0016, 0001, 0003, 42 0001, 0020, 0011, 0013, 0001, 0014, 0001, 0017, 0001, 0017, 0001, 0015, 0003, 0017, 0001, 0021, 0001, 0010, 0001, 0021, 43 0001, 0024, 0001, 0022, 0001, 0024, 0002, 0012, 0001, 0034, 0002, 0012, 0001, 0033, 0001, 0012, 0001, 0031, 0001, 0036, 44 0001, 0012, 0001, 0007, 0001, 0012, 0001, 0035, 0001, 0037, 0001, 0032, 0002, 0012, 0001, 0011, 0002, 0012, 0001, 0005, 45 0001, 0000, 0001, 0006, 0001, 0017, 0001, 0012, 0001, 0000, 0001, 0021, 0001, 0010, 0001, 0021, 0001, 0024, 0001, 0022, 46 0001, 0024, 0002, 0012, 0001, 0034, 0002, 0012, 0001, 0033, 0001, 0012, 0001, 0031, 0001, 0036, 0001, 0012, 0001, 0007, 47 0001, 0012, 0001, 0035, 0001, 0037, 0001, 0032, 0002, 0012, 0001, 0011, 0002, 0012, 0001, 0017, 0001, 0017, 0002, 0017, 48 0001, 0000, 0005, 0012, 0001, 0012, 0172, 0012, 0x1f28, 0000, 0001, 0030, 0001, 0030, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xffff, 0000, 0xdfe6, 0000} 49 50 /** 51 * Translates characters to character classes 52 */ 53 var ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED) 54 55 /** 56 * Translates DFA states to action switch labels. 57 */ 58 var ZZ_ACTION = zzUnpackActionNoParams() 59 60 var ZZ_ACTION_PACKED_0 []rune = []rune{0011, 0000, 0001, 0001, 0001, 0002, 0001, 0003, 0002, 0004, 0004, 0005, 0001, 0006, 0002, 0004, 61 0001, 0006, 0001, 0007, 0001, 0004, 0002, 0005, 0001, 0010, 0002, 0011, 0001, 0012, 0001, 0013, 62 0001, 0014, 0001, 0015, 0001, 0016, 0001, 0017, 0001, 0020, 0001, 0021, 0001, 0022, 0001, 0023, 63 0001, 0024, 0001, 0025, 0001, 0026, 0001, 0007, 0001, 0027, 0001, 0000, 0001, 0030, 0001, 0031, 64 0001, 0032, 0001, 0000, 0001, 0033, 0001, 0034, 0001, 0035, 0001, 0032, 0001, 0036, 0001, 0000, 65 0003, 0005, 0001, 0037, 0001, 0040, 0001, 0000, 0001, 0041, 0002, 0000, 0001, 0042, 0004, 0000, 66 0001, 0043, 0001, 0044, 0001, 0033, 0001, 0000, 0001, 0045, 0002, 0005, 0003, 0000, 0001, 0046, 67 0001, 0047, 0001, 0050, 0001, 0051, 0020, 0000, 0001, 0052, 0001, 0000, 0001, 0053, 0001, 0052, 68 0001, 0053} 69 70 func zzUnpackActionNoParams() []int { 71 result := make([]int, 104) 72 offset := 0 73 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result) 74 return result 75 } 76 77 func zzUnpackAction(packed []rune, offset int, result []int) int { 78 i := 0 /* index in packed string */ 79 j := offset /* index in unpacked array */ 80 l := len(packed) //130 81 for i < l { 82 count := packed[i] 83 i++ 84 value := packed[i] 85 i++ 86 result[j] = int(value) 87 j++ 88 count-- 89 for count > 0 { 90 result[j] = int(value) 91 j++ 92 count-- 93 } 94 } 95 return j 96 } 97 98 /** 99 * Translates a state to a row index in the transition table 100 */ 101 var ZZ_ROWMAP = zzUnpackRowMapNoParams() 102 103 var ZZ_ROWMAP_PACKED_0 []rune = []rune{0000, 0000, 0000, 0040, 0000, 0100, 0000, 0140, 0000, 0200, 0000, 0240, 0000, 0300, 0000, 0340, 104 0000, 0x0100, 0000, 0200, 0000, 0200, 0000, 0200, 0000, 0x0120, 0000, 0200, 0000, 0x0140, 0000, 0x0160, 105 0000, 0x0180, 0000, 0x01a0, 0000, 0x01c0, 0000, 0x01e0, 0000, 0x0200, 0000, 0x0220, 0000, 0200, 0000, 0x0240, 106 0000, 0x0260, 0000, 0x0280, 0000, 0x02a0, 0000, 0x02c0, 0000, 0x02e0, 0000, 0x0300, 0000, 0x0320, 0000, 0x0340, 107 0000, 0x0360, 0000, 0x0380, 0000, 0x03a0, 0000, 0x03c0, 0000, 0x03e0, 0000, 0x0400, 0000, 0200, 0000, 0200, 108 0000, 0200, 0000, 0200, 0000, 0x0420, 0000, 0200, 0000, 0x0440, 0000, 0200, 0000, 0200, 0000, 0x0460, 109 0000, 0x0480, 0000, 0200, 0000, 0200, 0000, 0200, 0000, 0x04a0, 0000, 0200, 0000, 0x04c0, 0000, 0x04e0, 110 0000, 0x0500, 0000, 0x0520, 0000, 0200, 0000, 0200, 0000, 0x02e0, 0000, 0200, 0000, 0x0540, 0000, 0x0560, 111 0000, 0200, 0000, 0x0580, 0000, 0x03a0, 0000, 0x05a0, 0000, 0x03e0, 0000, 0200, 0000, 0200, 0000, 0x05c0, 112 0000, 0x05c0, 0000, 0x04c0, 0000, 0x05e0, 0000, 0x0600, 0000, 0x0620, 0000, 0x0640, 0000, 0x0660, 0000, 0200, 113 0000, 0200, 0000, 0200, 0000, 0x01a0, 0000, 0x0680, 0000, 0x06a0, 0000, 0x06c0, 0000, 0x06e0, 0000, 0x0700, 114 0000, 0x0720, 0000, 0x0740, 0000, 0x0760, 0000, 0x0780, 0000, 0x07a0, 0000, 0x07c0, 0000, 0x07e0, 0000, 0x0800, 115 0000, 0x0820, 0000, 0x0840, 0000, 0x0860, 0000, 0200, 0000, 0x0880, 0000, 0200, 0000, 0x06e0, 0000, 0x0720} 116 117 func zzUnpackRowMapNoParams() []int { 118 result := make([]int, 104) 119 offset := 0 120 offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result) 121 return result 122 } 123 124 func zzUnpackRowMap(packed []rune, offset int, result []int) int { 125 i := 0 /* index in packed string */ 126 j := offset /* index in unpacked array */ 127 l := len(packed) //208 128 for i < l { 129 high := packed[i] << 16 130 i++ 131 result[j] = int(high | packed[i]) 132 i++ 133 j++ 134 } 135 return j 136 } 137 138 /** 139 * The transition table of the DFA 140 */ 141 var ZZ_TRANS []int = zzUnpackTransNoParams() 142 143 var ZZ_TRANS_PACKED_0 []rune = []rune{0001, 0012, 0001, 0013, 0001, 0014, 0001, 0015, 0003, 0016, 0001, 0017, 0001, 0020, 0001, 0021, 144 0001, 0022, 0001, 0023, 0001, 0024, 0001, 0016, 0001, 0025, 0001, 0016, 0001, 0026, 0002, 0022, 145 0001, 0016, 0001, 0022, 0002, 0027, 0001, 0030, 0001, 0000, 0001, 0031, 0002, 0022, 0001, 0032, 146 0003, 0022, 0003, 0033, 0001, 0034, 0001, 0035, 0033, 0033, 0001, 0036, 0001, 0037, 0036, 0036, 147 0002, 0040, 0001, 0041, 0035, 0040, 0040, 0000, 0001, 0042, 0001, 0043, 0036, 0042, 0001, 0044, 148 0001, 0045, 0036, 0044, 0006, 0046, 0001, 0047, 0031, 0046, 0001, 0050, 0001, 0051, 0004, 0050, 149 0001, 0052, 0031, 0050, 0003, 0000, 0001, 0053, 0001, 0054, 0034, 0000, 0001, 0055, 0005, 0000, 150 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 0001, 0022, 0004, 0000, 0007, 0022, 0001, 0000, 151 0001, 0056, 0005, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 0001, 0022, 0004, 0000, 152 0007, 0022, 0001, 0000, 0001, 0057, 0005, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 153 0001, 0022, 0004, 0000, 0007, 0022, 0007, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 154 0001, 0022, 0004, 0000, 0007, 0022, 0013, 0000, 0001, 0023, 0002, 0000, 0001, 0060, 0001, 0000, 155 0001, 0023, 0001, 0000, 0001, 0061, 0001, 0000, 0001, 0062, 0030, 0000, 0001, 0063, 0026, 0000, 156 0001, 0064, 0006, 0000, 0001, 0065, 0002, 0000, 0001, 0066, 0001, 0000, 0001, 0065, 0030, 0000, 157 0001, 0067, 0001, 0000, 0001, 0023, 0002, 0000, 0001, 0060, 0001, 0000, 0001, 0023, 0001, 0000, 158 0001, 0061, 0001, 0000, 0001, 0062, 0042, 0000, 0001, 0053, 0017, 0000, 0005, 0022, 0004, 0000, 159 0003, 0022, 0001, 0000, 0001, 0022, 0004, 0000, 0001, 0022, 0001, 0070, 0003, 0022, 0001, 0071, 160 0001, 0022, 0007, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 0001, 0022, 0004, 0000, 161 0004, 0022, 0001, 0072, 0002, 0022, 0003, 0033, 0002, 0000, 0033, 0033, 0004, 0000, 0001, 0073, 162 0036, 0000, 0001, 0074, 0001, 0075, 0033, 0000, 0001, 0036, 0001, 0000, 0036, 0036, 0001, 0000, 163 0001, 0076, 0023, 0000, 0001, 0077, 0001, 0100, 0011, 0000, 0002, 0040, 0001, 0000, 0035, 0040, 164 0002, 0000, 0001, 0101, 0035, 0000, 0001, 0042, 0001, 0000, 0036, 0042, 0025, 0000, 0001, 0102, 165 0001, 0103, 0011, 0000, 0001, 0044, 0001, 0000, 0036, 0044, 0025, 0000, 0001, 0104, 0001, 0105, 166 0011, 0000, 0006, 0046, 0001, 0000, 0031, 0046, 0025, 0053, 0001, 0000, 0012, 0053, 0005, 0000, 167 0001, 0106, 0045, 0000, 0001, 0065, 0002, 0000, 0001, 0107, 0001, 0000, 0001, 0065, 0001, 0000, 168 0001, 0061, 0001, 0000, 0001, 0062, 0026, 0000, 0001, 0110, 0004, 0000, 0001, 0110, 0002, 0000, 169 0001, 0111, 0003, 0000, 0001, 0111, 0023, 0000, 0001, 0065, 0004, 0000, 0001, 0065, 0001, 0000, 170 0001, 0061, 0001, 0000, 0001, 0062, 0023, 0000, 0001, 0112, 0002, 0000, 0001, 0112, 0004, 0000, 171 0003, 0112, 0001, 0000, 0001, 0112, 0022, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 172 0001, 0022, 0004, 0000, 0002, 0022, 0001, 0113, 0004, 0022, 0007, 0000, 0005, 0022, 0004, 0000, 173 0003, 0022, 0001, 0000, 0001, 0022, 0004, 0000, 0006, 0022, 0001, 0114, 0003, 0000, 0001, 0115, 174 0003, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 0001, 0022, 0002, 0116, 0001, 0117, 175 0001, 0000, 0007, 0022, 0001, 0000, 0001, 0120, 0023, 0000, 0002, 0077, 0036, 0000, 0001, 0077, 176 0001, 0100, 0012, 0000, 0001, 0121, 0023, 0000, 0002, 0102, 0012, 0000, 0001, 0122, 0023, 0000, 177 0002, 0104, 0024, 0000, 0001, 0110, 0004, 0000, 0001, 0110, 0026, 0000, 0005, 0022, 0004, 0000, 178 0003, 0022, 0001, 0000, 0001, 0022, 0004, 0000, 0002, 0022, 0001, 0123, 0004, 0022, 0003, 0000, 179 0001, 0124, 0003, 0000, 0005, 0022, 0004, 0000, 0003, 0022, 0001, 0000, 0001, 0022, 0002, 0125, 180 0001, 0126, 0001, 0000, 0007, 0022, 0003, 0000, 0001, 0127, 0037, 0000, 0001, 0115, 0021, 0000, 181 0002, 0116, 0001, 0117, 0001, 0000, 0001, 0130, 0035, 0000, 0001, 0127, 0013, 0000, 0001, 0131, 182 0037, 0000, 0001, 0124, 0021, 0000, 0002, 0125, 0001, 0126, 0001, 0000, 0001, 0132, 0035, 0000, 183 0001, 0131, 0010, 0000, 0025, 0127, 0001, 0116, 0003, 0127, 0001, 0133, 0006, 0127, 0032, 0000, 184 0001, 0134, 0005, 0000, 0025, 0131, 0001, 0125, 0003, 0131, 0001, 0135, 0006, 0131, 0032, 0000, 185 0001, 0136, 0005, 0000, 0025, 0127, 0001, 0116, 0003, 0127, 0001, 0133, 0001, 0137, 0005, 0127, 186 0033, 0000, 0001, 0140, 0004, 0000, 0025, 0131, 0001, 0125, 0003, 0131, 0001, 0135, 0001, 0141, 187 0005, 0131, 0033, 0000, 0001, 0142, 0004, 0000, 0025, 0127, 0001, 0116, 0003, 0127, 0001, 0133, 188 0001, 0127, 0001, 0143, 0004, 0127, 0033, 0000, 0001, 0144, 0004, 0000, 0025, 0131, 0001, 0125, 189 0003, 0131, 0001, 0135, 0001, 0131, 0001, 0145, 0004, 0131, 0033, 0000, 0001, 0146, 0004, 0000, 190 0025, 0127, 0001, 0116, 0003, 0127, 0001, 0133, 0001, 0127, 0001, 0147, 0004, 0127, 0025, 0131, 191 0001, 0125, 0003, 0131, 0001, 0135, 0001, 0131, 0001, 0150, 0004, 0131} 192 193 func zzUnpackTransNoParams() []int { 194 result := make([]int, 2208) 195 offset := 0 196 offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result) 197 return result 198 } 199 200 func zzUnpackTrans(packed []rune, offset int, result []int) int { 201 i := 0 /* index in packed string */ 202 j := offset /* index in unpacked array */ 203 l := len(packed) //780 204 for i < l { 205 count := packed[i] 206 i++ 207 value := packed[i] 208 i++ 209 value-- 210 result[j] = int(value) 211 j++ 212 count-- 213 for count > 0 { 214 result[j] = int(value) 215 j++ 216 count-- 217 } 218 } 219 return j 220 } 221 222 /* error codes */ 223 const ( 224 ZZ_UNKNOWN_ERROR = 0 225 ZZ_NO_MATCH = 1 226 ZZ_PUSHBACK_2BIG = 2 227 ) 228 229 /* error messages for the codes above */ 230 var ZZ_ERROR_MSG []string = []string{ 231 "Unknown internal scanner error", 232 "Error: could not match input", 233 "Error: pushback Value was too large"} 234 235 /** 236 * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> 237 */ 238 var ZZ_ATTRIBUTE []int = zzUnpackAttributeNoParams() 239 240 var ZZ_ATTRIBUTE_PACKED_0 []rune = []rune{0004, 0000, 0001, 0010, 0004, 0000, 0003, 0011, 0001, 0001, 0001, 0011, 0010, 0001, 0001, 0011, 241 0017, 0001, 0004, 0011, 0001, 0001, 0001, 0011, 0001, 0000, 0002, 0011, 0001, 0001, 0001, 0000, 242 0003, 0011, 0001, 0001, 0001, 0011, 0001, 0000, 0003, 0001, 0002, 0011, 0001, 0000, 0001, 0011, 243 0002, 0000, 0001, 0011, 0004, 0000, 0002, 0011, 0001, 0001, 0001, 0000, 0003, 0001, 0003, 0000, 244 0003, 0011, 0001, 0001, 0020, 0000, 0001, 0011, 0001, 0000, 0001, 0011, 0002, 0001} 245 246 func zzUnpackAttributeNoParams() []int { 247 result := make([]int, 104) 248 offset := 0 249 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result) 250 return result 251 } 252 253 func zzUnpackAttribute(packed []rune, offset int, result []int) int { 254 i := 0 /* index in packed string */ 255 j := offset /* index in unpacked array */ 256 l := len(packed) //78 257 for i < l { 258 count := packed[i] 259 i++ 260 value := packed[i] 261 i++ 262 result[j] = int(value) 263 j++ 264 count-- 265 266 for count > 0 { 267 result[j] = int(value) 268 j++ 269 count-- 270 } 271 } 272 return j 273 } 274 275 type Lexer struct { 276 /** the input device */ 277 zzReader io.RuneReader 278 279 /** the current state of the DFA */ 280 zzState int 281 282 /** the current lexical state */ 283 zzLexicalState int 284 285 /** this buffer contains the current text to be matched and is 286 the source of the yytext() string */ 287 zzBuffer []rune 288 289 //zzBytesBuffer []byte 290 291 /** the textposition at the last accepting state */ 292 zzMarkedPos int 293 294 /** the current text Position in the buffer */ 295 zzCurrentPos int 296 297 /** startRead marks the beginning of the yytext() string in the buffer */ 298 zzStartRead int 299 300 /** endRead marks the last character in the buffer, that has been read 301 from input */ 302 zzEndRead int 303 304 /** number of newlines encountered up to the start of the matched text */ 305 yyline int 306 307 /** the number of characters up to the start of the matched text */ 308 yychar int 309 310 /** 311 * the number of characters from the last newline up to the start of the 312 * matched text 313 */ 314 yycolumn int 315 316 /** 317 * zzAtBOL == true <=> the scanner is currently at the beginning of a line 318 */ 319 zzAtBOL bool 320 321 /** zzAtEOF == true <=> the scanner is at the EOF */ 322 zzAtEOF bool 323 324 /** denotes if the user-EOF-code has already been executed */ 325 zzEOFDone bool 326 327 /** 328 * The number of occupied positions in zzBuffer beyond zzEndRead. 329 * When a lead/high surrogate has been read from the input stream 330 * into the final zzBuffer Position, this will have a Value of 1; 331 * otherwise, it will have a Value of 0. 332 */ 333 zzFinalHighSurrogate int 334 335 /* user code: */ 336 ltstr string 337 debugFlag bool 338 } 339 340 func (lexer *Lexer) init() { 341 lexer.zzLexicalState = YYINITIAL 342 lexer.zzBuffer = make([]rune, ZZ_BUFFERSIZE) 343 lexer.zzAtBOL = true 344 } 345 346 func (lexer *Lexer) Reset(in io.RuneReader) *Lexer { 347 lexer.zzLexicalState = YYINITIAL 348 lexer.zzAtBOL = true 349 lexer.zzReader = in 350 lexer.zzState = 0 351 lexer.zzMarkedPos = 0 352 lexer.zzCurrentPos = 0 353 lexer.zzStartRead = 0 354 lexer.zzEndRead = 0 355 lexer.yyline = 0 356 lexer.yychar = 0 357 lexer.yycolumn = 0 358 lexer.zzAtEOF = false 359 lexer.zzEOFDone = false 360 lexer.zzFinalHighSurrogate = 0 361 lexer.ltstr = "" 362 return lexer 363 } 364 365 func (lexer *Lexer) debug(info string) { 366 if !lexer.debugFlag { 367 return 368 } 369 370 } 371 372 func (lexer *Lexer) yyerror(msg string) { 373 locInfo := "(line: " + strconv.Itoa(lexer.yyline) + ", column: " + strconv.Itoa(lexer.yycolumn) + ", char: " + strconv.Itoa(lexer.yychar) + ")" 374 if msg == "" { 375 panic("syntex error" + locInfo) 376 } else { 377 panic("syntex error" + locInfo + ": " + msg) 378 } 379 } 380 381 /** 382 * Creates a new scanner 383 * 384 * @param in the java.io.Reader to read input from. 385 */ 386 func NewLexer(in io.RuneReader, debug bool) *Lexer { 387 l := new(Lexer) 388 l.init() 389 l.debugFlag = debug 390 l.zzReader = in 391 return l 392 } 393 394 /** 395 * Unpacks the compressed character translation table. 396 * 397 * @param packed the packed character translation table 398 * @return the unpacked character translation table 399 */ 400 func zzUnpackCMap(packed []rune) []rune { 401 m := make([]rune, 0x110000) 402 i := 0 /* index in packed string */ 403 j := 0 /* index in unpacked array */ 404 for i < 208 { 405 count := packed[i] 406 i++ 407 value := packed[i] 408 i++ 409 m[j] = value 410 j++ 411 count-- 412 for count > 0 { 413 m[j] = value 414 j++ 415 count-- 416 } 417 } 418 return m 419 } 420 421 /** 422 * Refills the input buffer. 423 * 424 * @return <code>false</code>, iff there was new input. 425 * 426 * @exception java.io.IOException if any I/O-Error occurs 427 */ 428 func (lexer *Lexer) zzRefill() (bool, error) { 429 430 /* first: make room (if you can) */ 431 if lexer.zzStartRead > 0 { 432 lexer.zzEndRead += lexer.zzFinalHighSurrogate 433 lexer.zzFinalHighSurrogate = 0 434 l := lexer.zzEndRead - lexer.zzStartRead 435 if l > 0 { 436 copy(lexer.zzBuffer[:l], lexer.zzBuffer[lexer.zzStartRead:lexer.zzEndRead]) 437 } 438 439 /* translate stored positions */ 440 lexer.zzEndRead -= lexer.zzStartRead 441 lexer.zzCurrentPos -= lexer.zzStartRead 442 lexer.zzMarkedPos -= lexer.zzStartRead 443 lexer.zzStartRead = 0 444 } 445 446 /* is the buffer big enough? */ 447 if lexer.zzCurrentPos >= len(lexer.zzBuffer)-lexer.zzFinalHighSurrogate { 448 /* if not: blow it up */ 449 newBuffer := make([]rune, len(lexer.zzBuffer)*2) 450 451 copy(newBuffer[:len(lexer.zzBuffer)], lexer.zzBuffer[:len(lexer.zzBuffer)]) 452 lexer.zzBuffer = newBuffer 453 lexer.zzEndRead += lexer.zzFinalHighSurrogate 454 lexer.zzFinalHighSurrogate = 0 455 } 456 457 /* fill the buffer with new input */ 458 requested := len(lexer.zzBuffer) - lexer.zzEndRead 459 460 var numRead = 0 461 for i := lexer.zzEndRead; i < lexer.zzEndRead+requested; i++ { 462 r, _, err := lexer.zzReader.ReadRune() 463 if err == io.EOF { 464 if numRead == 0 { 465 numRead = -1 466 } 467 break 468 } else if err != nil { 469 return false, err 470 } else { 471 numRead++ 472 lexer.zzBuffer[i] = r 473 } 474 } 475 476 /* not supposed to occur according to specification of java.io.Reader */ 477 if numRead == 0 { 478 panic("Reader returned 0 characters. See JFlex examples for workaround.") 479 } 480 481 if numRead > 0 { 482 483 lexer.zzEndRead += numRead 484 /* If numRead == requested, we might have requested to few chars to 485 encode a full Unicode character. We assume that a Reader would 486 otherwise never return half characters. */ 487 if numRead == requested { 488 if utf8.ValidRune(lexer.zzBuffer[lexer.zzEndRead-1]) { 489 lexer.zzEndRead-- 490 lexer.zzFinalHighSurrogate = 1 491 } 492 } 493 /* potentially more input available */ 494 return false, nil 495 } 496 497 /* numRead < 0 ==> end of stream */ 498 return true, nil 499 } 500 501 /** 502 * Closes the input stream. 503 */ 504 func (lexer *Lexer) yyclose() error { 505 lexer.zzAtEOF = true /* indicate end of file */ 506 lexer.zzEndRead = lexer.zzStartRead /* invalidate buffer */ 507 508 if lexer.zzReader != nil { 509 if c, ok := lexer.zzReader.(io.Closer); ok { 510 return c.Close() 511 } 512 } 513 return nil 514 } 515 516 /** 517 * Resets the scanner to read from a new input stream. 518 * Does not close the old reader. 519 * 520 * All internal variables are reset, the old input stream 521 * <b>cannot</b> be reused (internal buffer is discarded and lost). 522 * Lexical state is set to <tt>ZZ_INITIAL</tt>. 523 * 524 * Internal scan buffer is resized down to its initial length, if it has grown. 525 * 526 * @param reader the new input stream 527 */ 528 func (lexer *Lexer) yyreset(reader io.RuneReader) { 529 lexer.zzReader = reader 530 lexer.zzAtBOL = true 531 lexer.zzAtEOF = false 532 lexer.zzEOFDone = false 533 lexer.zzEndRead = 0 534 lexer.zzStartRead = 0 535 lexer.zzCurrentPos = 0 536 lexer.zzMarkedPos = 0 537 lexer.zzFinalHighSurrogate = 0 538 lexer.yyline = 0 539 lexer.yychar = 0 540 lexer.yycolumn = 0 541 lexer.zzLexicalState = YYINITIAL 542 if len(lexer.zzBuffer) > ZZ_BUFFERSIZE { 543 lexer.zzBuffer = make([]rune, ZZ_BUFFERSIZE) 544 } 545 } 546 547 /** 548 * Returns the current lexical state. 549 */ 550 func (lexer *Lexer) yystate() int { 551 return lexer.zzLexicalState 552 } 553 554 /** 555 * Enters a new lexical state 556 * 557 * @param newState the new lexical state 558 */ 559 func (lexer *Lexer) yybegin(newState int) { 560 lexer.zzLexicalState = newState 561 } 562 563 /** 564 * Returns the text matched by the current regular expression. 565 */ 566 func (lexer *Lexer) yytext() string { 567 return string(lexer.zzBuffer[lexer.zzStartRead:lexer.zzMarkedPos]) 568 } 569 570 /** 571 * Returns the character at Position <tt>pos</tt> from the 572 * matched text. 573 * 574 * It is equivalent to yytext().charAt(pos), but faster 575 * 576 * @param pos the Position of the character to fetch. 577 * A Value from 0 to yylength()-1. 578 * 579 * @return the character at Position pos 580 */ 581 func (lexer *Lexer) yycharat(pos int) rune { 582 return lexer.zzBuffer[lexer.zzStartRead+pos] 583 } 584 585 /** 586 * Returns the length of the matched text region. 587 */ 588 func (lexer *Lexer) yylength() int { 589 return lexer.zzMarkedPos - lexer.zzStartRead 590 } 591 592 /** 593 * Reports an error that occured while scanning. 594 * 595 * In a wellformed scanner (no or only correct usage of 596 * yypushback(int) and a match-all fallback rule) this method 597 * will only be called with things that "Can't Possibly Happen". 598 * If this method is called, something is seriously wrong 599 * (e.g. a JFlex bug producing a faulty scanner etc.). 600 * 601 * Usual syntax/scanner level error handling should be done 602 * in error fallback rules. 603 * 604 * @param errorCode the code of the errormessage to display 605 */ 606 func (lexer *Lexer) zzScanError(errorCode int) { 607 var message string 608 609 message = ZZ_ERROR_MSG[errorCode] 610 if message == "" { 611 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR] 612 } 613 614 panic(message) 615 } 616 617 /** 618 * Pushes the specified amount of characters back into the input stream. 619 * 620 * They will be read again by then next call of the scanning method 621 * 622 * @param number the number of characters to be read again. 623 * This number must not be greater than yylength()! 624 */ 625 func (lexer *Lexer) yypushback(number int) { 626 if number > lexer.yylength() { 627 lexer.zzScanError(ZZ_PUSHBACK_2BIG) 628 } 629 630 lexer.zzMarkedPos -= number 631 } 632 633 /** 634 * Resumes scanning until the next regular expression is matched, 635 * the end of input is encountered or an I/O-Error occurs. 636 * 637 * @return the next token 638 * @exception java.io.IOException if any I/O-Error occurs 639 */ 640 func (lexer *Lexer) Yylex() (*LVal, error) { 641 var zzInput rune 642 var zzAction, zzCurrentPosL, zzMarkedPosL int 643 // cached fields: 644 zzEndReadL := lexer.zzEndRead 645 zzBufferL := lexer.zzBuffer 646 zzCMapL := ZZ_CMAP 647 648 zzTransL := ZZ_TRANS 649 zzRowMapL := ZZ_ROWMAP 650 zzAttrL := ZZ_ATTRIBUTE 651 652 for { 653 zzMarkedPosL = lexer.zzMarkedPos 654 655 lexer.yychar += zzMarkedPosL - lexer.zzStartRead 656 657 zzR := false 658 var zzCh rune 659 var zzCharCount int 660 zzCurrentPosL = lexer.zzStartRead 661 for zzCurrentPosL < zzMarkedPosL { 662 zzCh = zzBufferL[zzCurrentPosL] 663 zzCharCount = utf8.RuneLen(zzCh) 664 switch zzCh { 665 case '\u000B', '\u000C', '\u0085', '\u2028', '\u2029': 666 lexer.yyline++ 667 lexer.yycolumn = 0 668 zzR = false 669 case '\r': 670 lexer.yyline++ 671 lexer.yycolumn = 0 672 zzR = true 673 case '\n': 674 if zzR { 675 zzR = false 676 } else { 677 lexer.yyline++ 678 lexer.yycolumn = 0 679 } 680 default: 681 zzR = false 682 lexer.yycolumn += zzCharCount 683 } 684 zzCurrentPosL += zzCharCount 685 } 686 687 if zzR { 688 // peek one character ahead if it is \n (if we have counted one line too much) 689 var zzPeek bool 690 if zzMarkedPosL < zzEndReadL { 691 zzPeek = zzBufferL[zzMarkedPosL] == '\n' 692 } else if lexer.zzAtEOF { 693 zzPeek = false 694 } else { 695 eof, err := lexer.zzRefill() 696 if err != nil { 697 return nil, err 698 } 699 zzEndReadL = lexer.zzEndRead 700 zzMarkedPosL = lexer.zzMarkedPos 701 zzBufferL = lexer.zzBuffer 702 if eof { 703 zzPeek = false 704 } else { 705 zzPeek = zzBufferL[zzMarkedPosL] == '\n' 706 } 707 708 } 709 if zzPeek { 710 lexer.yyline-- 711 } 712 } 713 zzAction = -1 714 715 zzCurrentPosL = zzMarkedPosL 716 lexer.zzCurrentPos = zzMarkedPosL 717 lexer.zzStartRead = zzMarkedPosL 718 lexer.zzState = ZZ_LEXSTATE[lexer.zzLexicalState] 719 720 // set up zzAction for empty match case: 721 zzAttributes := zzAttrL[lexer.zzState] 722 if (zzAttributes & 1) == 1 { 723 zzAction = lexer.zzState 724 } 725 726 { 727 for true { 728 729 if zzCurrentPosL < zzEndReadL { 730 zzInput = zzBufferL[zzCurrentPosL] 731 zzCurrentPosL += 1 //utf8.RuneLen(zzInput) 732 } else if lexer.zzAtEOF { 733 zzInput = YYEOF 734 goto zzForAction 735 } else { 736 // store back cached positions 737 lexer.zzCurrentPos = zzCurrentPosL 738 lexer.zzMarkedPos = zzMarkedPosL 739 eof, err := lexer.zzRefill() 740 if err != nil { 741 return nil, err 742 } 743 // get translated positions and possibly new buffer 744 zzCurrentPosL = lexer.zzCurrentPos 745 zzMarkedPosL = lexer.zzMarkedPos 746 zzBufferL = lexer.zzBuffer 747 zzEndReadL = lexer.zzEndRead 748 if eof { 749 zzInput = YYEOF 750 goto zzForAction 751 } else { 752 zzInput = zzBufferL[zzCurrentPosL] 753 zzCurrentPosL += 1 //utf8.RuneLen(zzInput) 754 } 755 } 756 757 zzNext := zzTransL[zzRowMapL[lexer.zzState]+int(zzCMapL[zzInput])] 758 if zzNext == -1 { 759 goto zzForAction 760 } 761 762 lexer.zzState = zzNext 763 764 zzAttributes = zzAttrL[lexer.zzState] 765 if (zzAttributes & 1) == 1 { 766 zzAction = lexer.zzState 767 zzMarkedPosL = zzCurrentPosL 768 if (zzAttributes & 8) == 8 { 769 goto zzForAction 770 } 771 } 772 773 } 774 } 775 776 zzForAction: 777 // store back cached Position 778 lexer.zzMarkedPos = zzMarkedPosL 779 780 if zzInput == YYEOF && lexer.zzStartRead == lexer.zzCurrentPos { 781 lexer.zzAtEOF = true 782 switch lexer.zzLexicalState { 783 case xc: 784 { 785 lexer.debug("<xc><<EOF>>") 786 787 lexer.yybegin(YYINITIAL) 788 lexer.yyerror("unterminated /* comment") 789 } 790 case 105: 791 case xq: 792 { 793 lexer.debug("<xq><<EOF>>") 794 795 lexer.yybegin(YYINITIAL) 796 lexer.yyerror("unterminated quoted string") 797 } 798 fallthrough 799 case 106: 800 case xdq: 801 { 802 lexer.debug("<xdq><<EOF>>") 803 804 lexer.yybegin(YYINITIAL) 805 lexer.yyerror("unterminated quoted identifier") 806 } 807 fallthrough 808 case 107: 809 case xbin: 810 { 811 lexer.debug("<xbin><<EOF>>") 812 813 lexer.yybegin(YYINITIAL) 814 lexer.yyerror("unterminated binary string literal") 815 } 816 fallthrough 817 case 108: 818 case xhex: 819 { 820 lexer.debug("<xhex><<EOF>>") 821 822 lexer.yybegin(YYINITIAL) 823 lexer.yyerror("unterminated hexadecimal integer") 824 } 825 fallthrough 826 case 109: 827 case xq2: 828 { 829 lexer.yybegin(YYINITIAL) 830 lexer.yyerror("unterminated q2 string") 831 } 832 fallthrough 833 case 110: 834 case xq2_2: 835 { 836 lexer.yybegin(YYINITIAL) 837 lexer.yyerror("unterminated q2 string") 838 } 839 fallthrough 840 case 111: 841 default: 842 return nil, nil 843 } 844 } else { 845 var action int 846 if zzAction < 0 { 847 action = zzAction 848 } else { 849 action = ZZ_ACTION[zzAction] 850 } 851 switch action { 852 case 1: 853 { 854 lexer.debug("{other}") 855 856 return newLVal(lexer.yytext(), NORMAL), nil 857 } 858 fallthrough 859 case 44: 860 case 2: 861 { 862 lexer.debug("{xq_start}") 863 864 lexer.yybegin(xq) 865 lexer.ltstr = "" 866 } 867 fallthrough 868 case 45: 869 case 3: 870 { 871 lexer.debug("{xdq_start}") 872 873 lexer.yybegin(xdq) 874 lexer.ltstr = "" 875 lexer.ltstr += lexer.yytext() 876 } 877 fallthrough 878 case 46: 879 case 4: 880 { 881 lexer.debug("{self} | {op_chars}") 882 883 return newLVal(lexer.yytext(), NORMAL), nil 884 } 885 fallthrough 886 case 47: 887 case 5: 888 { 889 lexer.debug("{identifier}") 890 891 return newLVal(lexer.yytext(), NORMAL), nil 892 } 893 fallthrough 894 case 48: 895 case 6: 896 { 897 lexer.debug("{integer}") 898 899 return newLVal(lexer.yytext(), INT), nil 900 } 901 fallthrough 902 case 49: 903 case 7: 904 { 905 lexer.debug("{whitespace} | {comment} | {c_line_comment}") 906 907 return newLVal(lexer.yytext(), WHITESPACE_OR_COMMENT), nil 908 } 909 fallthrough 910 case 50: 911 case 8: 912 { 913 lexer.debug("<xc>{xc_inside}") 914 915 lexer.ltstr += lexer.yytext() 916 } 917 fallthrough 918 case 51: 919 case 9: 920 { 921 lexer.debug("<xc>[\\/] | <xc>[\\*]") 922 923 lexer.ltstr += lexer.yytext() 924 } 925 fallthrough 926 case 52: 927 case 10: 928 { 929 lexer.debug("<xq>{xq_inside}") 930 931 lexer.ltstr += lexer.yytext() 932 } 933 fallthrough 934 case 53: 935 case 11: 936 { 937 lexer.debug("<xq>{xq_stop}") 938 939 lexer.yybegin(YYINITIAL) 940 return newLVal(lexer.ltstr, STRING), nil 941 } 942 fallthrough 943 case 54: 944 case 12: 945 { 946 lexer.debug("<xdq>{xdq_inside}") 947 948 lexer.ltstr += lexer.yytext() 949 } 950 fallthrough 951 case 55: 952 case 13: 953 { 954 lexer.debug("<xdq>{xdq_stop}") 955 956 lexer.yybegin(YYINITIAL) 957 lexer.ltstr += lexer.yytext() 958 return newLVal(lexer.ltstr, NORMAL), nil 959 } 960 fallthrough 961 case 56: 962 case 14: 963 { 964 lexer.debug("<xbin>{xbin_inside}") 965 966 lexer.ltstr += lexer.yytext() 967 } 968 fallthrough 969 case 57: 970 case 15: 971 { 972 lexer.debug("<xbin>{xbin_stop}") 973 974 lexer.yybegin(YYINITIAL) 975 lexer.ltstr += lexer.yytext() 976 return newLVal(lexer.ltstr, NORMAL), nil 977 } 978 fallthrough 979 case 58: 980 case 16: 981 { 982 lexer.debug("<xhex>{xhex_inside}") 983 984 lexer.ltstr += lexer.yytext() 985 } 986 fallthrough 987 case 59: 988 case 17: 989 { 990 lexer.debug("<xhex>{xhex_stop}") 991 992 lexer.yybegin(YYINITIAL) 993 lexer.ltstr += lexer.yytext() 994 return newLVal(lexer.ltstr, NORMAL), nil 995 } 996 fallthrough 997 case 60: 998 case 18: 999 { 1000 lexer.ltstr += lexer.yytext() 1001 } 1002 fallthrough 1003 case 61: 1004 case 19: 1005 { 1006 lexer.yybegin(xq2_2) 1007 } 1008 fallthrough 1009 case 62: 1010 case 20: 1011 { 1012 lexer.ltstr += "]" 1013 lexer.ltstr += lexer.yytext() 1014 lexer.yybegin(xq2) 1015 } 1016 fallthrough 1017 case 63: 1018 case 21: 1019 { 1020 lexer.yybegin(YYINITIAL) 1021 1022 return newLVal(lexer.ltstr, STRING), nil 1023 } 1024 fallthrough 1025 case 64: 1026 case 22: 1027 { 1028 lexer.ltstr += "]" 1029 lexer.yybegin(xq2_2) 1030 } 1031 fallthrough 1032 case 65: 1033 case 23: 1034 { 1035 lexer.debug("{xc_start}") 1036 1037 lexer.yybegin(xc) 1038 lexer.ltstr = lexer.yytext() 1039 } 1040 fallthrough 1041 case 66: 1042 case 24: 1043 { 1044 lexer.debug("{xbin_start}") 1045 1046 lexer.yybegin(xbin) 1047 lexer.ltstr = "" 1048 lexer.ltstr += lexer.yytext() 1049 } 1050 fallthrough 1051 case 67: 1052 case 25: 1053 { 1054 lexer.debug("{xhex_start}") 1055 1056 lexer.yybegin(xhex) 1057 lexer.ltstr = "" 1058 lexer.ltstr += lexer.yytext() 1059 } 1060 fallthrough 1061 case 68: 1062 case 26: 1063 { 1064 lexer.debug("{decimal}") 1065 1066 return newLVal(lexer.yytext(), DECIMAL), nil 1067 } 1068 fallthrough 1069 case 69: 1070 case 27: 1071 { 1072 lexer.debug("{real}") 1073 1074 return newLVal(lexer.yytext(), DOUBLE), nil 1075 } 1076 fallthrough 1077 case 70: 1078 case 28: 1079 { 1080 lexer.debug("{assign}") 1081 1082 return newLVal(lexer.yytext(), NORMAL), nil 1083 } 1084 fallthrough 1085 case 71: 1086 case 29: 1087 { 1088 lexer.debug("{selstar}") 1089 1090 return newLVal(lexer.yytext(), NORMAL), nil 1091 } 1092 fallthrough 1093 case 72: 1094 case 30: 1095 { 1096 lexer.debug("{boundary}") 1097 1098 return newLVal(lexer.yytext(), NORMAL), nil 1099 } 1100 fallthrough 1101 case 73: 1102 case 31: 1103 { 1104 lexer.debug("<xc>{xc_start}") 1105 1106 lexer.ltstr += lexer.yytext() 1107 } 1108 fallthrough 1109 case 74: 1110 case 32: 1111 { 1112 lexer.debug("<xc>{xc_stop}") 1113 1114 lexer.yybegin(YYINITIAL) 1115 lexer.ltstr += lexer.yytext() 1116 return newLVal(lexer.ltstr, WHITESPACE_OR_COMMENT), nil 1117 } 1118 fallthrough 1119 case 75: 1120 case 33: 1121 { 1122 lexer.debug("<xq>{xq_double}") 1123 1124 lexer.ltstr += "\\'" 1125 } 1126 fallthrough 1127 case 76: 1128 case 34: 1129 { // keep original string 1130 lexer.debug("<xdq>{xdq_double}") 1131 1132 lexer.ltstr += lexer.yytext() 1133 } 1134 fallthrough 1135 case 77: 1136 case 35: 1137 { 1138 lexer.yybegin(xq2) 1139 lexer.ltstr = "" 1140 } 1141 fallthrough 1142 case 78: 1143 case 36: 1144 { 1145 lexer.debug("{integer_with_boundary}") 1146 1147 return newLVal(lexer.yytext(), NORMAL), nil 1148 } 1149 fallthrough 1150 case 79: 1151 case 37: 1152 { 1153 lexer.debug("{hex_integer}") 1154 1155 return newLVal(lexer.yytext(), HEX_INT), nil 1156 } 1157 fallthrough 1158 case 80: 1159 case 38: 1160 { 1161 lexer.debug("<xq>{xq_cat}") 1162 } 1163 fallthrough 1164 case 81: 1165 case 39: 1166 { /* ignore */ 1167 lexer.debug("<xbin>{xbin_cat}") 1168 } 1169 fallthrough 1170 case 82: 1171 case 40: 1172 { 1173 lexer.debug("<xhex>{xhex_cat}") 1174 } 1175 fallthrough 1176 case 83: 1177 case 41: 1178 { 1179 lexer.debug("{null}") 1180 1181 return newLVal("null", NULL), nil 1182 } 1183 fallthrough 1184 case 84: 1185 case 42: 1186 { 1187 lexer.debug("{is_null}") 1188 1189 return newLVal(lexer.yytext(), NORMAL), nil 1190 } 1191 fallthrough 1192 case 85: 1193 case 43: 1194 { 1195 lexer.debug("{not_null}") 1196 1197 return newLVal(lexer.yytext(), NORMAL), nil 1198 } 1199 fallthrough 1200 case 86: 1201 default: 1202 lexer.zzScanError(ZZ_NO_MATCH) 1203 } 1204 } 1205 } 1206 }