Method: Liquidscript::Scanner::Lexer#perform

Defined in:
lib/liquidscript/scanner/lexer.rb

#perform(data) ⇒ Object



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# File 'lib/liquidscript/scanner/lexer.rb', line 399

def perform(data)
  @data = data.unpack("c*") if data.is_a? String
  @eof = data.length

  @tokens = []

  line = proc do
    @line[:start] = @ts
    @line[:num] += 1
    emit :newline
  end

  
# line 413 "lib/liquidscript/scanner/lexer.rb"
begin
	    @p ||= 0
	   @pe ||=  @data.length
	 @cs = lexer_start
	 @ts = nil
	 @te = nil
	 @act = 0
end

# line 110 "lib/liquidscript/scanner/lexer.rl"
  
# line 425 "lib/liquidscript/scanner/lexer.rb"
begin
	_klen, _trans, _keys, _acts, _nacts = nil
	_goto_level = 0
	_resume = 10
	_eof_trans = 15
	_again = 20
	_test_eof = 30
	_out = 40
	while true
	_trigger_goto = false
	if _goto_level <= 0
	if     @p ==    @pe
		_goto_level = _test_eof
		next
	end
	end
	if _goto_level <= _resume
	_acts = _lexer_from_state_actions[ @cs]
	_nacts = _lexer_actions[_acts]
	_acts += 1
	while _nacts > 0
		_nacts -= 1
		_acts += 1
		case _lexer_actions[_acts - 1]
			when 1 then
# line 1 "NONE"
		begin
 @ts =     @p
		end
# line 455 "lib/liquidscript/scanner/lexer.rb"
		end # from state action switch
	end
	if _trigger_goto
		next
	end
	_keys = _lexer_key_offsets[ @cs]
	_trans = _lexer_index_offsets[ @cs]
	_klen = _lexer_single_lengths[ @cs]
	_break_match = false
	
	begin
	  if _klen > 0
_lower = _keys
_upper = _keys + _klen - 1

loop do
   break if _upper < _lower
   _mid = _lower + ( (_upper - _lower) >> 1 )

   if  @data[    @p].ord < _lexer_trans_keys[_mid]
      _upper = _mid - 1
   elsif  @data[    @p].ord > _lexer_trans_keys[_mid]
      _lower = _mid + 1
   else
      _trans += (_mid - _keys)
      _break_match = true
      break
   end
end # loop
break if _break_match
_keys += _klen
_trans += _klen
	  end
	  _klen = _lexer_range_lengths[ @cs]
	  if _klen > 0
_lower = _keys
_upper = _keys + (_klen << 1) - 2
loop do
   break if _upper < _lower
   _mid = _lower + (((_upper-_lower) >> 1) & ~1)
   if  @data[    @p].ord < _lexer_trans_keys[_mid]
     _upper = _mid - 2
   elsif  @data[    @p].ord > _lexer_trans_keys[_mid+1]
     _lower = _mid + 2
   else
     _trans += ((_mid - _keys) >> 1)
     _break_match = true
     break
   end
end # loop
break if _break_match
_trans += _klen
	  end
	end while false
	_trans = _lexer_indicies[_trans]
	end
	if _goto_level <= _eof_trans
	 @cs = _lexer_trans_targs[_trans]
	if _lexer_trans_actions[_trans] != 0
		_acts = _lexer_trans_actions[_trans]
		_nacts = _lexer_actions[_acts]
		_acts += 1
		while _nacts > 0
			_nacts -= 1
			_acts += 1
			case _lexer_actions[_acts - 1]
when 2 then
# line 1 "NONE"
		begin
 @te =     @p+1
		end
when 3 then
# line 29 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 2;		end
when 4 then
# line 30 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 3;		end
when 5 then
# line 31 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 4;		end
when 6 then
# line 32 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 5;		end
when 7 then
# line 33 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 6;		end
when 8 then
# line 34 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 7;		end
when 9 then
# line 35 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 8;		end
when 10 then
# line 36 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 9;		end
when 11 then
# line 37 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 10;		end
when 12 then
# line 38 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 11;		end
when 13 then
# line 39 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 12;		end
when 14 then
# line 40 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 13;		end
when 15 then
# line 42 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 15;		end
when 16 then
# line 54 "lib/liquidscript/scanner/lexer.rl"
		begin
 @act = 27;		end
when 17 then
# line 29 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :dstring      end
		end
when 18 then
# line 37 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :unop         end
		end
when 19 then
# line 38 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :binop        end
		end
when 20 then
# line 41 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :arrow        end
		end
when 21 then
# line 43 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :lbrack       end
		end
when 22 then
# line 44 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :lparen       end
		end
when 23 then
# line 45 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :lbrace       end
		end
when 24 then
# line 46 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :rbrack       end
		end
when 25 then
# line 47 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :rparen       end
		end
when 26 then
# line 48 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :rbrace       end
		end
when 27 then
# line 49 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :colon        end
		end
when 28 then
# line 50 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :prop         end
		end
when 29 then
# line 51 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  emit :comma        end
		end
when 30 then
# line 52 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  line.call          end
		end
when 31 then
# line 53 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin                     end
		end
when 32 then
# line 54 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p+1
 begin  error              end
		end
when 33 then
# line 28 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p
    @p =     @p - 1; begin  emit :number       end
		end
when 34 then
# line 38 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p
    @p =     @p - 1; begin  emit :binop        end
		end
when 35 then
# line 40 "lib/liquidscript/scanner/lexer.rl"
		begin
 @te =     @p
    @p =     @p - 1; begin  emit :identifier   end
		end
when 36 then
# line 28 "lib/liquidscript/scanner/lexer.rl"
		begin
 begin     @p = (( @te))-1; end
 begin  emit :number       end
		end
when 37 then
# line 1 "NONE"
		begin
	case  @act
	when 2 then
	begin begin     @p = (( @te))-1; end
 emit :dstring     end
	when 3 then
	begin begin     @p = (( @te))-1; end
 emit :sstring     end
	when 4 then
	begin begin     @p = (( @te))-1; end
 emit :class       end
	when 5 then
	begin begin     @p = (( @te))-1; end
 emit :module      end
	when 6 then
	begin begin     @p = (( @te))-1; end
 emit :if          end
	when 7 then
	begin begin     @p = (( @te))-1; end
 emit :unless      end
	when 8 then
	begin begin     @p = (( @te))-1; end
 emit :elsif       end
	when 9 then
	begin begin     @p = (( @te))-1; end
 emit :else        end
	when 10 then
	begin begin     @p = (( @te))-1; end
 emit :unop        end
	when 11 then
	begin begin     @p = (( @te))-1; end
 emit :binop       end
	when 12 then
	begin begin     @p = (( @te))-1; end
 emit :keyword     end
	when 13 then
	begin begin     @p = (( @te))-1; end
 emit :identifier  end
	when 15 then
	begin begin     @p = (( @te))-1; end
 emit :equal       end
	when 27 then
	begin begin     @p = (( @te))-1; end
 error             end
end 
			end
# line 751 "lib/liquidscript/scanner/lexer.rb"
			end # action switch
		end
	end
	if _trigger_goto
		next
	end
	end
	if _goto_level <= _again
	_acts = _lexer_to_state_actions[ @cs]
	_nacts = _lexer_actions[_acts]
	_acts += 1
	while _nacts > 0
		_nacts -= 1
		_acts += 1
		case _lexer_actions[_acts - 1]
when 0 then
# line 1 "NONE"
		begin
 @ts = nil;		end
# line 771 "lib/liquidscript/scanner/lexer.rb"
		end # to state action switch
	end
	if _trigger_goto
		next
	end
	    @p += 1
	if     @p !=    @pe
		_goto_level = _resume
		next
	end
	end
	if _goto_level <= _test_eof
	if     @p ==   @eof
	if _lexer_eof_trans[ @cs] > 0
		_trans = _lexer_eof_trans[ @cs] - 1;
		_goto_level = _eof_trans
		next;
	end
end
	end
	if _goto_level <= _out
		break
	end
	end
	end

# line 111 "lib/liquidscript/scanner/lexer.rl"

  clean!

  @tokens
end