1use crate::util::*;
2use crate::*;
3use std::os;
4pub type __u8 = os::raw::c_uchar;
5pub type __u16 = os::raw::c_ushort;
6pub type __int32_t = os::raw::c_int;
7pub type __u32 = os::raw::c_uint;
8pub type int32_t = __int32_t;
9pub type TSSymbol = u16;
10pub const TSInputEncodingUTF16: TSInputEncoding = 1;
11pub const TSInputEncodingUTF8: TSInputEncoding = 0;
12pub const TSLogTypeLex: TSLogType = 1;
13pub const TSLogTypeParse: TSLogType = 0;
14#[derive(Copy, Clone)]
15#[repr(C)]
16pub struct Lexer {
17 pub data: TSLexer,
18 pub current_position: Length,
19 pub token_start_position: Length,
20 pub token_end_position: Length,
21 pub included_ranges: *mut TSRange,
22 pub chunk: *const os::raw::c_char,
23 pub input: TSInput,
24 pub logger: TSLogger,
25 pub included_range_count: u32,
26 pub current_included_range_index: u32,
27 pub chunk_start: u32,
28 pub chunk_size: u32,
29 pub lookahead_size: u32,
30 pub did_get_column: bool,
31 pub debug_buffer: [os::raw::c_char; 1024],
32}
33pub type UnicodeDecodeFunction = Option<unsafe extern "C" fn(*const u8, u32, *mut int32_t) -> u32>;
34pub type UChar32 = int32_t;
35static mut LENGTH_UNDEFINED: Length = {
36 let mut init = Length {
37 bytes: 0 as os::raw::c_int as u32,
38 extent: {
39 let mut init = TSPoint {
40 row: 0 as os::raw::c_int as u32,
41 column: 1 as os::raw::c_int as u32,
42 };
43 init
44 },
45 };
46 init
47};
48#[inline]
49unsafe extern "C" fn length_is_undefined(mut length: Length) -> bool {
50 return length.bytes == 0 as os::raw::c_int as os::raw::c_uint
51 && length.extent.column != 0 as os::raw::c_int as os::raw::c_uint;
52}
53static mut TS_DECODE_ERROR: int32_t = -(1 as os::raw::c_int);
54#[inline]
55unsafe extern "C" fn ts_decode_utf8(
56 mut string: *const u8,
57 mut length: u32,
58 mut code_point: *mut int32_t,
59) -> u32 {
60 let mut i: u32 = 0 as os::raw::c_int as u32;
61 let fresh0 = i;
62 i = i.wrapping_add(1);
63 *code_point = *string.offset(fresh0 as isize) as int32_t;
64 if !(*code_point & 0x80 as os::raw::c_int == 0 as os::raw::c_int) {
65 let mut __t: u8 = 0 as os::raw::c_int as u8;
66 if !(i != length
67 && (if *code_point >= 0xe0 as os::raw::c_int {
68 ((if *code_point < 0xf0 as os::raw::c_int {
69 *code_point &= 0xf as os::raw::c_int;
70 __t = *string.offset(i as isize);
71 ((*::std::mem::transmute::<&[u8; 17], &[os::raw::c_char; 17]>(
72 b" 000000000000\x1000\0",
73 ))[*code_point as usize] as os::raw::c_int
74 & (1 as os::raw::c_int) << (__t as os::raw::c_int >> 5 as os::raw::c_int)
75 != 0
76 && {
77 __t = (__t as os::raw::c_int & 0x3f as os::raw::c_int) as u8;
78 true
79 }) as os::raw::c_int
80 } else {
81 *code_point -= 0xf0 as os::raw::c_int;
82 (*code_point <= 4 as os::raw::c_int
83 && {
84 __t = *string.offset(i as isize);
85 (*::std::mem::transmute::<&[u8; 17], &[os::raw::c_char; 17]>(
86 b"\0\0\0\0\0\0\0\0\x1E\x0F\x0F\x0F\0\0\0\0\0",
87 ))
88 [(__t as os::raw::c_int >> 4 as os::raw::c_int) as usize]
89 as os::raw::c_int
90 & (1 as os::raw::c_int) << *code_point
91 != 0
92 }
93 && {
94 *code_point = *code_point << 6 as os::raw::c_int
95 | __t as os::raw::c_int & 0x3f as os::raw::c_int;
96 i = i.wrapping_add(1);
97 i != length
98 }
99 && {
100 __t = (*string.offset(i as isize) as os::raw::c_int
101 - 0x80 as os::raw::c_int) as u8;
102 __t as os::raw::c_int <= 0x3f as os::raw::c_int
103 }) as os::raw::c_int
104 }) != 0
105 && {
106 *code_point = *code_point << 6 as os::raw::c_int | __t as os::raw::c_int;
107 i = i.wrapping_add(1);
108 i != length
109 }) as os::raw::c_int
110 } else {
111 (*code_point >= 0xc2 as os::raw::c_int && {
112 *code_point &= 0x1f as os::raw::c_int;
113 true
114 }) as os::raw::c_int
115 }) != 0
116 && {
117 __t = (*string.offset(i as isize) as os::raw::c_int - 0x80 as os::raw::c_int) as u8;
118 __t as os::raw::c_int <= 0x3f as os::raw::c_int
119 }
120 && {
121 *code_point = *code_point << 6 as os::raw::c_int | __t as os::raw::c_int;
122 i = i.wrapping_add(1);
123 true
124 })
125 {
126 *code_point = -(1 as os::raw::c_int);
127 }
128 }
129 return i;
130}
131#[inline]
132unsafe extern "C" fn ts_decode_utf16(
133 mut string: *const u8,
134 mut length: u32,
135 mut code_point: *mut int32_t,
136) -> u32 {
137 let mut i: u32 = 0 as os::raw::c_int as u32;
138 let fresh1 = i;
139 i = i.wrapping_add(1);
140 *code_point = *(string as *mut u16).offset(fresh1 as isize) as int32_t;
141 if *code_point as os::raw::c_uint & 0xfffffc00 as os::raw::c_uint
142 == 0xd800 as os::raw::c_int as os::raw::c_uint
143 {
144 let mut __c2: u16 = 0;
145 if i != length && {
146 __c2 = *(string as *mut u16).offset(i as isize);
147 __c2 as os::raw::c_uint & 0xfffffc00 as os::raw::c_uint
148 == 0xdc00 as os::raw::c_int as os::raw::c_uint
149 } {
150 i = i.wrapping_add(1);
151 *code_point = (*code_point << 10 as usize) + __c2 as UChar32
152 - (((0xd800 as os::raw::c_int) << 10 as usize) + 0xdc00 as os::raw::c_int
153 - 0x10000 as os::raw::c_int);
154 }
155 }
156 return i.wrapping_mul(2 as os::raw::c_int as os::raw::c_uint);
157}
158static mut BYTE_ORDER_MARK: int32_t = 0xfeff as os::raw::c_int;
159static mut DEFAULT_RANGE: TSRange = {
160 let mut init = TSRange {
161 start_point: {
162 let mut init = TSPoint {
163 row: 0 as os::raw::c_int as u32,
164 column: 0 as os::raw::c_int as u32,
165 };
166 init
167 },
168 end_point: {
169 let mut init = TSPoint {
170 row: 4294967295 as os::raw::c_uint,
171 column: 4294967295 as os::raw::c_uint,
172 };
173 init
174 },
175 start_byte: 0 as os::raw::c_int as u32,
176 end_byte: 4294967295 as os::raw::c_uint,
177 };
178 init
179};
180unsafe extern "C" fn ts_lexer__eof(mut _self: *const TSLexer) -> bool {
181 let mut self_0: *mut Lexer = _self as *mut Lexer;
182 return (*self_0).current_included_range_index == (*self_0).included_range_count;
183}
184unsafe extern "C" fn ts_lexer__clear_chunk(mut self_0: *mut Lexer) {
185 let ref mut fresh2 = (*self_0).chunk;
186 *fresh2 = 0 as *const os::raw::c_char;
187 (*self_0).chunk_size = 0 as os::raw::c_int as u32;
188 (*self_0).chunk_start = 0 as os::raw::c_int as u32;
189}
190unsafe extern "C" fn ts_lexer__get_chunk(mut self_0: *mut Lexer) {
191 (*self_0).chunk_start = (*self_0).current_position.bytes;
192 let ref mut fresh3 = (*self_0).chunk;
193 *fresh3 = ((*self_0).input.read).expect("non-null function pointer")(
194 (*self_0).input.payload,
195 (*self_0).current_position.bytes,
196 (*self_0).current_position.extent,
197 &mut (*self_0).chunk_size,
198 );
199 if (*self_0).chunk_size == 0 {
200 (*self_0).current_included_range_index = (*self_0).included_range_count;
201 let ref mut fresh4 = (*self_0).chunk;
202 *fresh4 = 0 as *const os::raw::c_char;
203 }
204}
205unsafe extern "C" fn ts_lexer__get_lookahead(mut self_0: *mut Lexer) {
206 let mut position_in_chunk: u32 =
207 ((*self_0).current_position.bytes).wrapping_sub((*self_0).chunk_start);
208 let mut size: u32 = ((*self_0).chunk_size).wrapping_sub(position_in_chunk);
209 if size == 0 as os::raw::c_int as os::raw::c_uint {
210 (*self_0).lookahead_size = 1 as os::raw::c_int as u32;
211 (*self_0).data.lookahead = '\0' as i32;
212 return;
213 }
214 let mut chunk: *const u8 = ((*self_0).chunk as *const u8).offset(position_in_chunk as isize);
215 let mut decode: UnicodeDecodeFunction = if (*self_0).input.encoding as os::raw::c_uint
216 == TSInputEncodingUTF8 as os::raw::c_int as os::raw::c_uint
217 {
218 Some(ts_decode_utf8 as unsafe extern "C" fn(*const u8, u32, *mut int32_t) -> u32)
219 } else {
220 Some(ts_decode_utf16 as unsafe extern "C" fn(*const u8, u32, *mut int32_t) -> u32)
221 };
222 (*self_0).lookahead_size =
223 decode.expect("non-null function pointer")(chunk, size, &mut (*self_0).data.lookahead);
224 if (*self_0).data.lookahead == TS_DECODE_ERROR && size < 4 as os::raw::c_int as os::raw::c_uint
225 {
226 ts_lexer__get_chunk(self_0);
227 chunk = (*self_0).chunk as *const u8;
228 size = (*self_0).chunk_size;
229 (*self_0).lookahead_size =
230 decode.expect("non-null function pointer")(chunk, size, &mut (*self_0).data.lookahead);
231 }
232 if (*self_0).data.lookahead == TS_DECODE_ERROR {
233 (*self_0).lookahead_size = 1 as os::raw::c_int as u32;
234 }
235}
236unsafe extern "C" fn ts_lexer_goto(mut self_0: *mut Lexer, mut position: Length) {
237 (*self_0).current_position = position;
238 let mut found_included_range: bool = false;
239 let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
240 while i < (*self_0).included_range_count {
241 let mut included_range: *mut TSRange =
242 &mut *((*self_0).included_ranges).offset(i as isize) as *mut TSRange;
243 if (*included_range).end_byte > position.bytes {
244 if (*included_range).start_byte >= position.bytes {
245 (*self_0).current_position = {
246 let mut init = Length {
247 bytes: (*included_range).start_byte,
248 extent: (*included_range).start_point,
249 };
250 init
251 };
252 }
253 (*self_0).current_included_range_index = i;
254 found_included_range = true;
255 break;
256 } else {
257 i = i.wrapping_add(1);
258 }
259 }
260 if found_included_range {
261 if !((*self_0).chunk).is_null()
262 && (position.bytes < (*self_0).chunk_start
263 || position.bytes >= ((*self_0).chunk_start).wrapping_add((*self_0).chunk_size))
264 {
265 ts_lexer__clear_chunk(self_0);
266 }
267 (*self_0).lookahead_size = 0 as os::raw::c_int as u32;
268 (*self_0).data.lookahead = '\0' as i32;
269 } else {
270 (*self_0).current_included_range_index = (*self_0).included_range_count;
271 let mut last_included_range: *mut TSRange = &mut *((*self_0).included_ranges).offset(
272 ((*self_0).included_range_count).wrapping_sub(1 as os::raw::c_int as os::raw::c_uint)
273 as isize,
274 ) as *mut TSRange;
275 (*self_0).current_position = {
276 let mut init = Length {
277 bytes: (*last_included_range).end_byte,
278 extent: (*last_included_range).end_point,
279 };
280 init
281 };
282 ts_lexer__clear_chunk(self_0);
283 (*self_0).lookahead_size = 1 as os::raw::c_int as u32;
284 (*self_0).data.lookahead = '\0' as i32;
285 };
286}
287unsafe extern "C" fn ts_lexer__do_advance(mut self_0: *mut Lexer, mut skip: bool) {
288 if (*self_0).lookahead_size != 0 {
289 let ref mut fresh5 = (*self_0).current_position.bytes;
290 *fresh5 = (*fresh5 as os::raw::c_uint).wrapping_add((*self_0).lookahead_size) as u32 as u32;
291 if (*self_0).data.lookahead == '\n' as i32 {
292 let ref mut fresh6 = (*self_0).current_position.extent.row;
293 *fresh6 = (*fresh6).wrapping_add(1);
294 (*self_0).current_position.extent.column = 0 as os::raw::c_int as u32;
295 } else {
296 let ref mut fresh7 = (*self_0).current_position.extent.column;
297 *fresh7 =
298 (*fresh7 as os::raw::c_uint).wrapping_add((*self_0).lookahead_size) as u32 as u32;
299 }
300 }
301 let mut current_range: *const TSRange = 0 as *const TSRange;
302 if (*self_0).current_included_range_index < (*self_0).included_range_count {
303 current_range = &mut *((*self_0).included_ranges)
304 .offset((*self_0).current_included_range_index as isize)
305 as *mut TSRange;
306 if (*self_0).current_position.bytes == (*current_range).end_byte {
307 let ref mut fresh8 = (*self_0).current_included_range_index;
308 *fresh8 = (*fresh8).wrapping_add(1);
309 if (*self_0).current_included_range_index < (*self_0).included_range_count {
310 current_range = current_range.offset(1);
311 (*self_0).current_position = {
312 let mut init = Length {
313 bytes: (*current_range).start_byte,
314 extent: (*current_range).start_point,
315 };
316 init
317 };
318 } else {
319 current_range = 0 as *const TSRange;
320 }
321 }
322 }
323 if skip {
324 (*self_0).token_start_position = (*self_0).current_position;
325 }
326 if !current_range.is_null() {
327 if (*self_0).current_position.bytes
328 >= ((*self_0).chunk_start).wrapping_add((*self_0).chunk_size)
329 {
330 ts_lexer__get_chunk(self_0);
331 }
332 ts_lexer__get_lookahead(self_0);
333 } else {
334 ts_lexer__clear_chunk(self_0);
335 (*self_0).data.lookahead = '\0' as i32;
336 (*self_0).lookahead_size = 1 as os::raw::c_int as u32;
337 };
338}
339unsafe extern "C" fn ts_lexer__advance(mut _self: *mut TSLexer, mut skip: bool) {
340 let mut self_0: *mut Lexer = _self as *mut Lexer;
341 if ((*self_0).chunk).is_null() {
342 return;
343 }
344 if skip {
345 if ((*self_0).logger.log).is_some() {
346 {
347 if 32 as os::raw::c_int <= (*self_0).data.lookahead
348 && (*self_0).data.lookahead < 127 as os::raw::c_int
349 {
350 snwrite!(
351 ((*self_0).debug_buffer).as_mut_ptr(),
352 1024 as os::raw::c_int as usize as usize,
353 "skip character:'{}'",
354 (*self_0).data.lookahead as u8 as char
355 )
356 .unwrap_or(usize::MAX) as os::raw::c_int
357 } else {
358 snwrite!(
359 ((*self_0).debug_buffer).as_mut_ptr(),
360 1024 as os::raw::c_int as usize as usize,
361 "skip character:{}",
362 (*self_0).data.lookahead
363 )
364 .unwrap_or(usize::MAX) as os::raw::c_int
365 }
366 };
367 ((*self_0).logger.log).expect("non-null function pointer")(
368 (*self_0).logger.payload,
369 TSLogTypeLex,
370 ((*self_0).debug_buffer).as_mut_ptr(),
371 );
372 }
373 } else if ((*self_0).logger.log).is_some() {
374 {
375 if 32 as os::raw::c_int <= (*self_0).data.lookahead
376 && (*self_0).data.lookahead < 127 as os::raw::c_int
377 {
378 snwrite!(
379 ((*self_0).debug_buffer).as_mut_ptr(),
380 1024 as os::raw::c_int as usize as usize,
381 "consume character:'{}'",
382 (*self_0).data.lookahead as u8 as char
383 )
384 .unwrap_or(usize::MAX) as os::raw::c_int
385 } else {
386 snwrite!(
387 ((*self_0).debug_buffer).as_mut_ptr(),
388 1024 as os::raw::c_int as usize as usize,
389 "consume character:{}",
390 (*self_0).data.lookahead
391 )
392 .unwrap_or(usize::MAX) as os::raw::c_int
393 }
394 };
395 ((*self_0).logger.log).expect("non-null function pointer")(
396 (*self_0).logger.payload,
397 TSLogTypeLex,
398 ((*self_0).debug_buffer).as_mut_ptr(),
399 );
400 }
401 ts_lexer__do_advance(self_0, skip);
402}
403unsafe extern "C" fn ts_lexer__mark_end(mut _self: *mut TSLexer) {
404 let mut self_0: *mut Lexer = _self as *mut Lexer;
405 if !ts_lexer__eof(&mut (*self_0).data) {
406 let mut current_included_range: *mut TSRange = &mut *((*self_0).included_ranges)
407 .offset((*self_0).current_included_range_index as isize)
408 as *mut TSRange;
409 if (*self_0).current_included_range_index > 0 as os::raw::c_int as os::raw::c_uint
410 && (*self_0).current_position.bytes == (*current_included_range).start_byte
411 {
412 let mut previous_included_range: *mut TSRange =
413 current_included_range.offset(-(1 as os::raw::c_int as isize));
414 (*self_0).token_end_position = {
415 let mut init = Length {
416 bytes: (*previous_included_range).end_byte,
417 extent: (*previous_included_range).end_point,
418 };
419 init
420 };
421 return;
422 }
423 }
424 (*self_0).token_end_position = (*self_0).current_position;
425}
426unsafe extern "C" fn ts_lexer__get_column(mut _self: *mut TSLexer) -> u32 {
427 let mut self_0: *mut Lexer = _self as *mut Lexer;
428 let mut goal_byte: u32 = (*self_0).current_position.bytes;
429 (*self_0).did_get_column = true;
430 let ref mut fresh9 = (*self_0).current_position.bytes;
431 *fresh9 = (*fresh9 as os::raw::c_uint).wrapping_sub((*self_0).current_position.extent.column)
432 as u32 as u32;
433 (*self_0).current_position.extent.column = 0 as os::raw::c_int as u32;
434 if (*self_0).current_position.bytes < (*self_0).chunk_start {
435 ts_lexer__get_chunk(self_0);
436 }
437 let mut result: u32 = 0 as os::raw::c_int as u32;
438 ts_lexer__get_lookahead(self_0);
439 while (*self_0).current_position.bytes < goal_byte
440 && !ts_lexer__eof(_self)
441 && !((*self_0).chunk).is_null()
442 {
443 ts_lexer__do_advance(self_0, false);
444 result = result.wrapping_add(1);
445 }
446 return result;
447}
448unsafe extern "C" fn ts_lexer__is_at_included_range_start(mut _self: *const TSLexer) -> bool {
449 let mut self_0: *const Lexer = _self as *const Lexer;
450 if (*self_0).current_included_range_index < (*self_0).included_range_count {
451 let mut current_range: *mut TSRange = &mut *((*self_0).included_ranges)
452 .offset((*self_0).current_included_range_index as isize)
453 as *mut TSRange;
454 return (*self_0).current_position.bytes == (*current_range).start_byte;
455 } else {
456 return false;
457 };
458}
459#[no_mangle]
460pub unsafe extern "C" fn ts_lexer_init(mut self_0: *mut Lexer) {
461 *self_0 = {
462 let mut init = Lexer {
463 data: {
464 let mut init = TSLexer {
465 lookahead: 0 as os::raw::c_int,
466 result_symbol: 0 as os::raw::c_int as TSSymbol,
467 advance: Some(
468 ts_lexer__advance as unsafe extern "C" fn(*mut TSLexer, bool) -> (),
469 ),
470 mark_end: Some(ts_lexer__mark_end as unsafe extern "C" fn(*mut TSLexer) -> ()),
471 get_column: Some(
472 ts_lexer__get_column as unsafe extern "C" fn(*mut TSLexer) -> u32,
473 ),
474 is_at_included_range_start: Some(
475 ts_lexer__is_at_included_range_start
476 as unsafe extern "C" fn(*const TSLexer) -> bool,
477 ),
478 eof: Some(ts_lexer__eof as unsafe extern "C" fn(*const TSLexer) -> bool),
479 };
480 init
481 },
482 current_position: {
483 let mut init = Length {
484 bytes: 0 as os::raw::c_int as u32,
485 extent: {
486 let mut init = TSPoint {
487 row: 0 as os::raw::c_int as u32,
488 column: 0 as os::raw::c_int as u32,
489 };
490 init
491 },
492 };
493 init
494 },
495 token_start_position: Length {
496 bytes: 0,
497 extent: TSPoint { row: 0, column: 0 },
498 },
499 token_end_position: Length {
500 bytes: 0,
501 extent: TSPoint { row: 0, column: 0 },
502 },
503 included_ranges: 0 as *mut TSRange,
504 chunk: 0 as *const os::raw::c_char,
505 input: TSInput {
506 payload: 0 as *mut os::raw::c_void,
507 read: None,
508 encoding: TSInputEncodingUTF8,
509 },
510 logger: {
511 let mut init = TSLogger {
512 payload: 0 as *mut os::raw::c_void,
513 log: None,
514 };
515 init
516 },
517 included_range_count: 0 as os::raw::c_int as u32,
518 current_included_range_index: 0 as os::raw::c_int as u32,
519 chunk_start: 0 as os::raw::c_int as u32,
520 chunk_size: 0 as os::raw::c_int as u32,
521 lookahead_size: 0,
522 did_get_column: false,
523 debug_buffer: [0; 1024],
524 };
525 init
526 };
527 ts_lexer_set_included_ranges(self_0, 0 as *const TSRange, 0 as os::raw::c_int as u32);
528}
529#[no_mangle]
530pub unsafe extern "C" fn ts_lexer_delete(mut self_0: *mut Lexer) {
531 crate::alloc::ts_free((*self_0).included_ranges as *mut os::raw::c_void);
532}
533#[no_mangle]
534pub unsafe extern "C" fn ts_lexer_set_input(mut self_0: *mut Lexer, mut input: TSInput) {
535 (*self_0).input = input;
536 ts_lexer__clear_chunk(self_0);
537 ts_lexer_goto(self_0, (*self_0).current_position);
538}
539#[no_mangle]
540pub unsafe extern "C" fn ts_lexer_reset(mut self_0: *mut Lexer, mut position: Length) {
541 if position.bytes != (*self_0).current_position.bytes {
542 ts_lexer_goto(self_0, position);
543 }
544}
545#[no_mangle]
546pub unsafe extern "C" fn ts_lexer_start(mut self_0: *mut Lexer) {
547 (*self_0).token_start_position = (*self_0).current_position;
548 (*self_0).token_end_position = LENGTH_UNDEFINED;
549 (*self_0).data.result_symbol = 0 as os::raw::c_int as TSSymbol;
550 (*self_0).did_get_column = false;
551 if !ts_lexer__eof(&mut (*self_0).data) {
552 if (*self_0).chunk_size == 0 {
553 ts_lexer__get_chunk(self_0);
554 }
555 if (*self_0).lookahead_size == 0 {
556 ts_lexer__get_lookahead(self_0);
557 }
558 if (*self_0).current_position.bytes == 0 as os::raw::c_int as os::raw::c_uint
559 && (*self_0).data.lookahead == BYTE_ORDER_MARK
560 {
561 ts_lexer__advance(&mut (*self_0).data, true);
562 }
563 }
564}
565#[no_mangle]
566pub unsafe extern "C" fn ts_lexer_finish(mut self_0: *mut Lexer, mut lookahead_end_byte: *mut u32) {
567 if length_is_undefined((*self_0).token_end_position) {
568 ts_lexer__mark_end(&mut (*self_0).data);
569 }
570 let mut current_lookahead_end_byte: u32 =
571 ((*self_0).current_position.bytes).wrapping_add(1 as os::raw::c_int as os::raw::c_uint);
572 if (*self_0).data.lookahead == TS_DECODE_ERROR {
573 current_lookahead_end_byte = current_lookahead_end_byte.wrapping_add(1);
574 }
575 if current_lookahead_end_byte > *lookahead_end_byte {
576 *lookahead_end_byte = current_lookahead_end_byte;
577 }
578}
579#[no_mangle]
580pub unsafe extern "C" fn ts_lexer_advance_to_end(mut self_0: *mut Lexer) {
581 while !((*self_0).chunk).is_null() {
582 ts_lexer__advance(&mut (*self_0).data, false);
583 }
584}
585#[no_mangle]
586pub unsafe extern "C" fn ts_lexer_mark_end(mut self_0: *mut Lexer) {
587 ts_lexer__mark_end(&mut (*self_0).data);
588}
589#[no_mangle]
590pub unsafe extern "C" fn ts_lexer_set_included_ranges(
591 mut self_0: *mut Lexer,
592 mut ranges: *const TSRange,
593 mut count: u32,
594) -> bool {
595 if count == 0 as os::raw::c_int as os::raw::c_uint || ranges.is_null() {
596 ranges = &DEFAULT_RANGE;
597 count = 1 as os::raw::c_int as u32;
598 } else {
599 let mut previous_byte: u32 = 0 as os::raw::c_int as u32;
600 let mut i: os::raw::c_uint = 0 as os::raw::c_int as os::raw::c_uint;
601 while i < count {
602 let mut range: *const TSRange = &*ranges.offset(i as isize) as *const TSRange;
603 if (*range).start_byte < previous_byte || (*range).end_byte < (*range).start_byte {
604 return false;
605 }
606 previous_byte = (*range).end_byte;
607 i = i.wrapping_add(1);
608 }
609 }
610 let mut size: size_t = (count as usize).wrapping_mul(::std::mem::size_of::<TSRange>() as usize);
611 let ref mut fresh10 = (*self_0).included_ranges;
612 *fresh10 = crate::alloc::ts_realloc((*self_0).included_ranges as *mut os::raw::c_void, size)
613 as *mut TSRange;
614 std::ptr::copy_nonoverlapping(
615 ranges as *const os::raw::c_void,
616 (*self_0).included_ranges as *mut os::raw::c_void,
617 size,
618 );
619 (*self_0).included_range_count = count;
620 ts_lexer_goto(self_0, (*self_0).current_position);
621 return true;
622}
623#[no_mangle]
624pub unsafe extern "C" fn ts_lexer_included_ranges(
625 mut self_0: *const Lexer,
626 mut count: *mut u32,
627) -> *mut TSRange {
628 *count = (*self_0).included_range_count;
629 return (*self_0).included_ranges;
630}