github.com/hashicorp/hcl/v2@v2.20.0/hclsyntax/scan_string_lit.go (about) 1 //line scan_string_lit.rl:1 2 // Copyright (c) HashiCorp, Inc. 3 // SPDX-License-Identifier: MPL-2.0 4 5 package hclsyntax 6 7 // This file is generated from scan_string_lit.rl. DO NOT EDIT. 8 9 //line scan_string_lit.go:11 10 var _hclstrtok_actions []byte = []byte{ 11 0, 1, 0, 1, 1, 2, 1, 0, 12 } 13 14 var _hclstrtok_key_offsets []byte = []byte{ 15 0, 0, 2, 4, 6, 10, 14, 18, 16 22, 27, 31, 36, 41, 46, 51, 57, 17 62, 74, 85, 96, 107, 118, 129, 140, 18 151, 19 } 20 21 var _hclstrtok_trans_keys []byte = []byte{ 22 128, 191, 128, 191, 128, 191, 10, 13, 23 36, 37, 10, 13, 36, 37, 10, 13, 24 36, 37, 10, 13, 36, 37, 10, 13, 25 36, 37, 123, 10, 13, 36, 37, 10, 26 13, 36, 37, 92, 10, 13, 36, 37, 27 92, 10, 13, 36, 37, 92, 10, 13, 28 36, 37, 92, 10, 13, 36, 37, 92, 29 123, 10, 13, 36, 37, 92, 85, 117, 30 128, 191, 192, 223, 224, 239, 240, 247, 31 248, 255, 10, 13, 36, 37, 92, 48, 32 57, 65, 70, 97, 102, 10, 13, 36, 33 37, 92, 48, 57, 65, 70, 97, 102, 34 10, 13, 36, 37, 92, 48, 57, 65, 35 70, 97, 102, 10, 13, 36, 37, 92, 36 48, 57, 65, 70, 97, 102, 10, 13, 37 36, 37, 92, 48, 57, 65, 70, 97, 38 102, 10, 13, 36, 37, 92, 48, 57, 39 65, 70, 97, 102, 10, 13, 36, 37, 40 92, 48, 57, 65, 70, 97, 102, 10, 41 13, 36, 37, 92, 48, 57, 65, 70, 42 97, 102, 43 } 44 45 var _hclstrtok_single_lengths []byte = []byte{ 46 0, 0, 0, 0, 4, 4, 4, 4, 47 5, 4, 5, 5, 5, 5, 6, 5, 48 2, 5, 5, 5, 5, 5, 5, 5, 49 5, 50 } 51 52 var _hclstrtok_range_lengths []byte = []byte{ 53 0, 1, 1, 1, 0, 0, 0, 0, 54 0, 0, 0, 0, 0, 0, 0, 0, 55 5, 3, 3, 3, 3, 3, 3, 3, 56 3, 57 } 58 59 var _hclstrtok_index_offsets []byte = []byte{ 60 0, 0, 2, 4, 6, 11, 16, 21, 61 26, 32, 37, 43, 49, 55, 61, 68, 62 74, 82, 91, 100, 109, 118, 127, 136, 63 145, 64 } 65 66 var _hclstrtok_indicies []byte = []byte{ 67 0, 1, 2, 1, 3, 1, 5, 6, 68 7, 8, 4, 10, 11, 12, 13, 9, 69 14, 11, 12, 13, 9, 10, 11, 15, 70 13, 9, 10, 11, 12, 13, 14, 9, 71 10, 11, 12, 15, 9, 17, 18, 19, 72 20, 21, 16, 23, 24, 25, 26, 27, 73 22, 0, 24, 25, 26, 27, 22, 23, 74 24, 28, 26, 27, 22, 23, 24, 25, 75 26, 27, 0, 22, 23, 24, 25, 28, 76 27, 22, 29, 30, 22, 2, 3, 31, 77 22, 0, 23, 24, 25, 26, 27, 32, 78 32, 32, 22, 23, 24, 25, 26, 27, 79 33, 33, 33, 22, 23, 24, 25, 26, 80 27, 34, 34, 34, 22, 23, 24, 25, 81 26, 27, 30, 30, 30, 22, 23, 24, 82 25, 26, 27, 35, 35, 35, 22, 23, 83 24, 25, 26, 27, 36, 36, 36, 22, 84 23, 24, 25, 26, 27, 37, 37, 37, 85 22, 23, 24, 25, 26, 27, 0, 0, 86 0, 22, 87 } 88 89 var _hclstrtok_trans_targs []byte = []byte{ 90 11, 0, 1, 2, 4, 5, 6, 7, 91 9, 4, 5, 6, 7, 9, 5, 8, 92 10, 11, 12, 13, 15, 16, 10, 11, 93 12, 13, 15, 16, 14, 17, 21, 3, 94 18, 19, 20, 22, 23, 24, 95 } 96 97 var _hclstrtok_trans_actions []byte = []byte{ 98 0, 0, 0, 0, 0, 1, 1, 1, 99 1, 3, 5, 5, 5, 5, 0, 0, 100 0, 1, 1, 1, 1, 1, 3, 5, 101 5, 5, 5, 5, 0, 0, 0, 0, 102 0, 0, 0, 0, 0, 0, 103 } 104 105 var _hclstrtok_eof_actions []byte = []byte{ 106 0, 0, 0, 0, 0, 3, 3, 3, 107 3, 3, 0, 3, 3, 3, 3, 3, 108 3, 3, 3, 3, 3, 3, 3, 3, 109 3, 110 } 111 112 const hclstrtok_start int = 4 113 const hclstrtok_first_final int = 4 114 const hclstrtok_error int = 0 115 116 const hclstrtok_en_quoted int = 10 117 const hclstrtok_en_unquoted int = 4 118 119 //line scan_string_lit.rl:12 120 121 func scanStringLit(data []byte, quoted bool) [][]byte { 122 var ret [][]byte 123 124 //line scan_string_lit.rl:63 125 126 // Ragel state 127 p := 0 // "Pointer" into data 128 pe := len(data) // End-of-data "pointer" 129 ts := 0 130 te := 0 131 eof := pe 132 133 var cs int // current state 134 switch { 135 case quoted: 136 cs = hclstrtok_en_quoted 137 default: 138 cs = hclstrtok_en_unquoted 139 } 140 141 // Make Go compiler happy 142 _ = ts 143 _ = eof 144 145 /*token := func () { 146 ret = append(ret, data[ts:te]) 147 }*/ 148 149 //line scan_string_lit.go:156 150 { 151 } 152 153 //line scan_string_lit.go:160 154 { 155 var _klen int 156 var _trans int 157 var _acts int 158 var _nacts uint 159 var _keys int 160 if p == pe { 161 goto _test_eof 162 } 163 if cs == 0 { 164 goto _out 165 } 166 _resume: 167 _keys = int(_hclstrtok_key_offsets[cs]) 168 _trans = int(_hclstrtok_index_offsets[cs]) 169 170 _klen = int(_hclstrtok_single_lengths[cs]) 171 if _klen > 0 { 172 _lower := int(_keys) 173 var _mid int 174 _upper := int(_keys + _klen - 1) 175 for { 176 if _upper < _lower { 177 break 178 } 179 180 _mid = _lower + ((_upper - _lower) >> 1) 181 switch { 182 case data[p] < _hclstrtok_trans_keys[_mid]: 183 _upper = _mid - 1 184 case data[p] > _hclstrtok_trans_keys[_mid]: 185 _lower = _mid + 1 186 default: 187 _trans += int(_mid - int(_keys)) 188 goto _match 189 } 190 } 191 _keys += _klen 192 _trans += _klen 193 } 194 195 _klen = int(_hclstrtok_range_lengths[cs]) 196 if _klen > 0 { 197 _lower := int(_keys) 198 var _mid int 199 _upper := int(_keys + (_klen << 1) - 2) 200 for { 201 if _upper < _lower { 202 break 203 } 204 205 _mid = _lower + (((_upper - _lower) >> 1) & ^1) 206 switch { 207 case data[p] < _hclstrtok_trans_keys[_mid]: 208 _upper = _mid - 2 209 case data[p] > _hclstrtok_trans_keys[_mid+1]: 210 _lower = _mid + 2 211 default: 212 _trans += int((_mid - int(_keys)) >> 1) 213 goto _match 214 } 215 } 216 _trans += _klen 217 } 218 219 _match: 220 _trans = int(_hclstrtok_indicies[_trans]) 221 cs = int(_hclstrtok_trans_targs[_trans]) 222 223 if _hclstrtok_trans_actions[_trans] == 0 { 224 goto _again 225 } 226 227 _acts = int(_hclstrtok_trans_actions[_trans]) 228 _nacts = uint(_hclstrtok_actions[_acts]) 229 _acts++ 230 for ; _nacts > 0; _nacts-- { 231 _acts++ 232 switch _hclstrtok_actions[_acts-1] { 233 case 0: 234 //line scan_string_lit.rl:42 235 236 // If te is behind p then we've skipped over some literal 237 // characters which we must now return. 238 if te < p { 239 ret = append(ret, data[te:p]) 240 } 241 ts = p 242 243 case 1: 244 //line scan_string_lit.rl:50 245 246 te = p 247 ret = append(ret, data[ts:te]) 248 249 //line scan_string_lit.go:255 250 } 251 } 252 253 _again: 254 if cs == 0 { 255 goto _out 256 } 257 p++ 258 if p != pe { 259 goto _resume 260 } 261 _test_eof: 262 { 263 } 264 if p == eof { 265 __acts := _hclstrtok_eof_actions[cs] 266 __nacts := uint(_hclstrtok_actions[__acts]) 267 __acts++ 268 for ; __nacts > 0; __nacts-- { 269 __acts++ 270 switch _hclstrtok_actions[__acts-1] { 271 case 1: 272 //line scan_string_lit.rl:50 273 274 te = p 275 ret = append(ret, data[ts:te]) 276 277 //line scan_string_lit.go:280 278 } 279 } 280 } 281 282 _out: 283 { 284 } 285 } 286 287 //line scan_string_lit.rl:91 288 289 if te < p { 290 // Collect any leftover literal characters at the end of the input 291 ret = append(ret, data[te:p]) 292 } 293 294 // If we fall out here without being in a final state then we've 295 // encountered something that the scanner can't match, which should 296 // be impossible (the scanner matches all bytes _somehow_) but we'll 297 // tolerate it and let the caller deal with it. 298 if cs < hclstrtok_first_final { 299 ret = append(ret, data[p:len(data)]) 300 } 301 302 return ret 303 }